Skip to content

Commit

Permalink
fix(): fix NPE
Browse files Browse the repository at this point in the history
  • Loading branch information
Leibnizhu committed Jun 24, 2020
1 parent c4570ec commit a7616b7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import com.google.auto.service.AutoService;
import com.sun.tools.javac.api.JavacTrees;
import com.sun.tools.javac.processing.JavacProcessingEnvironment;
import com.sun.tools.javac.tree.JCTree;
import com.sun.tools.javac.tree.TreeMaker;
import com.sun.tools.javac.util.Context;
import com.sun.tools.javac.util.Names;
Expand Down Expand Up @@ -38,7 +39,12 @@ public synchronized void init(ProcessingEnvironment processingEnv) {
@Override
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
MethodOverloadTranslator visitor = new MethodOverloadTranslator(treeMaker, messager, names);
roundEnv.getRootElements().forEach(element -> trees.getTree(element).accept(visitor));
roundEnv.getRootElements().forEach(element -> {
JCTree tree = trees.getTree(element);
if (tree != null) {
tree.accept(visitor);
}
});
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public MethodOverloadTranslator(TreeMaker treeMaker, Messager messager, Names na
*/
@Override
public void visitClassDef(JCTree.JCClassDecl jcClass) {
String classFullName = jcClass.sym.fullname.toString();
String classFullName = Optional.ofNullable(jcClass.sym).map(s -> s.fullname).map(Object::toString).orElse("");
Queue<JCTree.JCMethodDecl> newMethods = new LinkedList<>();
Map<String, Set<String>> methodSignMap = new HashMap<>(); //Map<MethodName, Set<ParameterTypeList>>
jcClass.defs.stream()
Expand Down

0 comments on commit a7616b7

Please sign in to comment.