All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.text.edits.TextEditVisitor Maven / Gradle / Ivy

There is a newer version: 1.9.22.1
Show newest version
/*******************************************************************************
 * Copyright (c) 2000, 2007 IBM Corporation and others.
 *
 * This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License 2.0
 * which accompanies this distribution, and is available at
 * https://www.eclipse.org/legal/epl-2.0/
 *
 * SPDX-License-Identifier: EPL-2.0
 *
 * Contributors:
 *     IBM Corporation - initial API and implementation
 *******************************************************************************/
package org.eclipse.text.edits;

/**
 * A visitor for text edits.
 * 

* For each different concrete text edit type T there is a method: *

*
    *
  • public boolean visit(T node) - Visits the given edit to * perform some arbitrary operation. If true is returned, the given edit's * child edits will be visited next; however, if false is returned, the * given edit's child edits will not be visited. The default implementation provided by * this class calls a generic method visitNode(TextEdit node). * Subclasses may reimplement these method as needed.
  • *
*

* In addition, there are methods for visiting text edits in the * abstract, regardless of node type: *

*
    *
  • public void preVisit(TextEdit edit) - Visits * the given edit to perform some arbitrary operation. * This method is invoked prior to the appropriate type-specific * visit method. * The default implementation of this method does nothing. * Subclasses may reimplement this method as needed.
  • * *
  • public void postVisit(TextEdit edit) - Visits * the given edit to perform some arbitrary operation. * This method is invoked after the appropriate type-specific * endVisit method. * The default implementation of this method does nothing. * Subclasses may reimplement this method as needed.
  • *
*

* For edits with children, the child nodes are visited in increasing order. *

* * @see TextEdit#accept(TextEditVisitor) * @since 3.0 */ public class TextEditVisitor { /** * Visits the given text edit prior to the type-specific visit. * (before visit). *

* The default implementation does nothing. Subclasses may reimplement. *

* * @param edit the node to visit */ public void preVisit(TextEdit edit) { // default implementation: do nothing } /** * Visits the given text edit following the type-specific visit * (after endVisit). *

* The default implementation does nothing. Subclasses may reimplement. *

* * @param edit the node to visit */ public void postVisit(TextEdit edit) { // default implementation: do nothing } /** * Visits the given text edit. This method is called by default from * type-specific visits. It is not called by an edit's accept method. * The default implementation returns true. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visitNode(TextEdit edit) { return true; } /** * Visits a CopySourceEdit instance. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visit(CopySourceEdit edit) { return visitNode(edit); } /** * Visits a CopyTargetEdit instance. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visit(CopyTargetEdit edit) { return visitNode(edit); } /** * Visits a MoveSourceEdit instance. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visit(MoveSourceEdit edit) { return visitNode(edit); } /** * Visits a MoveTargetEdit instance. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visit(MoveTargetEdit edit) { return visitNode(edit); } /** * Visits a RangeMarker instance. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visit(RangeMarker edit) { return visitNode(edit); } /** * Visits a CopyingRangeMarker instance. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visit(CopyingRangeMarker edit) { return visitNode(edit); } /** * Visits a DeleteEdit instance. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visit(DeleteEdit edit) { return visitNode(edit); } /** * Visits a InsertEdit instance. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visit(InsertEdit edit) { return visitNode(edit); } /** * Visits a ReplaceEdit instance. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visit(ReplaceEdit edit) { return visitNode(edit); } /** * Visits a UndoEdit instance. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visit(UndoEdit edit) { return visitNode(edit); } /** * Visits a MultiTextEdit instance. * * @param edit the node to visit * @return If true is returned, the given node's child * nodes will be visited next; however, if false is * returned, the given node's child nodes will not be visited. */ public boolean visit(MultiTextEdit edit) { return visitNode(edit); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy