def findLocalLabelInView(self, symbol_region):
''' Try to expand the region so that it includes a local label (including macro ones) '''
# check if there is a punctuation at the start
if self.view.classify(symbol_region.begin()) & sublime.CLASS_PUNCTUATION_END:
# cool, there is a punctuation expand selection with custom logic
new_region = self.view.expand_by_class(symbol_region,
sublime.CLASS_WORD_START | sublime.CLASS_WORD_END,
"()[]:, ")
region_word = self.view.substr(new_region).strip()
# we could also use self.view.indexed_symbols() here instead of the scopes
# get the global label point closest to this local one
closest_global = 0
for r in self.view.find_by_selector("rgbds.label.global"):
if r.end() < symbol_region.begin():
closest_global = r.end()
# now get all local labels and stop at the one after the global point
for r in self.view.find_by_selector("rgbds.label.local"):
if self.view.substr(r) == region_word and r.begin() > closest_global:
return (self.view.file_name(), r)
return None
评论列表
文章目录