Home Download Buy Blog Forum Support

Get positions of a Symbol

Get positions of a Symbol

Postby bizoo on Wed Dec 08, 2010 9:02 pm

Hi,

Is there a way to get the positions of a particular symbol (that come from the Grammar)in a text ?
view.syntaxName() give me the symbol name for a position but I want the opposite.
I've found the view.getSymbols() but it work only for the symbols declared in Symbol List, but it's close to what I want.

If it doesn't exists what about add it to next version ?
Please...

Dominique
bizoo
 
Posts: 889
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Get positions of a Symbol

Postby bizoo on Mon Dec 13, 2010 12:33 pm

sublimator wrote:view.matchSelector(pt, s) will determine if scope 's' matches at point 'pt'

You'll have to create your own function to findAll regions matching a scope, but that's not very hard.


I'm not sure I'm understand what You mean.

If I want the positions of all functions in a python source, so basically all occurrence of the scope "source.python meta.function.python".
So to use view.matchSelector() I need to check every word in the source, it would be really inefficient. Or is it something hidden behind findAll ?

I suppose ST already parse the source and record the positions of the scopes, so we only need a method to ask ST where the scopes 'x' are.
bizoo
 
Posts: 889
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Get positions of a Symbol

Postby bizoo on Mon Jul 18, 2011 9:55 am

I raise this question because I need this kind of functionality and look the best way to implement it.
A priori, only Jon could answer.

A practical example is a command to switch from interface to implementation of a method when both are in same file, like Delphi.
Using scope mean that I use the already defined syntax from language versus define my own RE to find them.

Actually, is finding occurrences of a scope using internal ST2 command quicker than a find with RE (is there some internal structure that hold this information when syntax highlight is processed) ?
Do you think my request have a chance to be heard ?

Thanks.
bizoo
 
Posts: 889
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 4 guests