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

Improve the signature help #2039

Merged
merged 1 commit into from
Apr 24, 2022
Merged

Conversation

jdneo
Copy link
Contributor

@jdneo jdneo commented Mar 29, 2022

fix #2025

The PR works in the following steps:

  1. Check if we can find a method-like node with the trigger offset, which might be: ClassInstanceCreation, ConstructorInvocation, SuperConstructorInvocation, MethodInvocation, SuperMethodInvocation and MethodRef.
    • If no method-like node is found, fallback to the previous implementation.
    • If a method-like node, we leverage that node to provide more context, especially range information to provide signature help (newly added code in SignatureHelpUtils.java)

It fixes the following cases:

1. Can trigger at the method name (as a feature to quickly peek all the overrides of a method)

sig1

2. Strings containing () and ,

sig2

3. varargs method

sig3

4. complex arguments

sig4

5. default constructor

sig5

6. consturutor invocation

sig6

7. super constructor invocation

sig7

8. super method invocation

sig8

9. diamond signs

diamond-sign

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

@@ -225,10 +225,32 @@ public void testSignatureHelp_constructor() throws JavaModelException {
ICompilationUnit cu = pack1.createCompilationUnit("E.java", buf.toString(), false, null);
SignatureHelp help = getSignatureHelp(cu, 3, 26);
assertNotNull(help);
assertEquals(5, help.getSignatures().size());
assertEquals(4, help.getSignatures().size());
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed from 5 to 4 because one of the RuntimeException's constructor is not accessible actually.

- Check if we can find a method-like node with the trigger offset, which
  might be: ClassInstanceCreation, ConstructorInvocation, SuperConstructorInvocation,
  MethodInvocation, SuperMethodInvocation and MethodRef.
- If no method-like node is found, fallback to the previous implementation.
- If a method-like node, we leverage that node to provide more context,
  especially range information to provide signature help.

Signed-off-by: sheche <sheche@microsoft.com>
@jdneo jdneo merged commit dd4b62c into eclipse-jdtls:master Apr 24, 2022
@jdneo jdneo deleted the cs/signature-help branch April 24, 2022 11:24
@rgrunber
Copy link
Contributor

Thanks for having a look @snjeza .

@rgrunber rgrunber added this to the Early May 2022 milestone May 4, 2022
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.

Improve the signature help
3 participants