-
Notifications
You must be signed in to change notification settings - Fork 417
Improve occurrences highlighting #1941
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
Improve occurrences highlighting #1941
Conversation
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 . change . is . awesome .
I was happy to make the requests upstream since I would just ping a contact there to make them, but if you want to do them, I'm happy with that.
CC'ing @jjohnstn for awareness : @0dinD would like to contribute to JDT.UI by moving the copied classes mentioned here into jdt.core.manipulation
. It should be a simple move (the dependent classes are already in place).
As for this change : I've tried it out and although it does work, but I see one main protocol issue :
Java types, that would normally display with document highlighting (a more visually noticeable highlight at least on vscode) now displays with a fainter hover highlighting. <-- This is just what OccurencesFinder
did. The other finders use a different kind
resulting in a different highlight.
...ipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/handlers/DocumentHighlightHandler.java
Show resolved
Hide resolved
import org.eclipse.jdt.internal.corext.util.Messages; | ||
|
||
|
||
public class MethodExitsFinder extends ASTVisitor implements IOccurrencesFinder { |
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 simple move request for this class against JDT.UI should eliminate needing to copy.
* | ||
* @since 3.2 | ||
*/ | ||
public class BreakContinueTargetFinder extends ASTVisitor implements IOccurrencesFinder { |
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 checked the imports and they all reside in jdt.core
/ jdt.core.manipulation
, except of course this class :) But that means all we need to do is request JDT.UI move it accordingly.
I can do this, and we drastically reduce the patch size.
I'll let you handle this :)
import org.eclipse.jdt.internal.corext.dom.Bindings; | ||
import org.eclipse.jdt.internal.corext.util.Messages; | ||
|
||
public class ExceptionOccurrencesFinder extends ASTVisitor implements IOccurrencesFinder { |
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 simple move request for this class against JDT.UI should eliminate needing to copy.
* | ||
* @since 3.1 | ||
*/ | ||
public class ImplementOccurrencesFinder implements IOccurrencesFinder { |
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 simple move request for this class against JDT.UI should eliminate needing to copy.
|
||
import org.eclipse.osgi.util.NLS; | ||
|
||
public final class SearchMessages extends NLS { |
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 can probably request this be moved as well along with the properties file.
I'm hoping to have time for this sometime next week. Any tips or pointers are appreciated, otherwise I'll just follow https://wiki.eclipse.org/JDT_UI/How_to_Contribute.
Not sure what exactly you mean (screenshot would help), but I'm guessing it's because I fixed the bug where |
@0dinD In particular https://wiki.eclipse.org/JDT_UI/How_to_Contribute#Contributing_a_change, since the Make sure to CC myself and @jjohnstn on the Gerrit pull request. You'll see your change on https://git.eclipse.org/r/q/project:jdt%252Feclipse.jdt.ui+status:open . |
Right again. Looks like a combination of the LSP only supports Update : I though some of those |
Oh, but now that you say that I think the default is supposed to be
We do explicitly need to set it, since the default kind (if not specified) is export interface DocumentHighlight {
// ...
/**
* The highlight kind, default is DocumentHighlightKind.Text.
*/
kind?: DocumentHighlightKind;
} See also implementation in other language servers:
I've made the change to set |
bd6268a
to
a71de36
Compare
Looks good on this end. In terms of contributing to JDT, the only real obstacle now is the 2022-03 M3 deadline. I've spoken to @akurtakov and although it is Feb 18th, it would be ideal to get it in by the end of this week to ensure no issues. |
Yeah I didn't have much time last week, but I should have time to submit a Gerrit PR during this week. Thanks for the help! |
I've submitted a Gerrit PR now: https://git.eclipse.org/r/c/jdt/eclipse.jdt.ui/+/190713 |
Merged. Once an I-build from Feb 11 (or later) is available, it should be possible to remove the copied code and simply update the target platform to use that. We can keep an eye on https://download.eclipse.org/eclipse/downloads/ for when that might happen. You could also technically play with the change before an I-build is available (and this is often useful for confirming something will work prior to proposing it) by doing a
Just don't forget to remove the artifacts from the local repository or else you'd always be using them. |
Thanks, that's really good to know! |
In fact, now you won't need to update the target platform. Once #2009 is merged (which fixes another issue), you should just be able to rebase on top of it, remove the copied code, and use the new classes available in jdt.core.manipulation. |
Signed-off-by: Odin Dahlström <[email protected]>
a71de36
to
1c2cc40
Compare
test this please |
I've removed the copied classes now, so should be ready to merge if it looks good to you. There was a random test failure, but I see it's already been reported as #1271. |
Thanks for taking the time to get this in. |
Fixes redhat-developer/vscode-java#2211
Fixes redhat-developer/vscode-java#2212
Fixes redhat-developer/vscode-java#2213
Fixes redhat-developer/vscode-java#972
This PR improves on the occurrence highlighting by porting the following occurrence finders from
jdt.ui
:MethodExitsFinder
ExceptionOccurrencesFinder
BreakContinueTargetFinder
ImplementOccurrencesFinder
It also registers the document highlight capability in the syntax server.
Lastly, I fixed a bug which could cause the wrong
DocumentHighlightKind
to be set. The bug was caused by incorrect logic when checking the bit flags set on anOccurrenceLocation
. If, for example, there were no flags set (0
), the condition would still be true, which meansDocumentHighlightKind.Write
would be set even though it shouldn't be.Initially I thought these occurrence finders were available from
jdt.core.manipulation
(seeing asOccurrencesFinder
is), but it turns out they are located injdt.ui
. So I copied the needed classes from there, seeing as they have no external dependencies and as such could easily be ported.With that said, I understand that copying from
jdt.ui
is not ideal, and I think these classes should be moved tojdt.core.manipulation
. But right now I don't have time to spend on that, especially since I'll need to learn how Gerrit works and how to set upjdt.ui
for development.If anyone wants to help with that to avoid copying, please go ahead. But I also think it would be valuable for me to learn how to contribute to upstream (and this seems like a fairly simple contribution to start with), so another alternative is to wait for that (might be a few more weeks until I have time though). Of course, we could also merge this PR with the copied files and then remove them later once they've been moved to
jdt.core.manipulation
.