Skip to content
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

Merged
merged 6 commits into from
Feb 11, 2021

Conversation

olafurpg
Copy link
Member

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.

semanticdb-javac-pipeline(1)

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 name app().

https://sourcegraph.com/github.com/sourcegraph/lsif-java@3cab1b8/-/blob/tests/minimized/src/main/java/minimized/MinimizedJavaMain.java#L13

Screenshot 2021-02-11 at 12 28 16

There are still several known bugs like the incorrect highlighting in this "Find references" request

Screenshot 2021-02-11 at 12 29 59

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.

@olafurpg olafurpg changed the title Remove old implementation of lsif-java. Implement a new design based on Java compiler plugins and SemanticDB Feb 11, 2021
@olafurpg olafurpg changed the title Implement a new design based on Java compiler plugins and SemanticDB Implement a new design based on a Java compiler plugin that generates SemanticDB Feb 11, 2021
Comment on lines +16 to +26
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);
}
Copy link
Contributor

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

Copy link
Member Author

@olafurpg olafurpg Feb 11, 2021

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

Screenshot 2021-02-11 at 14 10 11

❯ 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

Copy link
Contributor

@Strum355 Strum355 left a 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 :shipit: good stuff 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants