Pass 3 of 3 · Deep dive of PHAROSPass 1 · OverviewPass 2 · How it works
Code Observatory / function
_get_parser
codeintel.parsers.treesitter_parser._get_parser
PINNED SOURCE Source and edges from the index at this commit. An execution appears only where one was recorded.
PHAROS at 975a38dMIT license
Around this symbol
Search all symbolsLoading
| Symbol | File | Resolved by |
|---|---|---|
| grammar_status | treesitter_parser.py | same file |
| parse_treesitter | treesitter_parser.py | same file |
| Symbol | File | Resolved by |
|---|---|---|
| treesitter_parser | treesitter_parser.py | same file |
codeintel.parsers.treesitter_parser._get_parserbackend/app/codeintel/parsers/treesitter_parser.py, lines 295–318Open source
def _get_parser(grammar: str): """Return a tree-sitter Parser for ``grammar`` or raise ImportError.""" with _cache_lock: if grammar in _parsers: return _parsers[grammar] if grammar in _load_errors: raise ImportError(_load_errors[grammar]) package, module_name, factory = GRAMMAR_PACKAGES[grammar] try: from tree_sitter import Language, Parser module = importlib.import_module(module_name) parser = Parser(Language(getattr(module, factory)())) except Exception as exc: # ImportError, ABI mismatch, ... msg = f"grammar_unavailable:{package}" _load_errors[grammar] = msg logger.warning( "tree-sitter grammar %r unavailable (%s: %s); %s files will be " "indexed as line chunks. Install with: pip install %s", grammar, type(exc).__name__, exc, grammar, package, ) raise ImportError(msg) from exc _parsers[grammar] = parser return parserWhat the index recorded
- Signature
def _get_parser(grammar: str):- File
backend/app/codeintel/parsers/treesitter_parser.py- Lines
- 295–318
- Parser
- python-ast
- Git blob
bf0c9a8044cadd3452ebf5ffa82b866ae00395a9- Call sites
- 7 named, 1 resolved, 6 left unlinked
- Outside this subset
- 1 more edges reach code outside the graph shown here
