Getting signature/parameter help information

20 views
Skip to first unread message

Danny Tuppeny

unread,
Aug 6, 2016, 10:23:57 AM8/6/16
to Dart Analyzer Discussion
I'm trying to add signature/parameter help info in Code but I think the APIs are quite different to the analysis server so I'm not sure how best to do it.

In Code I register a signatureHelpProvider which Code invokes when certain characters are pressed (I've set these to "(" and ","). It gets passed a document and the position of the cursor. Eg., if my dart file looks like:

main() {
  print
}

when I type the "(" after print (which also inserts a ")" after the cursor) it will send a request for signature help for the given offset.

I figured I would just call completion.getSuggestions again with that location and filter the results for type = "ARGUMENT_LIST" but I seem to get zero results back (if this is unexpected, let me know and I'll do some logging - for some reason Code's debug console has a strange understanding of how Copy/Paste works...).

Am I on the right track?

Konstantin Shcheglov

unread,
Aug 7, 2016, 4:29:32 PM8/7/16
to analyzer...@dartlang.org, Dan Rubel, Jaime Wren

  Hm...
  Looking through the Analysis Server code I don't see place where we create ARGUMENT_LIST completion results.
  I only see negative tests that we DON'T create them.
  Dan and Jaime may know better why we don't create these results anymore.


  Server does not provide parameters information in structured form.
  The closest API is analysis.getHover, but it is not structured - just raw element description.

  Maybe we should add the corresponding SignatureHelp API.
  Do you know why it has multiple SignatureInformation objects?
  Is it for invocations inside of invocations?
Inline image 1
  So, here the caret is in "bar", which is in "foo".
  But should SignatureHelp also include "baz" signature?
  How about "blah" in "main" or outside of "main"?

  Or are these multiple signatures only for overloads?

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discuss+unsubscribe@dartlang.org.
Visit this group at https://groups.google.com/a/dartlang.org/group/analyzer-discuss/.



--
Konstantin Scheglov
Software Engineer
Google, Inc.

Danny Tuppeny

unread,
Aug 7, 2016, 4:52:12 PM8/7/16
to analyzer...@dartlang.org, Dan Rubel, Jaime Wren
On Sun, 7 Aug 2016 at 21:29 'Konstantin Shcheglov' via Dart Analyzer Discussion <analyzer...@dartlang.org> wrote:
  Maybe we should add the corresponding SignatureHelp API.

I'd definitely vote for that as a feature! I should have a look at what the other IDEs are doing; it seems weird if none of them are giving any help on the arguments to methods/constructors?!

 
  Do you know why it has multiple SignatureInformation objects?
  Is it for invocations inside of invocations?
image.png
  So, here the caret is in "bar", which is in "foo".
  But should SignatureHelp also include "baz" signature?
  How about "blah" in "main" or outside of "main"?

  Or are these multiple signatures only for overloads?

It's just for overloads. You get given a Position in the request for signature info and you return an array or SignatureInformation which correspond to each overload. You also include indexes for which overload and parameters are selected (since it's possible the call is already complete and the user re-typed a "(" or ","). Each overload (SignatureInformation) contains a label and doc and an array of ParameterInfo. Each parameter includes a further label and doc.

As far as I can tell, there is no support for showing the "outer" argument info if you're cursor is as shown in your image (which isn't a surprise to me, in Visual Studio/.NET you'd only get the help for bar there, but move your cursor outside of the parens and then you'd be back to foo's help).

Obviously I'd love to see support for all of this in the server; but if anyone knows if it's possible to get the required info (even if parsing from other data) in the meantime; it'd be useful. I'm trying to pick Dart up again and I'm really missing being able to see overload/arg help! ;(

Danny

Konstantin Shcheglov

unread,
Aug 7, 2016, 5:07:12 PM8/7/16
to analyzer...@dartlang.org, Dan Rubel, Jaime Wren
On Sun, Aug 7, 2016 at 1:52 PM, Danny Tuppeny <da...@tuppeny.com> wrote:
On Sun, 7 Aug 2016 at 21:29 'Konstantin Shcheglov' via Dart Analyzer Discussion <analyzer...@dartlang.org> wrote:
  Maybe we should add the corresponding SignatureHelp API.

I'd definitely vote for that as a feature! I should have a look at what the other IDEs are doing; it seems weird if none of them are giving any help on the arguments to methods/constructors?!

  IDEA parses Dart code itself, and uses this to map offsets to parameters.
Inline image 1
  Note that I don't say that this is the only way to solve the problem :-)

 

 
  Do you know why it has multiple SignatureInformation objects?
  Is it for invocations inside of invocations?
