List of usage examples for org.eclipse.jdt.core.dom CompilationUnit subtreeMatch
public final boolean subtreeMatch(ASTMatcher matcher, Object other)
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 www . ja va 2 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(); }
From source file:org.whole.lang.java.JavaImportExportTests.java
License:Open Source License
@SuppressWarnings("unchecked") private boolean performTest(String source) throws Exception { CompilationUnit cu = JDTUtils.parseAsCompilationUnit(source); IEntity model = JDTTransformerVisitor.transform(source, cu); String newSource = PrettyPrinterOperation.toPrettyPrintString(model); CompilationUnit cuReparsed = JDTUtils.parseAsCompilationUnit(newSource); for (Comment element : (List<Comment>) cu.getCommentList()) element.delete();//w ww. ja v a2 s.c o m boolean subtreeMatch = cu.subtreeMatch(new SemanticASTMatcher(), cuReparsed); return subtreeMatch; }