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: 941
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: 941
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: 941
Joined: Wed Dec 08, 2010 6:53 am
Location: Switzerland

Re: Get positions of a Symbol

Postby tysonlee on Wed Dec 31, 2014 8:32 am

The realistic case can be a control to switch through program to rendering of a technique whenever the two are usually in identical file, including Delphi.
Applying setting imply I exploit your by now defined syntax through vocabulary compared to outline my very own RE to uncover all of them.In fact, is actually discovering events of a setting making use of inner ST2 control more quickly than a discover along with RE (is presently there a few inner design that carry these records whenever syntax spotlight is actually processed)?
Think my own demand get an opportunity to be noticed?
Get Braindumps demos for dumps and passguide with 100% success ccna labs Our high quality online certifications itil prepares you well before appearing in the final keiseruniversity of www.sckans.edu
tysonlee
 
Posts: 2
Joined: Sat Oct 06, 2012 5:44 am

Re: Get positions of a Symbol

Postby tito on Fri Jan 02, 2015 4:17 pm

view.find_by_selector('source.python meta.function.python')
[(49, 69), (84, 107), (969, 983), (1018, 1033), (1069, 1080), (1120, 1134), (1169, 1191), (1234, 1256), (1398, 1418), (1459, 1489), (1540, 1557), (1662, 1686), (1724, 1747), (1784, 1808), (1846, 1887), (1944, 1978), (2019, 2060), (2286, 2310), (2355, 2378), (2415, 2435), ..............................
Give APIs, let the community build the rest!
https://github.com/titoBouzout
tito
 
Posts: 985
Joined: Thu Sep 29, 2011 2:27 pm
Location: Montevideo, Uruguay


Return to Plugin Development

Who is online

Users browsing this forum: No registered users and 6 guests