Skip to content
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

#604 - Updated symbols list #727

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

stweedie
Copy link

Fixes #604 where symbol list will show all references to a given function in a file instead of just the function definition.

This is the exact change proposed in #653, but the original author of that change abandoned it.

@orta
Copy link
Contributor

orta commented Jan 15, 2020

Running with this PR gave back zero results for me when I ran with cmd + r:
Screen Shot 2020-01-15 at 11 37 41 AM

( in comparison on master, where it was too much )
( also sorry it took so long to get to this PR )

@msftclas
Copy link

msftclas commented Jan 16, 2020

CLA assistant check
All CLA requirements met.

@stweedie
Copy link
Author

Thanks for the update @orta. I had to modify the symbols list. Being unable to find proper documentation for how sublime chooses what to put in their symbols list, the best I could do was to have one file to include some symbols (property definitions) and another to exclude other symbols (function calls, for instance).

This will need to be updated to keep up with the tmLanguage file.

Also, one curious thing I noticed is that there is no distinct scope for when you declare a property in the constructor of a class, for instance:

export class SomeClass {
  constructor(private someDependency: SomeDependency) { }
}

in the above, the 'someDependency' has the scopes: source.ts meta.class.ts meta.method.declaration.ts meta.parameters.ts variable.parameter.ts, none of which describe someDependency as a class parameter.

and in case it helps, I'm using the following command:

import sublime
import sublime_plugin

class ListScopesCommand(sublime_plugin.TextCommand):
    def run(self, view):
        for reg in self.view.sel():
            print(self.view.scope_name(reg.begin()))

if you put that in your packages/User folder, you can set a keybind to call 'list_scopes' and see the scopes of the object currently under your cursor.

@orta
Copy link
Contributor

orta commented Jan 17, 2020

Yeah, it looks like it uses a normal args list for the tokenizer there ( vscode has a very good tokenizer preview BTW, would recommend looking at it in that too ) perhaps it could get added to https://github.com/microsoft/TypeScript-TmLanguage

I think this is a pretty reasonable approach, it's very likely all of these names aren't changing anytime in the future.

I'm not sure if it's changed anything on my setup though:

Screen Shot 2020-01-17 at 2 24 07 PM
Screen Shot 2020-01-17 at 2 23 24 PM

I still get a bunch of weird results

Screen Shot 2020-01-17 at 2 26 20 PM

Screen Shot 2020-01-17 at 2 21 48 PM

Does that feel off to you?

@stweedie
Copy link
Author

yeah that does look off. Can you find the scopes for those, and I'll try and find some configuration that excludes them while not excluding stuff we would otherwise want

@stweedie
Copy link
Author

I'm also currently looking at how vscode is implementing their symbols list. I would guess it's not using the text mate scopes as class members defined in the constructor are properly sourced in vscode's symbol list, and there's no difference in scopes between a constructor parameter and a parameter in any class method

@orta
Copy link
Contributor

orta commented Jan 17, 2020

I think vscode uses the tsserver to get the list (probably getDocumentHighlights or getNavigationBarItems)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GoTo Definition shows all function calling in file
3 participants