code-intelligence 4.8.0__py3-none-win_amd64.whl → 4.8.2__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 +1 -1
- code_intelligence/goober.py +19 -15
- code_intelligence/libcode_intelligence.so +0 -0
- code_intelligence/py.typed +0 -0
- {code_intelligence-4.8.0.dist-info → code_intelligence-4.8.2.dist-info}/METADATA +1 -1
- code_intelligence-4.8.2.dist-info/RECORD +7 -0
- code_intelligence-4.8.0.dist-info/RECORD +0 -6
- {code_intelligence-4.8.0.dist-info → code_intelligence-4.8.2.dist-info}/WHEEL +0 -0
code_intelligence/__init__.py
CHANGED
code_intelligence/goober.py
CHANGED
|
@@ -6,6 +6,7 @@ import ctypes as C
|
|
|
6
6
|
from pathlib import Path
|
|
7
7
|
from dataclasses import dataclass, fields
|
|
8
8
|
from enum import IntEnum, IntFlag
|
|
9
|
+
from typing import Callable, TypeVar
|
|
9
10
|
|
|
10
11
|
|
|
11
12
|
DIR = Path(__file__).parent
|
|
@@ -59,7 +60,10 @@ _lib.free_memory.argtypes = [C.c_void_p]
|
|
|
59
60
|
_lib.free_memory.restype = None
|
|
60
61
|
|
|
61
62
|
|
|
62
|
-
|
|
63
|
+
T = TypeVar("T")
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
def positional_repr(cls: type) -> type:
|
|
63
67
|
def __repr__(self):
|
|
64
68
|
values = ', '.join(repr(getattr(self, f.name)) for f in fields(self))
|
|
65
69
|
return f"{cls.__name__}({values})"
|
|
@@ -95,7 +99,7 @@ class Definition_Link:
|
|
|
95
99
|
column_0_based : int = 0
|
|
96
100
|
|
|
97
101
|
@classmethod
|
|
98
|
-
def from_c(cls, link: Definition_Link_C):
|
|
102
|
+
def from_c(cls, link: Definition_Link_C) -> "Definition_Link":
|
|
99
103
|
return cls(
|
|
100
104
|
start_offset_in_text=link.start_offset_in_utf8_text,
|
|
101
105
|
end_offset_in_text=link.end_offset_in_utf8_text,
|
|
@@ -120,7 +124,7 @@ Py_DecRef.restype = None
|
|
|
120
124
|
C_NO_CALLBACK = SCAN_CALLBACK(0)
|
|
121
125
|
|
|
122
126
|
|
|
123
|
-
def _wrap_data_ptr(tup:
|
|
127
|
+
def _wrap_data_ptr(tup: T) -> int:
|
|
124
128
|
# MANUALLY INCREMENT THE REFERENCE COUNT
|
|
125
129
|
# We are now responsible for its lifetime
|
|
126
130
|
Py_IncRef(C.py_object(tup))
|
|
@@ -128,7 +132,7 @@ def _wrap_data_ptr(tup: tuple):
|
|
|
128
132
|
return id(tup)
|
|
129
133
|
|
|
130
134
|
|
|
131
|
-
def _unwrap_data_ptr(data_ptr) ->
|
|
135
|
+
def _unwrap_data_ptr(data_ptr: int) -> T:
|
|
132
136
|
assert data_ptr, "Received a NULL pointer"
|
|
133
137
|
|
|
134
138
|
tup = C.cast(data_ptr, C.py_object).value
|
|
@@ -140,7 +144,7 @@ def _unwrap_data_ptr(data_ptr) -> tuple:
|
|
|
140
144
|
return tup
|
|
141
145
|
|
|
142
146
|
|
|
143
|
-
def scan_file(file, language: Language, callback=None, data=None) -> bool:
|
|
147
|
+
def scan_file(file: str | Path, language: Language, callback: Callable[[T | None], None] | None = None, data: T | None = None) -> bool:
|
|
144
148
|
if callback is None:
|
|
145
149
|
c_callback, data_ptr = C_NO_CALLBACK, 0
|
|
146
150
|
else:
|
|
@@ -154,13 +158,13 @@ def scan_file(file, language: Language, callback=None, data=None) -> bool:
|
|
|
154
158
|
|
|
155
159
|
|
|
156
160
|
@SCAN_CALLBACK
|
|
157
|
-
def C_AFTER_SCAN(data_ptr):
|
|
161
|
+
def C_AFTER_SCAN(data_ptr: int) -> None:
|
|
158
162
|
callback, data = _unwrap_data_ptr(data_ptr)
|
|
159
163
|
assert callback is not None, "Don't feed youself NULL callbacks!"
|
|
160
164
|
callback(data)
|
|
161
165
|
|
|
162
166
|
|
|
163
|
-
def find_symbols_in_text(text: str, callback=None, data=None, ignore_word_like: bool = False, sync: bool = False, first_look_at_these_files: list[Path|str] = []) -> bool:
|
|
167
|
+
def find_symbols_in_text(text: str, callback: Callable[[T | None, list[Definition_Link]], None] | None = None, data: T | None = None, ignore_word_like: bool = False, sync: bool = False, first_look_at_these_files: list[Path|str] = []) -> bool:
|
|
164
168
|
if callback is None:
|
|
165
169
|
return True
|
|
166
170
|
|
|
@@ -178,7 +182,7 @@ def find_symbols_in_text(text: str, callback=None, data=None, ignore_word_like:
|
|
|
178
182
|
|
|
179
183
|
|
|
180
184
|
@FIND_CALLBACK
|
|
181
|
-
def C_AFTER_FIND(data_ptr, links_ptr, count, strings_handle):
|
|
185
|
+
def C_AFTER_FIND(data_ptr: int, links_ptr: C.POINTER(Definition_Link_C), count: int, strings_handle: int) -> None:
|
|
182
186
|
callback, data = _unwrap_data_ptr(data_ptr)
|
|
183
187
|
try:
|
|
184
188
|
assert callback is not None, "Don't feed youself NULL callbacks!"
|
|
@@ -192,22 +196,22 @@ def C_AFTER_FIND(data_ptr, links_ptr, count, strings_handle):
|
|
|
192
196
|
|
|
193
197
|
|
|
194
198
|
def pending_tasks() -> int:
|
|
195
|
-
return _lib.get_pending_tasks_count()
|
|
199
|
+
return int(_lib.get_pending_tasks_count())
|
|
196
200
|
|
|
197
201
|
|
|
198
|
-
def init():
|
|
202
|
+
def init() -> None:
|
|
199
203
|
_lib.start_workers()
|
|
200
204
|
|
|
201
205
|
|
|
202
|
-
def stop():
|
|
206
|
+
def stop() -> None:
|
|
203
207
|
_lib.enqueue_stop()
|
|
204
208
|
|
|
205
209
|
|
|
206
|
-
def clear():
|
|
210
|
+
def clear() -> None:
|
|
207
211
|
_lib.enqueue_clear()
|
|
208
212
|
|
|
209
213
|
|
|
210
|
-
def wait_for_callbacks_in_seconds(timeout_s, step_s=0.15):
|
|
214
|
+
def wait_for_callbacks_in_seconds(timeout_s: float, step_s: float = 0.15) -> bool:
|
|
211
215
|
# print(f"[PY] Waiting for callbacks (~{timeout_s}s)...")
|
|
212
216
|
deadline = time.time() + timeout_s
|
|
213
217
|
while True:
|
|
@@ -231,10 +235,10 @@ if __name__ == "__main__":
|
|
|
231
235
|
import atexit
|
|
232
236
|
atexit.register(stop)
|
|
233
237
|
|
|
234
|
-
def scan_callback(data):
|
|
238
|
+
def scan_callback(data: Path) -> None:
|
|
235
239
|
print(f"[PY] {data}")
|
|
236
240
|
|
|
237
|
-
def find_callback(data, links):
|
|
241
|
+
def find_callback(data: tuple[str, str], links: list[Definition_Link]) -> None:
|
|
238
242
|
text, label = data
|
|
239
243
|
print(f"[PY] Callback for '{label}': Found {len(links)} symbols in text \"{text}\"")
|
|
240
244
|
for res in links:
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
code_intelligence-4.8.2.dist-info/METADATA,sha256=6EhekOIYG_k5IhK_dQYrQPKcf2USKXdnmylKNuhmku4,100
|
|
2
|
+
code_intelligence-4.8.2.dist-info/RECORD,,
|
|
3
|
+
code_intelligence-4.8.2.dist-info/WHEEL,sha256=aD7J6E7Slys9i0J65v6Ehfi0DHYa5rImRhUDp62Iwh0,98
|
|
4
|
+
code_intelligence/__init__.py,sha256=4eaRUXnUFa5pmHYNB33oWTbJwehskkBGF9Gvy0PnC6I,587
|
|
5
|
+
code_intelligence/goober.py,sha256=Yo6g6rxW6SRsETKNqqHTy4Psovhs47aH9KdIJc9Ahaw,8174
|
|
6
|
+
code_intelligence/libcode_intelligence.so,sha256=FxVFth93kYfFidM8Qw3tIwaLV0lXaWkh2gJn4NZdVRs,25242112
|
|
7
|
+
code_intelligence/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
code_intelligence-4.8.0.dist-info/METADATA,sha256=1W9sxtyQc1lQNDlvKqK3B3XPiVSIbOTVSYLmpypOcA0,100
|
|
2
|
-
code_intelligence-4.8.0.dist-info/RECORD,,
|
|
3
|
-
code_intelligence-4.8.0.dist-info/WHEEL,sha256=aD7J6E7Slys9i0J65v6Ehfi0DHYa5rImRhUDp62Iwh0,98
|
|
4
|
-
code_intelligence/__init__.py,sha256=NwtulGvVxI5nCIeVUOo7gpQjMIpEUv4VV1bMMQyKKkA,587
|
|
5
|
-
code_intelligence/goober.py,sha256=r_jbnaiorQnJYErAvG-QuzxUtzLG36Xo4f4sqDPPKFQ,7761
|
|
6
|
-
code_intelligence/libcode_intelligence.so,sha256=JDR3H0sAK1L1-Hn7lP9msqOIZh63-_LXX-RG9_qQov4,25241088
|
|
File without changes
|