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

Do not show signature help at the end of an invocation #2079

Merged
merged 1 commit into from
May 4, 2022

Conversation

jdneo
Copy link
Contributor

@jdneo jdneo commented May 2, 2022

for example, when it's foo(), we should not show the signature help.

Signed-off-by: sheche sheche@microsoft.com

@jdneo
Copy link
Contributor Author

jdneo commented May 2, 2022

New behavior

new

Old behavior (The staging bits)

old

@jdneo jdneo requested review from rgrunber and snjeza May 2, 2022 08:24
@rgrunber
Copy link
Contributor

rgrunber commented May 3, 2022

The change works well for me. I just noticed some exceptions thrown when we get into some really weird cases like :

(cursor at |)
System.out.println()|()

SEVERE: Internal error: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0
java.util.concurrent.CompletionException: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0
	at java.base/java.util.concurrent.CompletableFuture.encodeThrowable(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture.completeThrowable(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$UniApply.tryFire(Unknown Source)
	at java.base/java.util.concurrent.CompletableFuture$Completion.exec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.scan(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(Unknown Source)
Caused by: java.lang.IndexOutOfBoundsException: Index -1 out of bounds for length 0
	at java.base/jdk.internal.util.Preconditions.outOfBounds(Unknown Source)
	at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Unknown Source)
	at java.base/jdk.internal.util.Preconditions.checkIndex(Unknown Source)
	at java.base/java.util.Objects.checkIndex(Unknown Source)
	at java.base/java.util.ArrayList.get(Unknown Source)
	at org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpUtils.getSignatureHelpFromASTNode(SignatureHelpUtils.java:65)
	at org.eclipse.jdt.ls.core.internal.handlers.SignatureHelpHandler.signatureHelp(SignatureHelpHandler.java:76)
	at org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer.lambda$8(JDTLanguageServer.java:590)
	at org.eclipse.jdt.ls.core.internal.BaseJDTLanguageServer.lambda$0(BaseJDTLanguageServer.java:75)
	... 7 more

context.arguments() - [$missing$()]
context.argumentRanges() - []

I was wondering why the logic in the first if statement isn't just used to cover the else. Either way, I would probably just try to avoid hitting the error.

@jdneo
Copy link
Contributor Author

jdneo commented May 4, 2022

Didn't know why I could not reproduce the error

image

But anyway, it makes sense to add more checks to avoid those unexpected errors. So I added some checks in the if-else block.

Copy link
Contributor

@rgrunber rgrunber left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try without breakpoints? There's a cancellation check for the monitor if you look at SignatureHelpContext#resolve(..). In many cases dealing with popups in the UI, simply switching away from the UI being tested is enough to trigger the cancellation. If you set your breakpoint after the cancellation checks, maybe you'll run into the issue ?

Change looks good to me.

- for example, when it's "foo()|", we should not show the signature help.

Signed-off-by: sheche <sheche@microsoft.com>
@rgrunber rgrunber added this to the Early May 2022 milestone May 4, 2022
@rgrunber rgrunber merged commit 14644d6 into eclipse-jdtls:master May 4, 2022
@jdneo jdneo deleted the cs/signature-help-fix branch May 5, 2022 01:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants