JavaCompletions
JavaCompletions copied to clipboard
NullPointerException when trying to get completions
I'm unable to use this library in my project.
Whenever I try to run the sample project, it just throws an NPE saying treePath is null, I tried searching for the cause of this issue but it refers to AutoValue_PositionContext.java which is auto-generated by the AutoValue annotations library. Here's the code I'm currently using
JavaCompletions completions = new JavaCompletions();
completions.initialize(new File(/* Path to the directory containing the sample java files */).toURI(), new JavaCompletionOptionsImpl(getBinDir() + "log.txt", Level.ALL, null, null));
// As a sample test
CompletionResult result = completions.getProject()
.getCompletionResult(new File(currentPathOfFile).toPath(), 8 /** line **/, 13 /** column **/);
String s = "";
for(CompletionCandidate candidate : result.getCompletionCandidates()) {
s += candidate.getName();
s += "\n";
}
/* Do something with the completion list later on */
Note: I modified the library to use com.sun.* and javax.tools.* packages instead of org.openjdk.* and org.openjdk.javax.* packages by mass search and replace

the NPE was caused my the modification of the packages, please try using the ones that is packaged in the library because thats the one that is tested.