-
Notifications
You must be signed in to change notification settings - Fork 29
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement a new design based on a Java compiler plugin that generates SemanticDB #85
Conversation
The next commits add a new implementation.
private static String bytesToHex(byte[] bytes) { | ||
char[] hexChars = new char[bytes.length * 2]; | ||
int j = 0; | ||
while (j < bytes.length) { | ||
int v = bytes[j] & 0xFF; | ||
hexChars[j * 2] = HEX_ARRAY[v >>> 4]; | ||
hexChars[j * 2 + 1] = HEX_ARRAY[v & 0x0F]; | ||
j += 1; | ||
} | ||
return new String(hexChars); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this could be replaced with javax.xml.bind.DataTypeConverter.printHexBinary but no big deal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IntelliJ says this class exists in rt.jar
but I can't find it in my Java home
❯ jar tf jre/lib/rt.jar | grep javax.xml.bind.DataTypeConverter
<empty>
❯ javap -cp jre/lib/rt.jar javax.xml.bind.DataTypeConverter
Error: class not found: javax.xml.bind.DataTypeConverter
❯ javap -cp lib/tools.jar javax.xml.bind.DataTypeConverter
Error: class not found: javax.xml.bind.DataTypeConverter
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nothing obvious stands out, LGTM good stuff 👍
This PR removes most of the contents from the original repo and introduces a new architecture for lsif-java.
In a nutshell, the new implementation includes a Java compiler plugin that generates one SemanticDB file for every
*.java
source file. After compilation completes, the SemanticDB files are processed to produce LSIF.The updated readme includes more details about the benefits of this new design.
You can try out the new precise code intelligence from the link below. Observe that navigating to a method name
app()
goes to the precise implementation even if there are many classes that implement methods with the same nameapp()
.https://sourcegraph.com/github.com/sourcegraph/lsif-java@3cab1b8/-/blob/tests/minimized/src/main/java/minimized/MinimizedJavaMain.java#L13
There are still several known bugs like the incorrect highlighting in this "Find references" request
The combined diff in this PR is large, but the Java compiler plugin implementation is only 745 lines of code if you exclude the generated protobuf definitions. The bulk of the diff comes from the new "snapshot testing" infrastructure to index a corpus of the https://github.com/airbnb/epoxy library.