alefragnani / vscode-separators

Separators Extension for Visual Studio Code
GNU General Public License v3.0
40 stars 6 forks source link

[BUG] - Not detecting all Dart constructions #7

Closed JCKodel closed 3 years ago

JCKodel commented 3 years ago

Environment/version

Steps to reproduce

Not all Dart/Flutter constructions triggers the separator. Some examples (notice the red arrow indicating where I've deleted my custom /* -- separator --*/)

image

(should have separators before enum (line 6), before extension (line 14) and before each get acessor (lines 15 and 32).

image

Before class (line 160).

In this file, only one separator was drawn, in the constructor (const Section(....). Methods works as well.

Dart has the following constructions that, IMO, requires a separator:

1) Between classes (class X, enum X, extension X, mixin X), etc. Dart has no support for interfaces (but has to abstract class).

2) Between get/set accessors (It would be amazing if all 3 items could be grouped, but it's fine only before get/set):

// only one separator here or...
int _privateVar;
// one here
int get privateVar => _privateVar;
// another here
set privateVar(int value) => _privateVar = value;

3) Methods (this is the only one working).

Also, in methods, it should consider attributes (in this example, @override belongs to the method itself, so the separator is better to be placed above @override):

image

alefragnani commented 3 years ago

Hi @JCKodel ,

Right now, the extension only supports Methods, Functions and Constructors, and based on your comments, it appears it is working just fine.

About the @override attribute which can appears above methods, it will depend on changes on the Dart/Flutter extension you use, because it is that extension which provides the location of each symbol, and this extension only uses that information to draw the separators. I don’t parse the source code.

As you already noticed, I’ve opened #2 to expand the kind of symbols which could be supported. At first I thought about addin Classes, Interfaces and Enums, and I’m open for more suggestions. How many, will depend on users feedback. Just keep in mind that it’s not simply a matter of which kind of symbol some language has (you said Dart doesn’t have Interfaces), but how their symbols are mapped to the kind of Symbols VS Code supports (https://code.visualstudio.com/api/references/vscode-api#SymbolKind). It will depend entirely on each Language extension. You can check how these symbols are translated to VS Code symbols, running the Go to Symbol Command and typing :. It will group the symbols by its kind.

I’ll close this issues because I understand it is working as expected, for the kind of symbols it supposed to do, and the other symbols, are also being requested in #2.

Thanks for your suggestions.

Hope this helps