Class DogLogRewriter
- All Implemented Interfaces:
com.github.javaparser.ast.visitor.GenericVisitor<com.github.javaparser.ast.visitor.Visitable,Void>
DogLogRewriter | Actual functionality
The actual class that performs the AST parsing and replacement of SmartDashboard calls with DogLog calls, invoked by the Main class.
Extends ModifierVisitor to "visit" and modify the calls.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidapplyReplacement(com.github.javaparser.ast.CompilationUnit parsed) Applies the replacementcom.github.javaparser.ast.expr.MethodCallExprVisit MethodMethods inherited from class com.github.javaparser.ast.visitor.ModifierVisitor
visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit, visit
-
Constructor Details
-
DogLogRewriter
public DogLogRewriter()
-
-
Method Details
-
visit
public com.github.javaparser.ast.expr.MethodCallExpr visit(com.github.javaparser.ast.expr.MethodCallExpr methodCall, Void arg) Visit Method
Overrides the
visit(com.github.javaparser.ast.expr.MethodCallExpr,java.lang.Void)method for method calls.It loops through every
MethodCallExprto check for aSmartDashboardcall with the methodsputNumber,putBoolean, orputString. If so, it replaces the scope withDogLogand changes the method name tolog.Sets variable
fileChangedto check if any changes were made to the file to determine whether to importDogLogat the end of the file.- Specified by:
visitin interfacecom.github.javaparser.ast.visitor.GenericVisitor<com.github.javaparser.ast.visitor.Visitable,Void> - Overrides:
visitin classcom.github.javaparser.ast.visitor.ModifierVisitor<Void>- Parameters:
methodCall- the method call expression being visitedarg- additional argument (not used in this case)- Returns:
- the modified method call expression
-
applyReplacement
public static void applyReplacement(com.github.javaparser.ast.CompilationUnit parsed) Applies the replacement
Applies the
SmartDashboardtoDogLogreplacement to the givenCompilationUnit.If the
fileChangedflag is true, it checks if the files already has an import forDogLog. If not, it adds the import statement. If the flag is false, it does nothing to avoid unnecessary changes and imports.- Parameters:
parsed- theCompilationUnitto process
-