Skip to content

Enum members do not use EnumMember SymbolKind #2945

Closed

Description

@JCKodel

Describe the bug
There are some inconsistences of VSCode SymbolKind for building extensions.

To Reproduce
I've forked the https://github.com/alefragnani/vscode-separators VSCode extension to add more separators (the original code only works on SymbolKind.Method, SymbolKind.Function and SymbolKind.Constructor). This extensions draws a line separating methods on any VSCode supported language.

While working on it to add more places where separators are placed, there are some minor inconsistences, as follow:

The extension is filtering i.SymbolKind.Method, i.SymbolKind.Function, i.SymbolKind.Constructor, i.SymbolKind.Class, i.SymbolKind.Enum, i.SymbolKind.Interface, but:

image

There is a SymbolKind.EnumMember and a SymbolKind.Enum. I'm requesting only SymbolKind.Enum but the screenshot shows separators on each member.

(A question: extension ModuleExtension on Module { should trigger which SymbolKind?)

image

The SymbolKind.Method (or .function) leaves the @override attribute outside the method itself. I don't know how the definition of SymbolKind works, but would be nice if the SymbolKind.Method (or really any of them) considerer the starting point before the attributes (so the line would be draw above the @override).

(Another question: when using SymbolKind.Property, a separator is drawn before get and another before set. It would be awesome if a pair of get/set should trigger SymbolKind.Property only once, to get only one separator for the pair).

Versions (please complete the following information):

  • VS Code version: 1.51.0
  • Dart extension version: 3.16.0
  • Dart/Flutter SDK version: 1.22.3

Activity

  1. DanTup commented on Nov 10, 2020

    @DanTup
    Member

    There are a few things here, so I'll try to answer them all!

    1. Enum members don't use EnumMember

    That's a bug/oversight. The original LSP spec didn't have EnumMember so it should only be provided when a client advertises support. I've got a fix at https://dart-review.googlesource.com/c/sdk/+/171286/ (I believe the non-LSP version was already updated, but LSP was not).

    2. extension ModuleExtension on Module { should trigger which SymbolKind?

    Looking at the code, I believe this will return Namespace. It's not perfect, but I think it was the closest match from the specified options.

    3. The SymbolKind.Method doesn't include the @override attribute

    This is expected. The symbol data being used here is not really intended for what it's being used for - it's what populates the Outline tree and the Document Symbols list. If we were to include the @override and newlines in the symbol, the tree and symbol list would not work as intended (for example each method tree node might just show @override if the client truncates/clips at the newline).

    4. It would be awesome if get/set triggered only one SymbolKind.Property

    Similar to 3, this isn't really possible without breaking other things (and providing data in a way that LSP servers are not expected to). The best option would be to customise the extension to have some way to fold these together if they're next to each other.

    I think that's everything, but let me know if I overlooked anything. I'll treat this issue as being for the first, since the others are questions or things I don't think we can really address in the LSP data.

    Thanks!

  2. changed the title [-]SymbolKind inconsistences[/-] [+]Enum members do not use EnumMember SymbolKind[/+] on Nov 10, 2020
  3. added this to the v3.17.0 milestone on Nov 10, 2020
  4. added
    in editorRelates to code editing or language features
    in lsp/analysis serverSomething to be fixed in the Dart analysis server
    on Nov 10, 2020
  5. DanTup commented on Nov 10, 2020

    @DanTup
    Member
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 editorRelates to code editing or language featuresin lsp/analysis serverSomething to be fixed in the Dart analysis serveris bug

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions