code-intelligence 4.7.0__py3-none-win_amd64.whl → 4.8.1__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 +20 -15
- code_intelligence/libcode_intelligence.so +0 -0
- code_intelligence/py.typed +0 -0
- {code_intelligence-4.7.0.dist-info → code_intelligence-4.8.1.dist-info}/METADATA +1 -1
- code_intelligence-4.8.1.dist-info/RECORD +7 -0
- code_intelligence-4.7.0.dist-info/RECORD +0 -6
- {code_intelligence-4.7.0.dist-info → code_intelligence-4.8.1.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})"
|
|
@@ -82,6 +86,7 @@ class Language(IntEnum):
|
|
|
82
86
|
DART = 11
|
|
83
87
|
R_LANG = 12
|
|
84
88
|
RUBY = 13
|
|
89
|
+
LUA = 14
|
|
85
90
|
|
|
86
91
|
|
|
87
92
|
@dataclass
|
|
@@ -94,7 +99,7 @@ class Definition_Link:
|
|
|
94
99
|
column_0_based : int = 0
|
|
95
100
|
|
|
96
101
|
@classmethod
|
|
97
|
-
def from_c(cls, link: Definition_Link_C):
|
|
102
|
+
def from_c(cls, link: Definition_Link_C) -> "Definition_Link":
|
|
98
103
|
return cls(
|
|
99
104
|
start_offset_in_text=link.start_offset_in_utf8_text,
|
|
100
105
|
end_offset_in_text=link.end_offset_in_utf8_text,
|
|
@@ -119,7 +124,7 @@ Py_DecRef.restype = None
|
|
|
119
124
|
C_NO_CALLBACK = SCAN_CALLBACK(0)
|
|
120
125
|
|
|
121
126
|
|
|
122
|
-
def _wrap_data_ptr(tup:
|
|
127
|
+
def _wrap_data_ptr(tup: T) -> int:
|
|
123
128
|
# MANUALLY INCREMENT THE REFERENCE COUNT
|
|
124
129
|
# We are now responsible for its lifetime
|
|
125
130
|
Py_IncRef(C.py_object(tup))
|
|
@@ -127,7 +132,7 @@ def _wrap_data_ptr(tup: tuple):
|
|
|
127
132
|
return id(tup)
|
|
128
133
|
|
|
129
134
|
|
|
130
|
-
def _unwrap_data_ptr(data_ptr) ->
|
|
135
|
+
def _unwrap_data_ptr(data_ptr: int) -> T:
|
|
131
136
|
assert data_ptr, "Received a NULL pointer"
|
|
132
137
|
|
|
133
138
|
tup = C.cast(data_ptr, C.py_object).value
|
|
@@ -139,7 +144,7 @@ def _unwrap_data_ptr(data_ptr) -> tuple:
|
|
|
139
144
|
return tup
|
|
140
145
|
|
|
141
146
|
|
|
142
|
-
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:
|
|
143
148
|
if callback is None:
|
|
144
149
|
c_callback, data_ptr = C_NO_CALLBACK, 0
|
|
145
150
|
else:
|
|
@@ -153,13 +158,13 @@ def scan_file(file, language: Language, callback=None, data=None) -> bool:
|
|
|
153
158
|
|
|
154
159
|
|
|
155
160
|
@SCAN_CALLBACK
|
|
156
|
-
def C_AFTER_SCAN(data_ptr):
|
|
161
|
+
def C_AFTER_SCAN(data_ptr: int) -> None:
|
|
157
162
|
callback, data = _unwrap_data_ptr(data_ptr)
|
|
158
163
|
assert callback is not None, "Don't feed youself NULL callbacks!"
|
|
159
164
|
callback(data)
|
|
160
165
|
|
|
161
166
|
|
|
162
|
-
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:
|
|
163
168
|
if callback is None:
|
|
164
169
|
return True
|
|
165
170
|
|
|
@@ -177,7 +182,7 @@ def find_symbols_in_text(text: str, callback=None, data=None, ignore_word_like:
|
|
|
177
182
|
|
|
178
183
|
|
|
179
184
|
@FIND_CALLBACK
|
|
180
|
-
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:
|
|
181
186
|
callback, data = _unwrap_data_ptr(data_ptr)
|
|
182
187
|
try:
|
|
183
188
|
assert callback is not None, "Don't feed youself NULL callbacks!"
|
|
@@ -191,22 +196,22 @@ def C_AFTER_FIND(data_ptr, links_ptr, count, strings_handle):
|
|
|
191
196
|
|
|
192
197
|
|
|
193
198
|
def pending_tasks() -> int:
|
|
194
|
-
return _lib.get_pending_tasks_count()
|
|
199
|
+
return int(_lib.get_pending_tasks_count())
|
|
195
200
|
|
|
196
201
|
|
|
197
|
-
def init():
|
|
202
|
+
def init() -> None:
|
|
198
203
|
_lib.start_workers()
|
|
199
204
|
|
|
200
205
|
|
|
201
|
-
def stop():
|
|
206
|
+
def stop() -> None:
|
|
202
207
|
_lib.enqueue_stop()
|
|
203
208
|
|
|
204
209
|
|
|
205
|
-
def clear():
|
|
210
|
+
def clear() -> None:
|
|
206
211
|
_lib.enqueue_clear()
|
|
207
212
|
|
|
208
213
|
|
|
209
|
-
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:
|
|
210
215
|
# print(f"[PY] Waiting for callbacks (~{timeout_s}s)...")
|
|
211
216
|
deadline = time.time() + timeout_s
|
|
212
217
|
while True:
|
|
@@ -230,10 +235,10 @@ if __name__ == "__main__":
|
|
|
230
235
|
import atexit
|
|
231
236
|
atexit.register(stop)
|
|
232
237
|
|
|
233
|
-
def scan_callback(data):
|
|
238
|
+
def scan_callback(data: Path) -> None:
|
|
234
239
|
print(f"[PY] {data}")
|
|
235
240
|
|
|
236
|
-
def find_callback(data, links):
|
|
241
|
+
def find_callback(data: tuple[str, str], links: list[Definition_Link]) -> None:
|
|
237
242
|
text, label = data
|
|
238
243
|
print(f"[PY] Callback for '{label}': Found {len(links)} symbols in text \"{text}\"")
|
|
239
244
|
for res in links:
|
|
Binary file
|
|
File without changes
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
code_intelligence-4.8.1.dist-info/METADATA,sha256=BmjPwjZS0WFJYRDs0L5-sqqzYPZQvM3fOEUg4LD0t2w,100
|
|
2
|
+
code_intelligence-4.8.1.dist-info/RECORD,,
|
|
3
|
+
code_intelligence-4.8.1.dist-info/WHEEL,sha256=aD7J6E7Slys9i0J65v6Ehfi0DHYa5rImRhUDp62Iwh0,98
|
|
4
|
+
code_intelligence/__init__.py,sha256=qt7lXjwRULYwQYcq3lqkBwFkRSD6ss-rEWR0ROkyF24,587
|
|
5
|
+
code_intelligence/goober.py,sha256=Yo6g6rxW6SRsETKNqqHTy4Psovhs47aH9KdIJc9Ahaw,8174
|
|
6
|
+
code_intelligence/libcode_intelligence.so,sha256=xclfooNJMtj_IKqepicPnKgcZ7Wm6A36Ohv_f97qI6Y,25241088
|
|
7
|
+
code_intelligence/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
code_intelligence-4.7.0.dist-info/METADATA,sha256=GKF_kr3cTwW6YdderbHXfF2FGms6pdq_ONtPgbPhhfo,100
|
|
2
|
-
code_intelligence-4.7.0.dist-info/RECORD,,
|
|
3
|
-
code_intelligence-4.7.0.dist-info/WHEEL,sha256=aD7J6E7Slys9i0J65v6Ehfi0DHYa5rImRhUDp62Iwh0,98
|
|
4
|
-
code_intelligence/__init__.py,sha256=EjG3-0mEmpyU-FdDfCYBLP9StA3orx94w5BIeW2ueD8,587
|
|
5
|
-
code_intelligence/goober.py,sha256=bu_iii83pa2mbmIjjiJ1u_FBesPLPLZSPkE7sct5cWk,7740
|
|
6
|
-
code_intelligence/libcode_intelligence.so,sha256=e-W1-YEVFgPlPERGUUpAwKVjQQq13H35TY7hURrybVk,25187328
|
|
File without changes
|