Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Helper class for writing Lint Checks for Android
/*
* Copyright 2016 Realm Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.realm.lint.util;
import lombok.ast.AlternateConstructorInvocation;
import lombok.ast.Annotation;
import lombok.ast.AnnotationDeclaration;
import lombok.ast.AnnotationElement;
import lombok.ast.AnnotationMethodDeclaration;
import lombok.ast.AnnotationValueArray;
import lombok.ast.ArrayAccess;
import lombok.ast.ArrayCreation;
import lombok.ast.ArrayDimension;
import lombok.ast.ArrayInitializer;
import lombok.ast.Assert;
import lombok.ast.AstVisitor;
import lombok.ast.BinaryExpression;
import lombok.ast.Block;
import lombok.ast.BooleanLiteral;
import lombok.ast.Break;
import lombok.ast.Case;
import lombok.ast.Cast;
import lombok.ast.Catch;
import lombok.ast.CharLiteral;
import lombok.ast.ClassDeclaration;
import lombok.ast.ClassLiteral;
import lombok.ast.Comment;
import lombok.ast.CompilationUnit;
import lombok.ast.ConstructorDeclaration;
import lombok.ast.ConstructorInvocation;
import lombok.ast.Continue;
import lombok.ast.Default;
import lombok.ast.DoWhile;
import lombok.ast.EmptyDeclaration;
import lombok.ast.EmptyStatement;
import lombok.ast.EnumConstant;
import lombok.ast.EnumDeclaration;
import lombok.ast.EnumTypeBody;
import lombok.ast.ExpressionStatement;
import lombok.ast.FloatingPointLiteral;
import lombok.ast.For;
import lombok.ast.ForEach;
import lombok.ast.Identifier;
import lombok.ast.If;
import lombok.ast.ImportDeclaration;
import lombok.ast.InlineIfExpression;
import lombok.ast.InstanceInitializer;
import lombok.ast.InstanceOf;
import lombok.ast.IntegralLiteral;
import lombok.ast.InterfaceDeclaration;
import lombok.ast.KeywordModifier;
import lombok.ast.LabelledStatement;
import lombok.ast.MethodDeclaration;
import lombok.ast.MethodInvocation;
import lombok.ast.Modifiers;
import lombok.ast.Node;
import lombok.ast.NormalTypeBody;
import lombok.ast.NullLiteral;
import lombok.ast.PackageDeclaration;
import lombok.ast.Return;
import lombok.ast.Select;
import lombok.ast.StaticInitializer;
import lombok.ast.StringLiteral;
import lombok.ast.Super;
import lombok.ast.SuperConstructorInvocation;
import lombok.ast.Switch;
import lombok.ast.Synchronized;
import lombok.ast.This;
import lombok.ast.Throw;
import lombok.ast.Try;
import lombok.ast.TypeReference;
import lombok.ast.TypeReferencePart;
import lombok.ast.TypeVariable;
import lombok.ast.UnaryExpression;
import lombok.ast.VariableDeclaration;
import lombok.ast.VariableDefinition;
import lombok.ast.VariableDefinitionEntry;
import lombok.ast.VariableReference;
import lombok.ast.While;
/**
* Util class for developing detectors. It will output all methods called when the
* AstVisitor is applied to a {@link
* Node}.
*/
public class LoggingAstVisitor extends AstVisitor {
public LoggingAstVisitor() {
}
public boolean visitNode(Node node) {
return false;
}
public void endVisit(Node node) {
}
public boolean visitTypeReference(TypeReference node) {
System.out.println("visitTypeReference: " + node.toString());
return this.visitNode(node);
}
public boolean visitTypeReferencePart(TypeReferencePart node) {
System.out.println("visitTypeReferencePart: " + node.toString());
return this.visitNode(node);
}
public boolean visitVariableReference(VariableReference node) {
System.out.println("visitVariableReference: " + node.toString());
return this.visitNode(node);
}
public boolean visitIdentifier(Identifier node) {
System.out.println("visitIdentifier: " + node.toString());
return this.visitNode(node);
}
public boolean visitIntegralLiteral(IntegralLiteral node) {
System.out.println("visitIntegerLiteral: " + node.toString());
return this.visitNode(node);
}
public boolean visitFloatingPointLiteral(FloatingPointLiteral node) {
System.out.println("visitFloatingPointLiteral: " + node.toString());
return this.visitNode(node);
}
public boolean visitBooleanLiteral(BooleanLiteral node) {
System.out.println("visitBooleanLiteral: " + node.toString());
return this.visitNode(node);
}
public boolean visitCharLiteral(CharLiteral node) {
System.out.println("visitCharLiteral: " + node.toString());
return this.visitNode(node);
}
public boolean visitStringLiteral(StringLiteral node) {
System.out.println("visitStringLiteral: " + node.toString());
return this.visitNode(node);
}
public boolean visitNullLiteral(NullLiteral node) {
System.out.println("visitNullLiteral: " + node.toString());
return this.visitNode(node);
}
public boolean visitBinaryExpression(BinaryExpression node) {
System.out.println("visitBinaryExpression: " + node.toString());
return this.visitNode(node);
}
public boolean visitUnaryExpression(UnaryExpression node) {
System.out.println("visitUnaryExpression: " + node.toString());
return this.visitNode(node);
}
public boolean visitInlineIfExpression(InlineIfExpression node) {
System.out.println("visitInlineIfExpression: " + node.toString());
return this.visitNode(node);
}
public boolean visitCast(Cast node) {
System.out.println("visitCast: " + node.toString());
return this.visitNode(node);
}
public boolean visitInstanceOf(InstanceOf node) {
System.out.println("visitInstnanceOf: " + node.toString());
return this.visitNode(node);
}
public boolean visitConstructorInvocation(ConstructorInvocation node) {
System.out.println("visitConstructorInvocation: " + node.toString());
return this.visitNode(node);
}
public boolean visitMethodInvocation(MethodInvocation node) {
System.out.println("visitMethodInvocation: " + node.toString());
return this.visitNode(node);
}
public boolean visitSelect(Select node) {
System.out.println("visitSelect: " + node.toString());
return this.visitNode(node);
}
public boolean visitArrayAccess(ArrayAccess node) {
System.out.println("visitArrayAccess: " + node.toString());
return this.visitNode(node);
}
public boolean visitArrayCreation(ArrayCreation node) {
System.out.println("visitArrayCreation: " + node.toString());
return this.visitNode(node);
}
public boolean visitAnnotationValueArray(AnnotationValueArray node) {
System.out.println("visitAnnotationValueArray: " + node.toString());
return this.visitNode(node);
}
public boolean visitArrayInitializer(ArrayInitializer node) {
System.out.println("visitArrayInitializer: " + node.toString());
return this.visitNode(node);
}
public boolean visitArrayDimension(ArrayDimension node) {
System.out.println("visitArrayDimension: " + node.toString());
return this.visitNode(node);
}
public boolean visitClassLiteral(ClassLiteral node) {
System.out.println("visitClassLiteral: " + node.toString());
return this.visitNode(node);
}
public boolean visitSuper(Super node) {
System.out.println("visitSuper: " + node.toString());
return this.visitNode(node);
}
public boolean visitThis(This node) {
System.out.println("visitThis: " + node.toString());
return this.visitNode(node);
}
public boolean visitLabelledStatement(LabelledStatement node) {
System.out.println("visitLabelledStatement: " + node.toString());
return this.visitNode(node);
}
public boolean visitExpressionStatement(ExpressionStatement node) {
System.out.println("visitExpressionStatement: " + node.toString());
return this.visitNode(node);
}
public boolean visitIf(If node) {
System.out.println("visitIf: " + node.toString());
return this.visitNode(node);
}
public boolean visitFor(For node) {
System.out.println("visitFor: " + node.toString());
return this.visitNode(node);
}
public boolean visitForEach(ForEach node) {
System.out.println(node.toString());
return this.visitNode(node);
}
public boolean visitTry(Try node) {
System.out.println("visitTry: " + node.toString());
return this.visitNode(node);
}
public boolean visitCatch(Catch node) {
System.out.println("visitCatch: " + node.toString());
return this.visitNode(node);
}
public boolean visitWhile(While node) {
System.out.println("visitWhile: " + node.toString());
return this.visitNode(node);
}
public boolean visitDoWhile(DoWhile node) {
System.out.println("visitDoWhile: " + node.toString());
return this.visitNode(node);
}
public boolean visitSynchronized(Synchronized node) {
System.out.println("visitSynchronized: " + node.toString());
return this.visitNode(node);
}
public boolean visitBlock(Block node) {
System.out.println("visitBlock: " + node.toString());
return this.visitNode(node);
}
public boolean visitAssert(Assert node) {
System.out.println("visitAssert: " + node.toString());
return this.visitNode(node);
}
public boolean visitEmptyStatement(EmptyStatement node) {
System.out.println("visitEmptyStatement: " + node.toString());
return this.visitNode(node);
}
public boolean visitSwitch(Switch node) {
System.out.println("visitSwitch: " + node.toString());
return this.visitNode(node);
}
public boolean visitCase(Case node) {
System.out.println("visitCase: " + node.toString());
return this.visitNode(node);
}
public boolean visitDefault(Default node) {
System.out.println("visitDefault: " + node.toString());
return this.visitNode(node);
}
public boolean visitBreak(Break node) {
System.out.println("visitBreak: " + node.toString());
return this.visitNode(node);
}
public boolean visitContinue(Continue node) {
System.out.println("visitContinue: " + node.toString());
return this.visitNode(node);
}
public boolean visitReturn(Return node) {
System.out.println("visitReturn: " + node.toString());
return this.visitNode(node);
}
public boolean visitThrow(Throw node) {
System.out.println("visitThrow: " + node.toString());
return this.visitNode(node);
}
public boolean visitVariableDeclaration(VariableDeclaration node) {
System.out.println("visitVariableDeclaration: " + node.toString());
return this.visitNode(node);
}
public boolean visitVariableDefinition(VariableDefinition node) {
System.out.println("visitVariableDefinition: " + node.toString());
return this.visitNode(node);
}
public boolean visitVariableDefinitionEntry(VariableDefinitionEntry node) {
System.out.println("visitVariableDefinitionEntry: " + node.toString());
return this.visitNode(node);
}
public boolean visitTypeVariable(TypeVariable node) {
System.out.println("visitTypeVariable: " + node.toString());
return this.visitNode(node);
}
public boolean visitKeywordModifier(KeywordModifier node) {
System.out.println("visitKeywordModifier: " + node.toString());
return this.visitNode(node);
}
public boolean visitModifiers(Modifiers node) {
System.out.println("visitModifiers: " + node.toString());
return this.visitNode(node);
}
public boolean visitAnnotation(Annotation node) {
System.out.println("visitAnnotation: " + node.toString());
return this.visitNode(node);
}
public boolean visitAnnotationElement(AnnotationElement node) {
System.out.println("visitAnnotationElement: " + node.toString());
return this.visitNode(node);
}
public boolean visitNormalTypeBody(NormalTypeBody node) {
System.out.println("visitNormalTypeBody: " + node.toString());
return this.visitNode(node);
}
public boolean visitEnumTypeBody(EnumTypeBody node) {
System.out.println("visitEnumTypeBody: " + node.toString());
return this.visitNode(node);
}
public boolean visitEmptyDeclaration(EmptyDeclaration node) {
System.out.println("visitEmptyDeclaration: " + node.toString());
return this.visitNode(node);
}
public boolean visitMethodDeclaration(MethodDeclaration node) {
System.out.println("vistiMethodDeclaration: " + node.toString());
return this.visitNode(node);
}
public boolean visitConstructorDeclaration(ConstructorDeclaration node) {
System.out.println("visitConstructorDeclaration: " + node.toString());
return this.visitNode(node);
}
public boolean visitSuperConstructorInvocation(SuperConstructorInvocation node) {
System.out.println("visitSuperConstructorInvocation: " + node.toString());
return this.visitNode(node);
}
public boolean visitAlternateConstructorInvocation(AlternateConstructorInvocation node) {
System.out.println("visitAlternateConstructorInvocation: " + node.toString());
return this.visitNode(node);
}
public boolean visitInstanceInitializer(InstanceInitializer node) {
System.out.println("visitInstanceInitializer: " + node.toString());
return this.visitNode(node);
}
public boolean visitStaticInitializer(StaticInitializer node) {
System.out.println("visitStaticInitializer: " + node.toString());
return this.visitNode(node);
}
public boolean visitClassDeclaration(ClassDeclaration node) {
System.out.println("visitClassDeclaration: " + node.toString());
return this.visitNode(node);
}
public boolean visitInterfaceDeclaration(InterfaceDeclaration node) {
System.out.println("visitInterfaceDeclaration: " + node.toString());
return this.visitNode(node);
}
public boolean visitEnumDeclaration(EnumDeclaration node) {
System.out.println("visitEnumDeclaration: " + node.toString());
return this.visitNode(node);
}
public boolean visitEnumConstant(EnumConstant node) {
System.out.println("visitEnumConstant: " + node.toString());
return this.visitNode(node);
}
public boolean visitAnnotationDeclaration(AnnotationDeclaration node) {
System.out.println("visitAnnotationDeclaration: " + node.toString());
return this.visitNode(node);
}
public boolean visitAnnotationMethodDeclaration(AnnotationMethodDeclaration node) {
System.out.println("visitAnnotationMethodDeclaration: " + node.toString());
return this.visitNode(node);
}
public boolean visitCompilationUnit(CompilationUnit node) {
System.out.println("visitCompilationUnit" + node.toString());
return this.visitNode(node);
}
public boolean visitPackageDeclaration(PackageDeclaration node) {
System.out.println("visitPackageDeclaration" + node.toString());
return this.visitNode(node);
}
public boolean visitImportDeclaration(ImportDeclaration node) {
System.out.println("visitImportDeclaration" + node.toString());
return this.visitNode(node);
}
public boolean visitParseArtefact(Node node) {
System.out.println("visitParseArtefact" + node.toString());
return this.visitNode(node);
}
public boolean visitComment(Comment node) {
System.out.println("visitComment" + node.toString());
return this.visitNode(node);
}
public void afterVisitTypeReference(TypeReference node) {
System.out.println("afterVisitTypeReference: " + node.toString());
}
public void afterVisitTypeReferencePart(TypeReferencePart node) {
System.out.println("afterVisitTypeReferencePart: " + node.toString());
}
public void afterVisitVariableReference(VariableReference node) {
System.out.println("afterVisitVariableReference: " + node.toString());
}
public void afterVisitIdentifier(Identifier node) {
System.out.println("afterVisitIdentifier: " + node.toString());
}
public void afterVisitIntegralLiteral(IntegralLiteral node) {
System.out.println("afterVisitIntegralLiteral: " + node.toString());
}
public void afterVisitFloatingPointLiteral(FloatingPointLiteral node) {
System.out.println("afterVisitFloatingPointLiteral: " + node.toString());
}
public void afterVisitBooleanLiteral(BooleanLiteral node) {
System.out.println("afterVisitBooleanLiteral: " + node.toString());
}
public void afterVisitCharLiteral(CharLiteral node) {
System.out.println("afterVisitCharLiteral: " + node.toString());
}
public void afterVisitStringLiteral(StringLiteral node) {
}
public void afterVisitNullLiteral(NullLiteral node) {
}
public void afterVisitBinaryExpression(BinaryExpression node) {
}
public void afterVisitUnaryExpression(UnaryExpression node) {
}
public void afterVisitInlineIfExpression(InlineIfExpression node) {
}
public void afterVisitCast(Cast node) {
}
public void afterVisitInstanceOf(InstanceOf node) {
}
public void afterVisitConstructorInvocation(ConstructorInvocation node) {
}
public void afterVisitMethodInvocation(MethodInvocation node) {
}
public void afterVisitSelect(Select node) {
}
public void afterVisitArrayAccess(ArrayAccess node) {
}
public void afterVisitArrayCreation(ArrayCreation node) {
}
public void afterVisitAnnotationValueArray(AnnotationValueArray node) {
}
public void afterVisitArrayInitializer(ArrayInitializer node) {
}
public void afterVisitArrayDimension(ArrayDimension node) {
}
public void afterVisitClassLiteral(ClassLiteral node) {
}
public void afterVisitSuper(Super node) {
}
public void afterVisitThis(This node) {
}
public void afterVisitLabelledStatement(LabelledStatement node) {
}
public void afterVisitExpressionStatement(ExpressionStatement node) {
}
public void afterVisitIf(If node) {
}
public void afterVisitFor(For node) {
}
public void afterVisitForEach(ForEach node) {
}
public void afterVisitTry(Try node) {
}
public void afterVisitCatch(Catch node) {
}
public void afterVisitWhile(While node) {
}
public void afterVisitDoWhile(DoWhile node) {
}
public void afterVisitSynchronized(Synchronized node) {
}
public void afterVisitBlock(Block node) {
}
public void afterVisitAssert(Assert node) {
}
public void afterVisitEmptyStatement(EmptyStatement node) {
}
public void afterVisitSwitch(Switch node) {
}
public void afterVisitCase(Case node) {
}
public void afterVisitDefault(Default node) {
}
public void afterVisitBreak(Break node) {
}
public void afterVisitContinue(Continue node) {
}
public void afterVisitReturn(Return node) {
}
public void afterVisitThrow(Throw node) {
}
public void afterVisitVariableDeclaration(VariableDeclaration node) {
}
public void afterVisitVariableDefinition(VariableDefinition node) {
}
public void afterVisitVariableDefinitionEntry(VariableDefinitionEntry node) {
}
public void afterVisitTypeVariable(TypeVariable node) {
}
public void afterVisitKeywordModifier(KeywordModifier node) {
}
public void afterVisitModifiers(Modifiers node) {
}
public void afterVisitAnnotation(Annotation node) {
}
public void afterVisitAnnotationElement(AnnotationElement node) {
}
public void afterVisitNormalTypeBody(NormalTypeBody node) {
}
public void afterVisitEnumTypeBody(EnumTypeBody node) {
}
public void afterVisitEmptyDeclaration(EmptyDeclaration node) {
}
public void afterVisitMethodDeclaration(MethodDeclaration node) {
}
public void afterVisitConstructorDeclaration(ConstructorDeclaration node) {
}
public void afterVisitSuperConstructorInvocation(SuperConstructorInvocation node) {
}
public void afterVisitAlternateConstructorInvocation(AlternateConstructorInvocation node) {
}
public void afterVisitInstanceInitializer(InstanceInitializer node) {
}
public void afterVisitStaticInitializer(StaticInitializer node) {
}
public void afterVisitClassDeclaration(ClassDeclaration node) {
}
public void afterVisitInterfaceDeclaration(InterfaceDeclaration node) {
}
public void afterVisitEnumDeclaration(EnumDeclaration node) {
}
public void afterVisitEnumConstant(EnumConstant node) {
}
public void afterVisitAnnotationDeclaration(AnnotationDeclaration node) {
}
public void afterVisitAnnotationMethodDeclaration(AnnotationMethodDeclaration node) {
}
public void afterVisitCompilationUnit(CompilationUnit node) {
}
public void afterVisitPackageDeclaration(PackageDeclaration node) {
}
public void afterVisitImportDeclaration(ImportDeclaration node) {
}
public void afterVisitParseArtefact(Node node) {
}
public void afterVisitComment(Comment node) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.