Skip to content

Completion list looks like something is missing when trailing commas are added to arguments #319

Closed

Description

@sethladd

First off, awesome work on the Flutter support!

I noticed that we don't show the type of what the parameter expects, when trying to complete a named parameter in constructors. Notice the blank space and then comma after "onTap":
capture

Can we show something like: onTap: void Function(), which is more helpful than showing onTap: GestureTapCallback because, what is a GestureTapCallback? :)

Thanks!

Activity

  1. sethladd commented on Jun 16, 2017

    @sethladd
    Author

    BTW do you have a label for "code completion" ?

  2. modified the milestone: v.1.4.2 on Jun 16, 2017
  3. DanTup commented on Jun 16, 2017

    @DanTup
    Member

    @sethladd What do you mean by label? In GH? Not really; I only have some basic labels; there aren't really enough cases that they need breaking into small categories.

  4. DanTup commented on Jun 16, 2017

    @DanTup
    Member

    This text is actually how we get it from the analyzer:

    onTapUp

    However there is a bug in Dart Code that we normally put a placeholder into the completion, but it's only triggered when the completion ends with : (it doesn't consider the trailing comma). I'll fix this, which will add the placeholder but as far as I can see, it still seems I don't have the info you want (for example for onTapUp I know it's a GestureTapUpCallback but not what that is).

    I'll make this fix and then post a screenshot of how it works, and then maybe it's worth raising an issue @ sdk for surfacing the actual type of the function required.

  5. DanTup commented on Jun 16, 2017

    @DanTup
    Member

    @bwilkerson While testing some changes for this, I noticed that in a Dart project I only ever get completions for name parameters end with : but in a Flutter project I get them back with : , on the end. The SDKs are very slightly different versions but this seems like a strange change. Is this a deliberate change made between 1.24.0-dev.6.7 and 1.24.0-dev.6.8 or could this be a bug?

    See #319 (comment), I can repro the differences on same SDK so I've raised cases in sdk for both the weird commas and a request for the original request here.

  6. DanTup commented on Jun 16, 2017

    @DanTup
    Member

    Ok, I was a little confused by this. I think there are two issues, however I don't think the type is missing.. In your screenshot you've opened the "details" pane (Ctrl+Space) which moves the type from the completion list to where it is in yours. Here's what it would normally look like:

    Completion with type

    So I think there are two issues:

    1. There's a weird comma appearing when completing arguments on GestureDetector (I can't repro this by copy/pasting the definition!) which I think should not be there.
    2. Showing the name of the type-def is less useful than showing the underlying type.

    I think both of these things may be Analyzer issues, but I'm gonna do some more investigation.

    However, as a result of this case I did make a bunch of other minor improvements to the completion (#323, #324).

  7. DanTup commented on Jun 16, 2017

    @DanTup
    Member

    It seems like both of the problems described here would require analyzer changes. I've raised two cases over at the SDK repo:

    dart-lang/sdk#29909 - Unexpected commas on the end of argument completion for GestureDetector (bug?)
    dart-lang/sdk#29910 - Provide more information for TypeDefs in completions from analyzer (feature req?)

    I can't really explain the first one (I can't repro the commas with my own classes, but do see them for GestureDetector in same project!).

  8. removed this from the v.1.4.2 milestone on Jun 16, 2017
  9. added
    is enhancement
    blocked on dart / flutter
    on Jun 16, 2017
  10. sethladd commented on Jun 19, 2017

    @sethladd
    Author

    Thanks for taking a look!

  11. DanTup commented on Jun 19, 2017

    @DanTup
    Member

    Seems like the commas being inserted are by-design - see dart-lang/sdk#29909. I don't really agree with this though, I think it's wonky for many reasons and really don't understand the advantages. I'm tempted to strip them out client-side :/

  12. sethladd commented on Jun 21, 2017

    @sethladd
    Author

    Ah, yeah. Interesting that the AS is inserting the comma.

    The commas are basically required, because they are the signal to the formatter: "format this with more tree-like indention", which is very helpful for Flutter developers.

  13. DanTup commented on Jun 23, 2017

    @DanTup
    Member

    @sethladd Since you raised this originally; what are your thoughts on me hiding the trailing comma in the completion list (it would still be inserted into the document)? IMO it totally looks like a bug in your screenshot even though I'm come around (somewhat) to the behaviour (I still think it's inconsistent, but there's discussion about that in the sdk issue!).

    The pro of hiding the comma is that it doesn't look buggy, but the con is that the completion items don't perfectly show you what would be inserted (it's hard to know if that'd be a big deal to people).

  14. added
    in flutter
    on Jun 24, 2017
  15. changed the title [-]Missing function type when code-completing named parameters that expect functions[/-] [+]Completion list looks like something is missing when trailing commas are added to arguments[/+] on Jul 6, 2017
  16. removed
    blocked on dart / flutter
    on Jul 7, 2017
  17. modified the milestone: v2.0 on Jul 7, 2017
  18. DanTup commented on Jul 7, 2017

    @DanTup
    Member

    Due to no responses, I've made a call on this! I've trimmed the commas from the display text so everything looks normal:

    Trimmed

    But when you insert, you still get the original text including the comma (and the placeholder I injected):

    Inserted

    I haven't used it much, but in a quick test this looks and feels really natural.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    in flutteris bugis enhancement

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions