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
Add support for displaying function signature information #27034
Comments
In analyzer-discuss you said
I did spend some time trying to make this work using myFunc((1 * 2), (fr|ed)); I was also going to have a go at implementing this (by copying So, if there's any possibility of someone looking at this; it would be greatly appreciated. It's one of my biggest annoyances with Dart Code (and @sethladd noticed it missing pretty quick upon first trying out Dart Code!). Alternatively; if you can think of a decent way I can get the correct position to send a |
I'd imagine this would be for more than Visual Code? Would all IDEs be able to utilize this? |
@sethladd I would've thought so, but nobody else appears to have asked for it! @devoncarew said atom doesn't have it so I'm surprised nobody has asked - maybe things work differently there, like you can still see the method you completed? I'm not sure (never used Atom). There is an IDE that has this (IntelliJ IDEA) but that parses Dart itself so is able to figure this out more easily. |
@sethladd Are there any plans to add support for this? I've been running into the same issue recently. |
Sorry, I'm not sure what the plans are. |
@bwilkerson @scheglov How complicated do you think this would be for an outsider (me!) to implement if I can get the analyzer code building/running tests locally? I think it'd be a big improvement for Dart Code and I hope I'll be done with Flutter integration in the next few weeks so maybe can find some time. |
@DanTup, if it helps, there are some setup instructions here for working on the analysis server: https://github.com/dart-lang/sdk/blob/master/pkg/analysis_server/CONTRIBUTING.md. |
That file makes it look so easy; but I'm sure I had real issues last time! =) I'll take a look once this debugging stuff is sorted; though I was mostly after an idea of how hard it'd be to make the changes (assuming I had the environment working). I presume mostly it's like the |
If the existing API isn't sufficient (which is the conclusion I believe we came to), then we would need to add a new request to the API and implement it. The first step would be to come to an agreement on what the API should be, then you add it to the
We could easily add an
and a call site of
(where '^' is the cursor position), should it assume that the next argument is |
IMO either is acceptable; I don't think the user would have any real expectation there (maybe // index should match d, whatever its position in the argument list returned
o.method(1, c: 2, d: ^) |
I don't know whether VSCode would support it, but another possibility would be to return a list of "valid next parameters" and highlight both |
That would be good, though Code doesn't support it. I think it's a good idea, and I can just take the "first" one for Code as the best I can support (and since named args aren't unique to Dart, maybe I'll raise a feature request for Code if/when we have it). I guess the list could also be filtered based on the typed text: void method(a, {b, c1, c2}) {}
// set only c2 as the active index, b is filtered out because of the already-typed c
o.method(1, c1: 2, c^) |
…nctions Bug: #27034 Change-Id: I8d3f1a9c9a824b4b80f9cfa0370a439fa897b226 Reviewed-on: https://dart-review.googlesource.com/64689 Commit-Queue: Danny Tuppeny <dantup@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Bug: #27034 Change-Id: Ie47f76d4197dbcdec0fcfdada7914fdf986731ec Reviewed-on: https://dart-review.googlesource.com/66540 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Danny Tuppeny <dantup@google.com>
…rIndex Bug: #27034 Change-Id: I3409ab544b79a7f64d6d41e5d091ca20418f248a Reviewed-on: https://dart-review.googlesource.com/66562 Commit-Queue: Danny Tuppeny <dantup@google.com> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
The server now supports getSignature as spec'd above. Dart Code vNext will include support for it (though it'll only work if you're running with an SDK that includes the support for it). 🎉 It doesn't currently highlight which parameter you're on, but I may come back to that in the future if we can think of a way to make it work nicely (maybe by stealing ideas from other languages that allow named args in any order :-)) |
Add a new request, something like the following:
Return the signature information associated with the given location in the given file. If the signature information for the given file has not yet been computed, or the most recently computed signature information for the given file is out of date, then the response for this request will be delayed until it has been computed. If the content of the file changes after this request was received but before a response could be sent, then an error of type CONTENT_MODIFIED will be generated.
If a request is made for a file which does not exist, or which is not currently subject to analysis (e.g. because it is not associated with any analysis root specified to analysis.setAnalysisRoots), an error of type GET_SIGNATURE_INVALID_FILE will be generated.
If the location given is not inside the argument list for a function (including method and constructor) invocation, then an error of type GET_SIGNATURE_INVALID_OFFSET will be generated. If the location is inside an argument list but the function is not defined or cannot be determined (such as a method invocation where the target has type 'dynamic') then an error of type GET_SIGNATURE_UNKNOWN_FUNCTION will be generated.
Parameters
file ( FilePath )
The file in which signature information is being requested.
offset ( int )
The location for which signature information is being requested.
Returns
name ( String )
The name of the function being invoked at the given offset.
dartdoc ( String )
The dartdoc associated with the function being invoked. Other than the removal of the comment delimiters, including leading asterisks in the case of a block comment, the dartdoc is unprocessed markdown. This data is omitted if there is no referenced element, or if the element has no dartdoc.
parameters ( List )
A list of information about each of the parameters of the function being invoked.
Where ParameterInfo contains the name, type and kind (required, optional or named) of the parameter.
The text was updated successfully, but these errors were encountered: