-
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
Add signature pretty-printer to lsif-semanticdb conversion process #131
Conversation
0401ab9
to
ed1e6ed
Compare
ed1e6ed
to
f170c72
Compare
c7586de
to
4fc0ce9
Compare
4a2808f
to
2a08071
Compare
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.
This is outstanding work! It will be a big milestone when lsif-java supports proper hover messages.
A few comments, mostly minor. The only blocking comments are
- print class name instead of
<init>
- why are there so many
unresolved_type
in the snapshots?
lsif-java/src/main/scala/com/sourcegraph/lsif_java/SemanticdbPrinters.scala
Outdated
Show resolved
Hide resolved
lsif-java/src/main/scala/com/sourcegraph/lsif_java/SemanticdbPrinters.scala
Outdated
Show resolved
Hide resolved
lsif-java/src/main/scala/com/sourcegraph/lsif_java/SemanticdbPrinters.scala
Outdated
Show resolved
Hide resolved
lsif-java/src/main/scala/com/sourcegraph/lsif_java/commands/SnapshotLsifCommand.scala
Outdated
Show resolved
Hide resolved
// we cheese it a bit here, as this is less work than trying to reconstruct | ||
// a Signature from the pretty-printed Signature, with accompanying logic | ||
// to fallback to display_name in SemanticdbPrinters.scala | ||
.setDisplayName(hover).setSymbol(symbol).build() |
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.
Can we use Documentation
instead?
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.
we (currently) dont emit Documentation in the snapshots, only the Signature with DisplayName as fallback.
This should probably still not use Documentation even if we did, if we decide to go ahead with the original "musing" of formatting documentation in a fashion similar to Lorem ipsum ... facilisis, in convallis ex imperdiet.
, truncating for brevity
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 see, the android.view.View
class is indeed missing from the classpath that we're using in the snapshots
❯ javap -cp $(cs fetch -r https://maven.google.com/ 'com.airbnb.android:epoxy:4.3.1' -p) android.view.View
Error: class not found: android.view.View
The class is defined in android.jar
from the SDK
❯ javap -cp $ANDROID_HOME/platforms/android-30/android.jar android.view.View | head
Compiled from "View.java"
public class android.view.View implements android.graphics.drawable.Drawable$Callback,android.view.KeyEvent$Callback,android.view.accessibility.AccessibilityEventSource {
public static final int ACCESSIBILITY_LIVE_REGION_ASSERTIVE;
public static final int ACCESSIBILITY_LIVE_REGION_NONE;
public static final int ACCESSIBILITY_LIVE_REGION_POLITE;
public static final android.util.Property<android.view.View, java.lang.Float> ALPHA;
public static final int AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE;
public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY;
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.
Its weird because many other android types do resolve. 🤷
lsif-semanticdb/src/main/java/com/sourcegraph/lsif_semanticdb/SignatureFormatter.java
Outdated
Show resolved
Hide resolved
lsif-semanticdb/src/main/java/com/sourcegraph/lsif_semanticdb/SignatureFormatter.java
Outdated
Show resolved
Hide resolved
tests/snapshots/src/main/generated/com/airbnb/epoxy/AsyncEpoxyController.java
Outdated
Show resolved
Hide resolved
// ^^^^^^^^ reference androidx/annotation/Nullable# | ||
// ^^^^ reference java/util/List# | ||
// ^^^^^^^^^^ reference com/airbnb/epoxy/EpoxyModel# | ||
// ^^^^^^ definition local0 | ||
// ^^^^^^ definition local0 List<? extends EpoxyModel<?>> models |
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.
👏 🤩
} | ||
|
||
/** | ||
* A Handler class that uses the main thread's Looper. | ||
*/ | ||
public static final Handler MAIN_THREAD_HANDLER = | ||
// ^^^^^^^ reference _root_/ | ||
// ^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyAsyncUtil#MAIN_THREAD_HANDLER. | ||
// ^^^^^^^^^^^^^^^^^^^ definition com/airbnb/epoxy/EpoxyAsyncUtil#MAIN_THREAD_HANDLER. public static final unresolved_type MAIN_THREAD_HANDLER |
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.
Why do we have unresolved_type
here?
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.
A lot of android types dont seem to resolve for some reason. You can see that above where the field type is _root_/
instead of the android/os/Handler#
that it should be
38188cb
to
6ad078d
Compare
There seems to be some issue with types from the android sdk occasionally (and Im not sure why only occasionally) where they dont resolved. This is always accompanied with the reference occurrence being given the symbol |
6ad078d
to
7da5641
Compare
7da5641
to
a285b29
Compare
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.
LGTM 👍 Feel free to merge once you think this is ready to go.
// we cheese it a bit here, as this is less work than trying to reconstruct | ||
// a Signature from the pretty-printed Signature, with accompanying logic | ||
// to fallback to display_name in SemanticdbPrinters.scala | ||
.setDisplayName(hover).setSymbol(symbol).build() |
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 see, the android.view.View
class is indeed missing from the classpath that we're using in the snapshots
❯ javap -cp $(cs fetch -r https://maven.google.com/ 'com.airbnb.android:epoxy:4.3.1' -p) android.view.View
Error: class not found: android.view.View
The class is defined in android.jar
from the SDK
❯ javap -cp $ANDROID_HOME/platforms/android-30/android.jar android.view.View | head
Compiled from "View.java"
public class android.view.View implements android.graphics.drawable.Drawable$Callback,android.view.KeyEvent$Callback,android.view.accessibility.AccessibilityEventSource {
public static final int ACCESSIBILITY_LIVE_REGION_ASSERTIVE;
public static final int ACCESSIBILITY_LIVE_REGION_NONE;
public static final int ACCESSIBILITY_LIVE_REGION_POLITE;
public static final android.util.Property<android.view.View, java.lang.Float> ALPHA;
public static final int AUTOFILL_FLAG_INCLUDE_NOT_IMPORTANT_VIEWS;
public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DATE;
public static final java.lang.String AUTOFILL_HINT_CREDIT_CARD_EXPIRATION_DAY;
String documentation = symbolInformation.getDocumentation().getMessage(); | ||
if (!documentation.isEmpty()) { | ||
int hoverId = writer.emitHoverResult(doc.semanticdb.getLanguage(), documentation); | ||
markedStrings.add(new MarkedString(Semanticdb.Language.UNKNOWN_LANGUAGE, documentation)); |
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.
What do you think about adding a new Documentation.Format
called SIGNATURE
? We can then make the Documentation documentation = 20;
field repeated (which is a binary backwards compatible change). Do you think that would make this cleaner?
PR adds support for generating a pretty-printed hover text from the emitted SemanticDB Signature and SymbolInformation types.
This happens at the SemanticDB to LSIF stage and is included in the hover results lists for a range, alongside the doc string if it exists.
TODO (either in this PR or a follow-up):
annotation interfacespretty-print enums properlyimplements vs extendsskipabstract
in interface + interface methodsconstructorsthis
keyword references field namedthis
that doesn't exist