image.png
  So, here the caret is in "bar", which is in "foo".
  But should SignatureHelp also include "baz" signature?
  How about "blah" in "main" or outside of "main"?

  Or are these multiple signatures only for overloads?

It's just for overloads. You get given a Position in the request for signature info and you return an array or SignatureInformation which correspond to each overload. You also include indexes for which overload and parameters are selected (since it's possible the call is already complete and the user re-typed a "(" or ","). Each overload (SignatureInformation) contains a label and doc and an array of ParameterInfo. Each parameter includes a further label and doc.

  OK
  Dart does not have overloads, so just one SignatureInformation.

 

As far as I can tell, there is no support for showing the "outer" argument info if you're cursor is as shown in your image (which isn't a surprise to me, in Visual Studio/.NET you'd only get the help for bar there, but move your cursor outside of the parens and then you'd be back to foo's help).

Obviously I'd love to see support for all of this in the server; but if anyone knows if it's possible to get the required info (even if parsing from other data) in the meantime; it'd be useful. I'm trying to pick Dart up again and I'm really missing being able to see overload/arg help! ;(

Danny

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discuss+unsubscribe@dartlang.org.
Visit this group at https://groups.google.com/a/dartlang.org/group/analyzer-discuss/.

Danny Tuppeny

unread,
Aug 7, 2016, 5:15:04 PM8/7/16
to analyzer...@dartlang.org
  IDEA parses Dart code itself, and uses this to map offsets to parameters.

Hmmm, this doesn't sound like fun!

I was wondering about maybe parsing something out of existing data the AS provided. Maybe it was wishful thinking! :D


  OK
  Dart does not have overloads, so just one SignatureInformation.

Ah yes, of course :)

So I guess the ideal data to return (for me, at least!) would be label (name) + dartdoc of the method/constructor, and array of params (also label (name) + dartdoc) and the index of the param at the current cursor position.

Simples? 😂

Konstantin Shcheglov

unread,
Aug 7, 2016, 5:38:05 PM8/7/16
to analyzer...@dartlang.org
  Unlike Java, in Dart parameters don't have documentation - there is no @param of something like.
  Instead parameters are freely referenced using [parameter_name] markup in the method documentation.
  So, for parameters we can provide their name, type and kind (required, optional positional, optional named).

 

Simples? 😂

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discuss+unsubscribe@dartlang.org.
Visit this group at https://groups.google.com/a/dartlang.org/group/analyzer-discuss/.

Danny Tuppeny

unread,
Aug 7, 2016, 5:46:44 PM8/7/16
to analyzer...@dartlang.org
On Sun, 7 Aug 2016, 22:38 'Konstantin Shcheglov' via Dart Analyzer Discussion, <analyzer...@dartlang.org> wrote:

  Unlike Java, in Dart parameters don't have documentation - there is no @param of something like.
  Instead parameters are freely referenced using [parameter_name] markup in the method documentation.
  So, for parameters we can provide their name, type and kind (required, optional positional, optional named).

Oh yeah, whoops! Sounds reasonable; when can I have it? 😂

Brian Wilkerson

unread,
Aug 8, 2016, 11:40:38 AM8/8/16
to analyzer...@dartlang.org
Let's use https://github.com/dart-lang/sdk/issues/27034 to hammer out the finer points of the API.

Will the proposal there get you the information you need?

Would this API be useful to other tools, and if so what changes would we need to make for them?

Brian

--

Danny Tuppeny

unread,
Aug 8, 2016, 11:51:36 AM8/8/16
to analyzer...@dartlang.org
Sounds great to me; just one minor tweak I've suggested on the GH Issue (parameter index for cursor location).

On Mon, 8 Aug 2016 at 16:40 'Brian Wilkerson' via Dart Analyzer Discussion <analyzer...@dartlang.org> wrote:
Let's use https://github.com/dart-lang/sdk/issues/27034 to hammer out the finer points of the API.

Will the proposal there get you the information you need?

Would this API be useful to other tools, and if so what changes would we need to make for them?


Brian
On Sun, Aug 7, 2016 at 2:46 PM, Danny Tuppeny <da...@tuppeny.com> wrote:
On Sun, 7 Aug 2016, 22:38 'Konstantin Shcheglov' via Dart Analyzer Discussion, <analyzer...@dartlang.org> wrote:

  Unlike Java, in Dart parameters don't have documentation - there is no @param of something like.
  Instead parameters are freely referenced using [parameter_name] markup in the method documentation.
  So, for parameters we can provide their name, type and kind (required, optional positional, optional named).

Oh yeah, whoops! Sounds reasonable; when can I have it? 😂

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discu...@dartlang.org.

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discu...@dartlang.org.

Danny Tuppeny

