-
Notifications
You must be signed in to change notification settings - Fork 66
Add symbol tags as proposed for LSP specification (e.g. visibility tags, static, abstract, etc.) #977 #1149
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
base: main
Are you sure you want to change the base?
Conversation
|
This would be great it the LSP gets improved and a new version in released. |
|
Hi @travkin79, just checking in - are you planning to finish this PR? It would be much appreciated if you could! 😊 |
|
Hi @sebthom, The reason for the delay is that the LSP PR requires (in best case) a client implementation and a language server implementation. We planned to implement it for CDT LSP, LSP4E and clangd, but the person implementing the required changes on clangd side stopped working on her/his PR. But in the meanwhile, we found someone else who will finish the work. So, I hope to finish the related PRs, including this one, some time soon. |
645d293 to
ea5b00a
Compare
|
Hi @jonahgraham, @sebthom, and @rubenporras, Type changes in LSP4J vers. 1.0.0:
|
jonahgraham
left a comment
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.
TextEdit -> Either<TextEdit, SnippetTextEdit> in TextDocumentEdit class
String -> Either<String, MarkupContent> in Diagnostic class
Background:
Those are the new features in LSP 3.18 (beta support). See https://github.com/eclipse-lsp4j/lsp4j/blob/main/CHANGELOG.md#v100-tbd
See 3.18 spec for more details, which is also in the LSP4J javadocs
How to fix:
Because you are not turning on snippetEditSupport to enable the 3.18 feature (yet), the right thing to do is change things like .getEdits -> getEdits.getLeft.
LMK if that makes sense. It may be a better idea to have a separate PR for the 0.24 -> 1.0 LSP4J change, and I can help write that if the above isn't trivial.
| org.eclipse.lsp4j.jsonrpc;bundle-version="[0.24.0,0.25.0)", | ||
| org.eclipse.lsp4j.jsonrpc.debug;bundle-version="[0.24.0,0.25.0)", | ||
| org.eclipse.lsp4j.debug;bundle-version="[0.24.0,0.25.0)", | ||
| org.eclipse.lsp4j.jsonrpc;bundle-version="[1.0.0,1.1.0)", |
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 have improved the API policy for 1.0 going forward to be properly semantic versions. This means the range can safely be:
| org.eclipse.lsp4j.jsonrpc;bundle-version="[1.0.0,1.1.0)", | |
| org.eclipse.lsp4j.jsonrpc;bundle-version="[1.0.0,2.0.0)", |
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.
Hi @jonahgraham,
It may be a better idea to have a separate PR for the 0.24 -> 1.0 LSP4J change,...
Do we need an issue for the separate PR? I started PR #1421 for that purpose.
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.
Do we need an issue for the separate PR?
No IMHO - but I am not an active committer on LSP4E so I don't know if it is best to just create one to save yourself hassle later.
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.
OK. Then, @rubenporras, please let me know if you want me to create an issue for PR #1421 or if you prefer to create it yourself.
ea5b00a to
e08aed6
Compare
org.eclipse.lsp4e/src/org/eclipse/lsp4e/outline/SymbolsLabelProvider.java
Fixed
Show fixed
Hide fixed
5d2dc08 to
0131fe3
Compare
For the sake of simplicity, for now, we only use the left argument in Either tuples, i.e. the types that we used in earlier versions.
0131fe3 to
4abe75c
Compare
4abe75c to
eec3214
Compare
| // TODO Do we have to dispose all images in the image caches? | ||
|
|
||
| private static final Map<java.awt.Color, Image> colorToImageCache = new HashMap<>(); | ||
|
|
||
| /** | ||
| * Cache for symbol images with various overlays and / or an underlay. | ||
| * | ||
| * First key: the element's kind (e.g. class or method); | ||
| * Second key: hash value calculated for a set of overlay image descriptors, | ||
| * see {@link #getImageWithOverlays(SymbolKind, ImageDescriptor[])}; | ||
| * Value: the base image with overlays and an optional underlay combined in one image. | ||
| */ | ||
| private static final Map<SymbolKind, Map<Integer, Image>> overlayImagesCache = new HashMap<>(); |
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.
Hi @jonahgraham,
Do we have to dispose the images cached here? It seems that images should be disposed when the Display used to create them is being disposed. What would be the best way to do that?
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.
The short answer is register with org.eclipse.swt.widgets.Display.disposeExec(Runnable) to dispose of images when the display is disposed.
You can also look at how org.eclipse.jface.resource.ImageRegistry handles it.
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.
PS I dodged the "Do we have to dispose the images cached here? " part of the question - but the answer is yes in theory, in practice if the test suites aren't making additional displays, chances are it never matters in practice. However the non-dispose listener may warn about non-disposed images. Perhaps it is already on colorToImageCache entries, but as it happens on shutdown no one paid attention/noticed?
Run with -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true to get the warnings.
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.
Ok, I hope to have solved it by disposing the cached images on bundle / plug-in stop. I tried to start Eclipse with -Dorg.eclipse.swt.graphics.Resource.reportNonDisposed=true, but did not see any warning or error message if images were not disposed.
| @Nullable ImageDescriptor[] overlays = { | ||
| visibilityImageDescriptor, topRightOverlayDescriptor, | ||
| severityImageDescriptor, bottomRightOverlayDescriptor, | ||
| deprecatedImageDescriptor}; |
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.
Hi @sebthom and @jonahgraham,
Is it correct here to use @Nullable this way? I want to express that the variable overlays cannot be null, but the array entries can be null.
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 it is @NonNull ImageDescriptor @Nullable [] - but not really very experienced in this area.
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.
That's what I also started with, but for some reason I get an error message saying that @NonNull is not allowed 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.
I didn't try it - hopefully @sebthom has a good answer as he has been doing a great job of maintaining the nullness analysis.
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, I solved it now. It turns out, I erroneously used an annotation from LSP4J, not a JDT annotation. In addition, the null checks in Eclipse seem to have problems to correctly check nullabililty for array variables and their entries.
eec3214 to
9746520
Compare
Start using new symbol tags as proposed in my microsoft/language-server-protocol#2003, for example, adding private, package, protected, and public visibility tags as well as tags like static, final, abstract, read-only, nullable and non-null. Our motivation comes from our wish to add visibility and other symbol details to the outline view (see discussion #977), but maybe also to the call hierarchy and to the type hierarchy or to other related features / LSP operations.
The PR on the LSP specification requires at least one implementation in a language server and / or a client. We plan to finish a first language server implementation in clangd [1] [2] and a first client implementation in LSP4J, LSP4E, and CDT LSP (which is using clangd).
See microsoft/language-server-protocol#2003
and llvm/llvm-project#167536
and eclipse-lsp4j/lsp4j#856
The PR for updating LSP4E to LSP4J vers. 1.0.0 (#1421) has to be merged before this PR can be merged.