Example usage for org.eclipse.jdt.core.dom BodyDeclaration subtreeMatch

List of usage examples for org.eclipse.jdt.core.dom BodyDeclaration subtreeMatch

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom BodyDeclaration subtreeMatch.

Prototype

public final boolean subtreeMatch(ASTMatcher matcher, Object other) 

Source Link

Document

Returns whether the subtree rooted at the given node matches the given other object as decided by the given matcher.

Usage

From source file:de.fkoeberle.autocommit.message.java.helper.delta.DeclarationListDelta.java

License:Open Source License

public DeclarationListDelta(List<?> oldTypes, List<?> newTypes) {
    // Use a linked hash map so that the list of
    // removed declaration is in declaration order.
    Map<DeclarationId, BodyDeclaration> idToOldVersion = new LinkedHashMap<DeclarationId, BodyDeclaration>(
            oldTypes.size());/*from w  ww.  j  ava 2 s. c o  m*/
    this.addedDeclarations = new ArrayList<BodyDeclaration>();
    this.changedDeclarations = new ArrayList<DeclarationDelta<?>>();
    for (Object declarationObject : oldTypes) {
        BodyDeclaration declaration = (BodyDeclaration) declarationObject;
        DeclarationId id = declarationIdOf(declaration);
        idToOldVersion.put(id, declaration);
    }

    for (Object typeObject : newTypes) {
        BodyDeclaration newDeclaration = (BodyDeclaration) typeObject;
        DeclarationId id = declarationIdOf(newDeclaration);
        BodyDeclaration oldDeclaration = idToOldVersion.remove(id);
        if (oldDeclaration == null) {
            addedDeclarations.add(newDeclaration);
        } else {
            if (!oldDeclaration.subtreeMatch(new ASTMatcher(true), newDeclaration)) {
                changedDeclarations.add(createDeclarationDelta(oldDeclaration, newDeclaration));
            }
        }
    }
    this.removedDeclarations = new ArrayList<BodyDeclaration>(idToOldVersion.values());
}