unread,
Aug 22, 2016, 1:55:03 PM8/22/16
to Dart Analyzer Discussion
Do you think this is something you'd be likely to add? I understand if it's only me that wants it, but knowing if it will come will help me decide whether to try and achieve it another way (eg. using hovers) in the meantime. I think this is the biggest thing remaining that bugs me when I try to write Dart in Dart Code (I'm quite unfamiliar with the SDK and currently get zero help once inside the parens!)

If it's unlikely to happen (or soon), I'm happy to try and do it another way for now!




On Monday, 8 August 2016 16:51:36 UTC+1, Danny Tuppeny wrote:
Sounds great to me; just one minor tweak I've suggested on the GH Issue (parameter index for cursor location).

On Mon, 8 Aug 2016 at 16:40 'Brian Wilkerson' via Dart Analyzer Discussion <analyzer...@dartlang.org> wrote:
Let's use https://github.com/dart-lang/sdk/issues/27034 to hammer out the finer points of the API.

Will the proposal there get you the information you need?

Would this API be useful to other tools, and if so what changes would we need to make for them?


Brian
On Sun, Aug 7, 2016 at 2:46 PM, Danny Tuppeny <da...@tuppeny.com> wrote:
On Sun, 7 Aug 2016, 22:38 'Konstantin Shcheglov' via Dart Analyzer Discussion, <analyzer...@dartlang.org> wrote:

  Unlike Java, in Dart parameters don't have documentation - there is no @param of something like.
  Instead parameters are freely referenced using [parameter_name] markup in the method documentation.
  So, for parameters we can provide their name, type and kind (required, optional positional, optional named).

Oh yeah, whoops! Sounds reasonable; when can I have it? 😂

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discuss+unsubscribe@dartlang.org.

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discuss+unsubscribe@dartlang.org.

Brian Wilkerson

unread,
Aug 22, 2016, 2:52:02 PM8/22/16
to analyzer...@dartlang.org
Danny,

I would love to add this, but I honestly don't know when we might get it implemented, so I certainly don't want to suggest that you wait for it. Do let us know if it turns out to be too hard to implement it using another request, and we'll see whether we can increase the priority.

Brian

Danny Tuppeny

unread,
Aug 22, 2016, 2:58:33 PM8/22/16
to analyzer...@dartlang.org
No worries; I assumed this was the case but wanted to be sure before I put too might time into trying something else. I have a couple of ideas about how I might be able to get it to work so I'll see how it goes :-)

On Mon, 22 Aug 2016 at 19:52 'Brian Wilkerson' via Dart Analyzer Discussion <analyzer...@dartlang.org> wrote:
Danny,

I would love to add this, but I honestly don't know when we might get it implemented, so I certainly don't want to suggest that you wait for it. Do let us know if it turns out to be too hard to implement it using another request, and we'll see whether we can increase the priority.

Brian
On Mon, Aug 22, 2016 at 10:55 AM, Danny Tuppeny <da...@tuppeny.com> wrote:
Do you think this is something you'd be likely to add? I understand if it's only me that wants it, but knowing if it will come will help me decide whether to try and achieve it another way (eg. using hovers) in the meantime. I think this is the biggest thing remaining that bugs me when I try to write Dart in Dart Code (I'm quite unfamiliar with the SDK and currently get zero help once inside the parens!)

If it's unlikely to happen (or soon), I'm happy to try and do it another way for now!




On Monday, 8 August 2016 16:51:36 UTC+1, Danny Tuppeny wrote:
Sounds great to me; just one minor tweak I've suggested on the GH Issue (parameter index for cursor location).

On Mon, 8 Aug 2016 at 16:40 'Brian Wilkerson' via Dart Analyzer Discussion <analyzer...@dartlang.org> wrote:
Let's use https://github.com/dart-lang/sdk/issues/27034 to hammer out the finer points of the API.

Will the proposal there get you the information you need?

Would this API be useful to other tools, and if so what changes would we need to make for them?


Brian
On Sun, Aug 7, 2016 at 2:46 PM, Danny Tuppeny <da...@tuppeny.com> wrote:
On Sun, 7 Aug 2016, 22:38 'Konstantin Shcheglov' via Dart Analyzer Discussion, <analyzer...@dartlang.org> wrote:

  Unlike Java, in Dart parameters don't have documentation - there is no @param of something like.
  Instead parameters are freely referenced using [parameter_name] markup in the method documentation.
  So, for parameters we can provide their name, type and kind (required, optional positional, optional named).

Oh yeah, whoops! Sounds reasonable; when can I have it? 😂

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discu...@dartlang.org.

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discu...@dartlang.org.

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discu...@dartlang.org.

--
You received this message because you are subscribed to the Google Groups "Dart Analyzer Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to analyzer-discu...@dartlang.org.
Reply all
Reply to author
Forward
0 new messages