code-intelligence 1.1.0__py3-none-win_amd64.whl → 1.3.0__py3-none-win_amd64.whl
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_intelligence/__init__.py +5 -12
- code_intelligence/_code_intelligence.dll +0 -0
- code_intelligence/symdb.py +47 -28
- {code_intelligence-1.1.0.dist-info → code_intelligence-1.3.0.dist-info}/METADATA +1 -1
- code_intelligence-1.3.0.dist-info/RECORD +6 -0
- code_intelligence-1.1.0.dist-info/RECORD +0 -6
- {code_intelligence-1.1.0.dist-info → code_intelligence-1.3.0.dist-info}/WHEEL +0 -0
code_intelligence/__init__.py
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
"""
|
|
2
|
-
Code Intelligence Library
|
|
3
|
-
|
|
4
|
-
A lightweight, fast Tree-sitter based code intelligence library.
|
|
5
|
-
Provides symbol database functionality for code analysis.
|
|
6
|
-
"""
|
|
7
|
-
|
|
8
1
|
from .symdb import (
|
|
9
2
|
Language,
|
|
10
3
|
SymbolType,
|
|
11
4
|
Symbol,
|
|
12
5
|
Location,
|
|
13
|
-
|
|
6
|
+
ImmediateSymbolDatabase,
|
|
14
7
|
LazySymbolDatabase,
|
|
15
8
|
)
|
|
16
9
|
|
|
17
|
-
# Backward compatibility alias
|
|
18
|
-
SymbolDatabase =
|
|
10
|
+
# Backward compatibility alias
|
|
11
|
+
SymbolDatabase = ImmediateSymbolDatabase
|
|
19
12
|
|
|
20
|
-
__version__ = "1.
|
|
13
|
+
__version__ = "1.3.0"
|
|
21
14
|
__version_info__ = tuple(int(i) for i in __version__.split('.'))
|
|
22
15
|
|
|
23
16
|
__all__ = [
|
|
@@ -25,7 +18,7 @@ __all__ = [
|
|
|
25
18
|
"SymbolType",
|
|
26
19
|
"Symbol",
|
|
27
20
|
"Location",
|
|
28
|
-
"
|
|
21
|
+
"ImmediateSymbolDatabase",
|
|
29
22
|
"LazySymbolDatabase",
|
|
30
23
|
"SymbolDatabase",
|
|
31
24
|
]
|
|
Binary file
|
code_intelligence/symdb.py
CHANGED
|
@@ -9,21 +9,14 @@ from dataclasses import dataclass, field
|
|
|
9
9
|
class Language(IntEnum):
|
|
10
10
|
# UNKNOWN = 0
|
|
11
11
|
PYTHON = 1
|
|
12
|
-
JAVASCRIPT = 2
|
|
13
|
-
TYPESCRIPT = 3
|
|
12
|
+
JAVASCRIPT = 2 # Not implemented yet - enum exists but no parser
|
|
13
|
+
TYPESCRIPT = 3 # Not implemented yet - enum exists but no parser
|
|
14
14
|
CPP = 4
|
|
15
15
|
C = 5
|
|
16
|
-
JAVA = 6
|
|
16
|
+
JAVA = 6 # Not implemented yet - enum exists but no parser
|
|
17
17
|
RUST = 7
|
|
18
18
|
GO = 8
|
|
19
19
|
PHP = 9
|
|
20
|
-
RUBY = 10
|
|
21
|
-
CSHARP = 11
|
|
22
|
-
KOTLIN = 12
|
|
23
|
-
SWIFT = 13
|
|
24
|
-
SCALA = 14
|
|
25
|
-
DART = 15
|
|
26
|
-
LUA = 16
|
|
27
20
|
|
|
28
21
|
|
|
29
22
|
class SymbolType(IntEnum):
|
|
@@ -35,17 +28,6 @@ class SymbolType(IntEnum):
|
|
|
35
28
|
MODULE = 5
|
|
36
29
|
IMPORT = 6
|
|
37
30
|
FROM_IMPORT = 7
|
|
38
|
-
CONSTANT = 8
|
|
39
|
-
PROPERTY = 9
|
|
40
|
-
INTERFACE = 10
|
|
41
|
-
STRUCT = 11
|
|
42
|
-
ENUM = 12
|
|
43
|
-
NAMESPACE = 13
|
|
44
|
-
PACKAGE = 14
|
|
45
|
-
FIELD = 15
|
|
46
|
-
PARAMETER = 16
|
|
47
|
-
LOCAL = 17
|
|
48
|
-
TYPE = 18
|
|
49
31
|
|
|
50
32
|
Path_Like = str | Path
|
|
51
33
|
|
|
@@ -94,7 +76,6 @@ class Symbol:
|
|
|
94
76
|
|
|
95
77
|
# --- Private ctypes Implementation ---
|
|
96
78
|
|
|
97
|
-
# Matches ci_location_t (field name 'path')
|
|
98
79
|
class _Location(ctypes.Structure):
|
|
99
80
|
_fields_ = [
|
|
100
81
|
("path", ctypes.c_char_p),
|
|
@@ -104,15 +85,16 @@ class _Location(ctypes.Structure):
|
|
|
104
85
|
("end_column", ctypes.c_uint32),
|
|
105
86
|
]
|
|
106
87
|
|
|
107
|
-
# Matches ci_symbol_t (field name 'definition')
|
|
108
88
|
class _Symbol(ctypes.Structure):
|
|
109
89
|
_fields_ = [
|
|
110
90
|
("name", ctypes.c_char_p),
|
|
111
|
-
("symbol_type", ctypes.
|
|
91
|
+
("symbol_type", ctypes.c_uint8),
|
|
112
92
|
("definition", _Location),
|
|
113
93
|
("parent", ctypes.c_char_p),
|
|
114
94
|
("signature", ctypes.c_char_p),
|
|
115
95
|
("documentation", ctypes.c_char_p),
|
|
96
|
+
("_is_stub", ctypes.c_bool),
|
|
97
|
+
("_target_module", ctypes.c_char_p),
|
|
116
98
|
]
|
|
117
99
|
|
|
118
100
|
|
|
@@ -154,18 +136,18 @@ _lib.symbol_db_destroy.restype = None
|
|
|
154
136
|
_lib.symbol_db_set_project_root.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
|
|
155
137
|
_lib.symbol_db_set_project_root.restype = None
|
|
156
138
|
|
|
157
|
-
_lib.symbol_db_scan_file.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.
|
|
139
|
+
_lib.symbol_db_scan_file.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_uint8]
|
|
158
140
|
_lib.symbol_db_scan_file.restype = ctypes.c_bool
|
|
159
141
|
|
|
160
142
|
# Batch scan
|
|
161
|
-
_lib.symbol_db_scan_files.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_char_p), ctypes.c_uint32, ctypes.
|
|
143
|
+
_lib.symbol_db_scan_files.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_char_p), ctypes.c_uint32, ctypes.c_uint8]
|
|
162
144
|
_lib.symbol_db_scan_files.restype = ctypes.c_bool
|
|
163
145
|
|
|
164
146
|
_lib.symbol_db_remove_file.argtypes = [ctypes.c_void_p, ctypes.c_char_p]
|
|
165
147
|
_lib.symbol_db_remove_file.restype = ctypes.c_bool
|
|
166
148
|
|
|
167
149
|
# Update file (re-scan and replace)
|
|
168
|
-
_lib.symbol_db_update_file.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.
|
|
150
|
+
_lib.symbol_db_update_file.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_uint8]
|
|
169
151
|
_lib.symbol_db_update_file.restype = ctypes.c_bool
|
|
170
152
|
|
|
171
153
|
# Arrays with out_count
|
|
@@ -178,6 +160,9 @@ _lib.symbol_db_find_references.restype = ctypes.POINTER(_Symbol)
|
|
|
178
160
|
_lib.symbol_db_get_all_symbols.argtypes = [ctypes.c_void_p, ctypes.POINTER(ctypes.c_uint32)]
|
|
179
161
|
_lib.symbol_db_get_all_symbols.restype = ctypes.POINTER(_Symbol)
|
|
180
162
|
|
|
163
|
+
_lib.symbol_db_get_file_symbols.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.POINTER(ctypes.c_uint32)]
|
|
164
|
+
_lib.symbol_db_get_file_symbols.restype = ctypes.POINTER(_Symbol)
|
|
165
|
+
|
|
181
166
|
# bool return + out _Symbol
|
|
182
167
|
_lib.symbol_db_get_symbol.argtypes = [ctypes.c_void_p, ctypes.c_char_p, ctypes.c_uint32, ctypes.c_uint32, ctypes.POINTER(_Symbol)]
|
|
183
168
|
_lib.symbol_db_get_symbol.restype = ctypes.c_bool
|
|
@@ -189,6 +174,9 @@ _lib.symbol_array_free.restype = None
|
|
|
189
174
|
_lib.ci_flush_coverage.argtypes = []
|
|
190
175
|
_lib.ci_flush_coverage.restype = None
|
|
191
176
|
|
|
177
|
+
_lib.symbol_db_clear.argtypes = [ctypes.c_void_p, ctypes.c_int]
|
|
178
|
+
_lib.symbol_db_clear.restype = None
|
|
179
|
+
|
|
192
180
|
def _flush_coverage():
|
|
193
181
|
try:
|
|
194
182
|
_lib.ci_flush_coverage()
|
|
@@ -341,6 +329,19 @@ class _BaseSymbolDatabase:
|
|
|
341
329
|
_lib.symbol_db_destroy(self._handle)
|
|
342
330
|
self._handle = None
|
|
343
331
|
|
|
332
|
+
def clear(self, *, reuse_memory: bool = True):
|
|
333
|
+
"""Reset the database state while keeping the same Python object.
|
|
334
|
+
|
|
335
|
+
Frees the current native database state and reinitializes it. Any
|
|
336
|
+
previously scanned files, symbols, and project root are discarded.
|
|
337
|
+
|
|
338
|
+
Args:
|
|
339
|
+
reuse_memory: If True (default), keep allocated arena memory for reuse.
|
|
340
|
+
If False, free all memory and start fresh.
|
|
341
|
+
"""
|
|
342
|
+
if self._handle:
|
|
343
|
+
_lib.symbol_db_clear(self._handle, ctypes.c_int(1 if reuse_memory else 0))
|
|
344
|
+
|
|
344
345
|
def set_project_root(self, path: Path_Like):
|
|
345
346
|
_lib.symbol_db_set_project_root(self._handle, os.fsencode(path))
|
|
346
347
|
|
|
@@ -397,7 +398,7 @@ class _BaseSymbolDatabase:
|
|
|
397
398
|
return _to_py_symbol(out) if ok else None
|
|
398
399
|
|
|
399
400
|
|
|
400
|
-
class
|
|
401
|
+
class ImmediateSymbolDatabase(_BaseSymbolDatabase):
|
|
401
402
|
"""Symbol database using copying (eager) backend."""
|
|
402
403
|
def find_definitions(self, symbol_name: str) -> list[Symbol]:
|
|
403
404
|
count = ctypes.c_uint32(0)
|
|
@@ -425,6 +426,15 @@ class ImmideateSymbolDatabase(_BaseSymbolDatabase):
|
|
|
425
426
|
ptr = _lib.symbol_db_get_all_symbols(self._handle, ctypes.byref(count))
|
|
426
427
|
return _convert_symbol_array(ptr, int(count.value))
|
|
427
428
|
|
|
429
|
+
def get_file_symbols(self, path: Path_Like) -> list[Symbol]:
|
|
430
|
+
count = ctypes.c_uint32(0)
|
|
431
|
+
ptr = _lib.symbol_db_get_file_symbols(
|
|
432
|
+
self._handle,
|
|
433
|
+
os.fsencode(path),
|
|
434
|
+
ctypes.byref(count),
|
|
435
|
+
)
|
|
436
|
+
return _convert_symbol_array(ptr, int(count.value))
|
|
437
|
+
|
|
428
438
|
|
|
429
439
|
class LazySymbolDatabase(_BaseSymbolDatabase):
|
|
430
440
|
"""Symbol database using lazy backend."""
|
|
@@ -454,3 +464,12 @@ class LazySymbolDatabase(_BaseSymbolDatabase):
|
|
|
454
464
|
ptr = _lib.symbol_db_get_all_symbols(self._handle, ctypes.byref(count))
|
|
455
465
|
return _convert_symbol_array_lazy(ptr, int(count.value))
|
|
456
466
|
|
|
467
|
+
def get_file_symbols(self, path: Path_Like) -> SymbolArrayView:
|
|
468
|
+
count = ctypes.c_uint32(0)
|
|
469
|
+
ptr = _lib.symbol_db_get_file_symbols(
|
|
470
|
+
self._handle,
|
|
471
|
+
os.fsencode(path),
|
|
472
|
+
ctypes.byref(count),
|
|
473
|
+
)
|
|
474
|
+
return _convert_symbol_array_lazy(ptr, int(count.value))
|
|
475
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
code_intelligence-1.3.0.dist-info/METADATA,sha256=___8D0t8oEl2VRhVidjmJX1B84UDJkFHPhHm5w8mews,100
|
|
2
|
+
code_intelligence-1.3.0.dist-info/RECORD,,
|
|
3
|
+
code_intelligence-1.3.0.dist-info/WHEEL,sha256=aD7J6E7Slys9i0J65v6Ehfi0DHYa5rImRhUDp62Iwh0,98
|
|
4
|
+
code_intelligence/__init__.py,sha256=2br2823E1Mi9gejTIr_lRhPtv0tZKFlyjVebV_tuxJg,475
|
|
5
|
+
code_intelligence/_code_intelligence.dll,sha256=2f_7kGXznmc3NBbSn7H6HvaA_Mp9sKK8xRAQ4XJ39Tw,6475264
|
|
6
|
+
code_intelligence/symdb.py,sha256=eIcyCsbXNBfpmHsEJmHtOSgtMW8GdrnIryYDSfafGH4,16529
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
code_intelligence-1.1.0.dist-info/METADATA,sha256=46s-pcLbZcw6z4i8hq5uw-naESHKn0_af7mqDR7-9V0,100
|
|
2
|
-
code_intelligence-1.1.0.dist-info/RECORD,,
|
|
3
|
-
code_intelligence-1.1.0.dist-info/WHEEL,sha256=aD7J6E7Slys9i0J65v6Ehfi0DHYa5rImRhUDp62Iwh0,98
|
|
4
|
-
code_intelligence/__init__.py,sha256=P8L8zacW4zhJsh7Y8OWqRzuFICzv7Ao2qZdyyoHHvSo,671
|
|
5
|
-
code_intelligence/_code_intelligence.dll,sha256=G3mOir53ppOKlFxY921nai6povpMcUbncb5o743Ufc0,6473728
|
|
6
|
-
code_intelligence/symdb.py,sha256=0Gfj1e2Huh6de_iMlz7Jf2gRt9HVjIqJJk4Bhigf4QU,15158
|
|
File without changes
|