ResourceProcessor(ProcessingEnvironment processingEnv, ErrorLogger errorLogger, Elements elementUtils, Types typeUtils) { this.errorLogger = errorLogger; this.elementUtils = elementUtils; this.typeUtils = typeUtils; try { trees = Trees.instance(processingEnv); } catch (IllegalArgumentException ignored) { } }
@Override public Void visitEndElement(EndElementTree endElementTree, Void aVoid) { return super.visitEndElement(endElementTree, aVoid); }
@Override public void started(TaskEvent e) { for (TaskListener listener : listeners) listener.started(e); } }
private static boolean isEnhancedForLoopVar(TreePath variablePath) { Tree tree = variablePath.getLeaf(); Tree parent = variablePath.getParentPath().getLeaf(); return parent instanceof EnhancedForLoopTree && ((EnhancedForLoopTree) parent).getVariable() == tree; }
/** * Gets a {@link DiagnosticPosition} for the {@link DocTree} pointed to by {@code path}, attached * to the {@link Tree} which it documents. */ static DiagnosticPosition diagnosticPosition(DocTreePath path, VisitorState state) { int startPosition = getStartPosition(path.getLeaf(), state); Tree tree = path.getTreePath().getLeaf(); return getDiagnosticPosition(startPosition, tree); }
/** Scan a tree from a position identified by a TreePath. */ @Override public Void scan(TreePath path, VisitorState state) { SuppressionInfo prevSuppressionInfo = updateSuppressions(path.getLeaf(), state); try { return super.scan(path, state); } finally { // Restore old suppression state. currentSuppressions = prevSuppressionInfo; } }
SourcePositions getSourcePositions() { return treeUtils.getSourcePositions(); }
@Override public Void visitClass(ClassTree classTree, Void unused) { if (isSuppressed(classTree)) { suppressions++; super.visitClass(classTree, null); suppressions--; } else { super.visitClass(classTree, null); } return null; }
@Override public Boolean scan(Tree tree, Boolean matchFound) { if (matchFound) { return true; } if (matcher.matches(tree, state)) { return true; } return super.scan(tree, false); }
@Override public Void visitMethod(MethodTree tree, Void unused) { // Ignore synthetic constructors: if (ASTHelpers.isGeneratedConstructor(tree)) { return null; } return super.visitMethod(tree, null); }
@Override public void finished(TaskEvent e) { if (e.getKind() == Kind.COMPILATION) { AnnotationUtils.clear(); } } }
@Override public Void visitClass(ClassTree classTree, VisitorState visitorState) { boolean priorInShadowClass = inShadowClass; inShadowClass = hasAnnotation(classTree, Implements.class, visitorState); try { return super.visitClass(classTree, visitorState); } finally { inShadowClass = priorInShadowClass; } }
@Override public Void visitMemberSelect(MemberSelectTree tree, HeldLockSet locks) { checkMatch(tree, locks); return super.visitMemberSelect(tree, locks); }
@Override public void finished(TaskEvent e) { for (TaskListener listener : listeners) listener.finished(e); }
@Override public Void visitIdentifier(IdentifierTree tree, HeldLockSet locks) { checkMatch(tree, locks); return super.visitIdentifier(tree, locks); }
@Override public Void visitIdentifier(IdentifierTree node, Void v) { if (((JCIdent) node).sym instanceof VarSymbol) { freeVars.add(node); } return super.visitIdentifier(node, v); } }.scan(tree, null);
@Override public Void visitLiteral(LiteralTree tree, Scope scope) { replaceLiteral(tree, scope, state); return super.visitLiteral(tree, scope); }
@Override public T scan(DocTree docTree, Void unused) { if (clazz.isInstance(docTree)) { return clazz.cast(docTree); } return super.scan(docTree, null); } }.scan(docTreePath.getLeaf(), null);
@Override public Void visitInstanceOf(InstanceOfTree tree, ExpressionTree expr) { if (expressionsEqual(tree.getExpression(), expr)) { relevantTree = tree; } return super.visitInstanceOf(tree, expr); }
@Override public Void visitText(TextTree textTree, Void aVoid) { System.out.println("textTree = " + textTree); return super.visitText(textTree, aVoid); }