/** * Returns the javac tree representing the source file. * @return {@link CompilationUnitTree} the compilation unit containing the top level classes contained in the, * java source file. * @throws java.lang.IllegalStateException when the phase is less than {@link JavaSource.Phase#PARSED} */ public CompilationUnitTree getCompilationUnit() { checkConfinement(); return this.impl.getCompilationUnit(); }
final CompilationUnitTree cu = ci.getCompilationUnit(); if (cu == null || newBody == null) { return false;
/** * Returns tree which was reparsed by an incremental reparse. * When the source file wasn't parsed yet or the parse was a full parse * this method returns null. * <p class="nonnormative"> * Currently the leaf tree is a MethodTree but this may change in the future. * Client of this method is responsible to check the corresponding TreeKind * to find out if it may perform on the changed subtree or it needs to * reprocess the whole tree. * </p> * @return {@link TreePath} or null * @since 0.31 */ public @CheckForNull @CheckReturnValue TreePath getChangedTree () { checkConfinement(); if (JavaSource.Phase.PARSED.compareTo (impl.getPhase())>0) { return null; } final Pair<DocPositionRegion,MethodTree> changedTree = impl.getChangedTree(); if (changedTree == null) { return null; } final CompilationUnitTree cu = impl.getCompilationUnit(); if (cu == null) { return null; } return TreePath.getPath(cu, changedTree.second()); }