List of usage examples for org.eclipse.jdt.core.dom BodyDeclaration subtreeMatch
public final boolean subtreeMatch(ASTMatcher matcher, Object other)
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()); }