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

Signature help returns wrong active parameter #1039

Closed
yyoncho opened this issue May 15, 2019 · 6 comments · Fixed by #1063
Closed

Signature help returns wrong active parameter #1039

yyoncho opened this issue May 15, 2019 · 6 comments · Fixed by #1063

Comments

@yyoncho
Copy link
Contributor

yyoncho commented May 15, 2019

E. g.

 Arrays.asList(1, 2);
@fbricon
Copy link
Contributor

fbricon commented May 15, 2019

What would be the expected outcome?

@yyoncho
Copy link
Contributor Author

yyoncho commented May 15, 2019

IMO It should be the same as the outcome of Arrays.asList(1); . Apparently, vararg is considered as a single argument and does not match when there are more than one params.

@snjeza snjeza self-assigned this May 15, 2019
@fbricon fbricon added this to the End May 2019 milestone May 15, 2019
@snjeza
Copy link
Contributor

snjeza commented May 20, 2019

I can't reproduce the issue with vscode-java 0.45.0.

1039

@yyoncho
Copy link
Contributor Author

yyoncho commented May 20, 2019

Yes, you are right, the problem actually is that activeParameter and activeSignature are not populated, compare the result with one and two parameters. I guess that VScode just assumes that the first parameter is active:

[Trace - 11:00:35 PM] Received response 'textDocument/signatureHelp - (222)' in 10ms.
Result: {
"signatures": [
               {
               "label": "asList(T... a) : List<T>",
               "documentation": " Returns a fixed-size list backed by the specified array. (Changes to the returned list \"write through\" to the array.) This method acts as bridge between array-based and collection-based APIs, in combination with Collection.toArray. The returned list is serializable and implements RandomAccess. \nThis method also provides a convenient way to create a fixed-size list initialized to contain several elements: \n List<String> stooges = Arrays.asList(\"Larry\", \"Moe\", \"Curly\"); \n * Parameters:\n   - <T> the class of the objects in the array\n   - a the array by which the list will be backed\n * Returns:\n   - a list view of the specified array",
               "parameters": [
                              {
                              "label": "T... a"
                              }
                              ]
               }
               ]
}
[Trace - 11:00:02 PM] Received response 'textDocument/signatureHelp - (205)' in 8ms.
Result: {
    "signatures": [
        {
            "label": "asList(T... a) : List<T>",
            "documentation": " Returns a fixed-size list backed by the specified array. (Changes to the returned list \"write through\" to the array.) This method acts as bridge between array-based and collection-based APIs, in combination with Collection.toArray. The returned list is serializable and implements RandomAccess. \nThis method also provides a convenient way to create a fixed-size list initialized to contain several elements: \n List<String> stooges = Arrays.asList(\"Larry\", \"Moe\", \"Curly\"); \n * Parameters:\n   - <T> the class of the objects in the array\n   - a the array by which the list will be backed\n * Returns:\n   - a list view of the specified array",
            "parameters": [
                {
                    "label": "T... a"
                }
            ]
        }
    ],
    "activeSignature": 0,
    "activeParameter": 0
}

This will reproduce the problem in vscode (it will select the first parameter as active, although it should select the second).

  public void demo (String s, String... s2) {
    demo("1", "2", "3");
  }

@snjeza
Copy link
Contributor

snjeza commented May 20, 2019

The issue depends on #1051

@snjeza snjeza changed the title Signature help does not work for varargs Signature help returns wrong active parameter May 20, 2019
@snjeza
Copy link
Contributor

snjeza commented May 20, 2019

The following examples don't work properly:

new RuntimeException(new Exception(),|);
System.out.println(  |);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants