code-symbol-index 0.3.2__tar.gz → 0.3.3__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/PKG-INFO +1 -1
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/code_symbol_index.egg-info/PKG-INFO +1 -1
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/code_symbol_index.py +13 -3
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/pyproject.toml +1 -1
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/LICENSE +0 -0
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/README.md +0 -0
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/code_symbol_index.egg-info/SOURCES.txt +0 -0
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/code_symbol_index.egg-info/dependency_links.txt +0 -0
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/code_symbol_index.egg-info/entry_points.txt +0 -0
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/code_symbol_index.egg-info/requires.txt +0 -0
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/code_symbol_index.egg-info/top_level.txt +0 -0
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/setup.cfg +0 -0
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/tests/test_code_symbol_index.py +0 -0
- {code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/tests/test_import.py +0 -0
|
@@ -22,7 +22,7 @@ from tree_sitter import Node
|
|
|
22
22
|
from tree_sitter_language_pack import get_parser
|
|
23
23
|
|
|
24
24
|
|
|
25
|
-
__version__ = "0.3.
|
|
25
|
+
__version__ = "0.3.3"
|
|
26
26
|
SCHEMA_VERSION = 5
|
|
27
27
|
DEFAULT_INDEX_DIR = ".code-symbol-index"
|
|
28
28
|
DEFAULT_INDEX_DB = "index.sqlite"
|
|
@@ -2516,7 +2516,7 @@ def _parse_file(
|
|
|
2516
2516
|
except (OSError, UnicodeDecodeError, BinaryFileError):
|
|
2517
2517
|
return None
|
|
2518
2518
|
|
|
2519
|
-
tree = _parser_for_language(spec.name)
|
|
2519
|
+
tree = _parse_source(_parser_for_language(spec.name), source_text)
|
|
2520
2520
|
root_node = tree.root_node() if callable(tree.root_node) else tree.root_node
|
|
2521
2521
|
source_bytes = source_text.encode("utf-8")
|
|
2522
2522
|
symbols, references = _extract_symbols_and_references(
|
|
@@ -2579,6 +2579,16 @@ def _file_contains_bytes(path: Path, needle: bytes) -> bool:
|
|
|
2579
2579
|
_PARSER_TLS = threading.local()
|
|
2580
2580
|
|
|
2581
2581
|
|
|
2582
|
+
def _parse_source(parser, source: str):
|
|
2583
|
+
# tree-sitter's parse() signature varies across versions/builds: some accept str, others
|
|
2584
|
+
# require bytes (raising "source must be a bytestring or a callable, not str"). Try str first,
|
|
2585
|
+
# then fall back to encoded bytes so both bindings work. Byte offsets are identical either way.
|
|
2586
|
+
try:
|
|
2587
|
+
return parser.parse(source)
|
|
2588
|
+
except TypeError:
|
|
2589
|
+
return parser.parse(source.encode("utf-8"))
|
|
2590
|
+
|
|
2591
|
+
|
|
2582
2592
|
def _parser_for_language(language: str):
|
|
2583
2593
|
if language not in LANGUAGE_BY_NAME:
|
|
2584
2594
|
raise UnsupportedLanguageError(f"Unsupported language: {language}")
|
|
@@ -3691,7 +3701,7 @@ def _definition_ranges_for_symbols(
|
|
|
3691
3701
|
for symbol in symbols
|
|
3692
3702
|
}
|
|
3693
3703
|
ranges: dict[str, Range] = {}
|
|
3694
|
-
tree = _parser_for_language(spec.name)
|
|
3704
|
+
tree = _parse_source(_parser_for_language(spec.name), source)
|
|
3695
3705
|
root_node = tree.root_node() if callable(tree.root_node) else tree.root_node
|
|
3696
3706
|
|
|
3697
3707
|
def walk(node: Node) -> None:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/code_symbol_index.egg-info/dependency_links.txt
RENAMED
|
File without changes
|
{code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/code_symbol_index.egg-info/entry_points.txt
RENAMED
|
File without changes
|
|
File without changes
|
{code_symbol_index-0.3.2 → code_symbol_index-0.3.3}/code_symbol_index.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|