@@ -89,19 +89,34 @@ def get_treesitter_symbols(location, **kwargs):
8989 )
9090
9191
92- def collect_symbols_and_strings (location ):
93- """
94- Return lists containing mappings of symbols and strings collected from file at location.
92+ def get_tree_and_language_info (location ):
9593 """
96- symbols , strings = [], []
94+ Given the `location` of a file, determine the correct parser to use, parse
95+ the file, and return a tuple of (`tree`, `language_info`).
9796
97+ Return (None, None) if a parser is not found for the file type at `location`
98+ """
99+ tree = None
100+ language_info = None
98101 if parser_result := get_parser (location ):
99102 parser , language_info = parser_result
100103
101104 with open (location , "rb" ) as f :
102105 source = f .read ()
103106
104107 tree = parser .parse (source )
108+ return tree , language_info
109+ return tree , language_info
110+
111+
112+ def collect_symbols_and_strings (location ):
113+ """
114+ Return lists containing mappings of symbols and strings collected from file at location.
115+ """
116+ symbols , strings = [], []
117+
118+ tree , language_info = get_tree_and_language_info (location )
119+ if tree and language_info :
105120 traverse (tree .root_node , symbols , strings , language_info )
106121
107122 return symbols , strings
@@ -165,6 +180,11 @@ def traverse(node, symbols, strings, language_info):
165180 "identifiers" : ["identifier" ],
166181 "string_literals" : ["string_literal" ],
167182 },
183+ "Cython" : {
184+ "wheel" : "tree_sitter_python" ,
185+ "identifiers" : ["identifier" ],
186+ "string_literals" : ["string_literal" ],
187+ },
168188 "Go" : {
169189 "wheel" : "tree_sitter_go" ,
170190 "identifiers" : ["identifier" ],
0 commit comments