List of usage examples for org.eclipse.jdt.core.dom ASTMatcher ASTMatcher
public ASTMatcher(boolean matchDocTags)
From source file:de.fkoeberle.autocommit.message.java.helper.ASTCompareUtil.java
License:Open Source License
/** * //from www . jav a2 s. c o m * @param oldList * must be a list of {@link ASTNode} objects. * @param newList * must be a list of {@link ASTNode} objects. * @return true if the two list of abstract syntax trees don't match. */ public static boolean listsOfASTNodesDiffer(List<?> oldList, List<?> newList) { if (oldList.size() != newList.size()) { return true; } int size = oldList.size(); for (int i = 0; i < size; i++) { ASTNode oldInterface = (ASTNode) (oldList.get(i)); ASTNode newInterface = (ASTNode) (newList.get(i)); boolean matches = oldInterface.subtreeMatch(new ASTMatcher(true), newInterface); if (!matches) { return true; } } return false; }
From source file:de.fkoeberle.autocommit.message.java.helper.ASTCompareUtil.java
License:Open Source License
/** * //from w ww . j av a2s . com * @param oldNode * can be null. * @param newNode * can be null. * @return false if and only if the nodes match when compared with a * {@link ASTMatcher}. Otherwise true gets returned */ public static boolean astNodesDiffer(ASTNode oldNode, ASTNode newNode) { if (oldNode == null || newNode == null) { return oldNode != newNode; } boolean sameReturnType = (oldNode.subtreeMatch(new ASTMatcher(true), newNode)); return !sameReturnType; }
From source file:de.fkoeberle.autocommit.message.java.helper.delta.DeclarationDelta.java
License:Open Source License
/** * // w ww . j a v a2 s . c o m * @return true if the javadoc element of this declaration has been changed * and false otherwise. Ignores javadoc on child elements. */ private final boolean containsJavaDocChanges() { Javadoc oldJavaDoc = oldDeclaration.getJavadoc(); Javadoc newJavaDoc = newDeclaration.getJavadoc(); if (oldJavaDoc == null || newJavaDoc == null) { return (oldJavaDoc != newJavaDoc); } else { return (!oldJavaDoc.subtreeMatch(new ASTMatcher(true), newJavaDoc)); } }
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 w w. j a va 2 s . com 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()); }
From source file:de.fkoeberle.autocommit.message.java.helper.delta.FieldDelta.java
License:Open Source License
private boolean containsTypeChange() { Type oldType = oldDeclaration.getType(); Type newType = newDeclaration.getType(); boolean sameType = oldType.subtreeMatch(new ASTMatcher(true), newType); return !sameType; }
From source file:de.fkoeberle.autocommit.message.java.helper.JavaFormatationChecker.java
License:Open Source License
/** * Checks for a given file if there are only whitespace changes. * /*from w w w . j av a2 s . co m*/ * @param changedFile * the file to check. * @return true if it can be guaranteed that there were only formation * changes and false otherwise. * @throws IOException */ public boolean foundJavaFormatationChangesOnly(JavaFileDelta javaFileDelta) throws IOException { Map<JavaFileDelta, Boolean> map = getCachableValue(); Boolean result = map.get(javaFileDelta); if (result == null) { CompilationUnit oldContent = javaFileDelta.getOldDeclaration(); CompilationUnit newContent = javaFileDelta.getNewDeclaration(); if (containsProblems(oldContent)) { return false; } if (containsProblems(newContent)) { return false; } boolean match = oldContent.subtreeMatch(new ASTMatcher(true), newContent); result = Boolean.valueOf(match); map.put(javaFileDelta, result); } return result.booleanValue(); }