Skip to content

Commit

Permalink
VisitorState: add getElements() method, and use instead of getTreeMak…
Browse files Browse the repository at this point in the history
…er().Literal(...)

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=260932977
  • Loading branch information
awturner authored and netdpb committed Aug 13, 2019
1 parent 97d9c13 commit ce095ff
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import com.sun.tools.javac.code.Type.ClassType;
import com.sun.tools.javac.code.Types;
import com.sun.tools.javac.comp.Modules;
import com.sun.tools.javac.model.JavacElements;
import com.sun.tools.javac.parser.Tokens.Token;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.JCTree.JCCompilationUnit;
Expand All @@ -56,6 +57,7 @@
import java.util.List;
import java.util.Map;
import javax.annotation.Nullable;
import javax.lang.model.util.Elements;

/** @author alexeagle@google.com (Alex Eagle) */
public class VisitorState {
Expand Down Expand Up @@ -260,6 +262,10 @@ public Types getTypes() {
return sharedState.types;
}

public Elements getElements() {
return JavacElements.instance(context);
}

public Symtab getSymtab() {
return sharedState.symtab;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public Description matchMethodInvocation(MethodInvocationTree tree, final Visito
for (String r : replacement.replacements) {
builder.addFix(
SuggestedFix.replace(
tree.getArguments().get(0), state.getTreeMaker().Literal(r).toString()));
tree.getArguments().get(0), state.getElements().getConstantExpression(r)));
}
return builder.build();
}
Expand Down

0 comments on commit ce095ff

Please sign in to comment.