robotcode-robot 0.95.0__py3-none-any.whl → 0.95.2__py3-none-any.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.
- robotcode/robot/__version__.py +1 -1
- robotcode/robot/diagnostics/entities.py +8 -8
- robotcode/robot/diagnostics/imports_manager.py +3 -10
- robotcode/robot/diagnostics/keyword_finder.py +40 -39
- robotcode/robot/diagnostics/library_doc.py +197 -204
- robotcode/robot/diagnostics/model_helper.py +3 -3
- robotcode/robot/diagnostics/namespace.py +2 -7
- robotcode/robot/diagnostics/namespace_analyzer.py +8 -5
- robotcode/robot/utils/ast.py +42 -60
- robotcode/robot/utils/markdownformatter.py +11 -11
- robotcode/robot/utils/match.py +6 -5
- robotcode/robot/utils/robot_path.py +2 -2
- robotcode/robot/utils/stubs.py +1 -25
- robotcode/robot/utils/variables.py +5 -5
- robotcode/robot/utils/visitor.py +2 -28
- {robotcode_robot-0.95.0.dist-info → robotcode_robot-0.95.2.dist-info}/METADATA +2 -2
- robotcode_robot-0.95.2.dist-info/RECORD +32 -0
- robotcode_robot-0.95.0.dist-info/RECORD +0 -32
- {robotcode_robot-0.95.0.dist-info → robotcode_robot-0.95.2.dist-info}/WHEEL +0 -0
- {robotcode_robot-0.95.0.dist-info → robotcode_robot-0.95.2.dist-info}/licenses/LICENSE.txt +0 -0
robotcode/robot/__version__.py
CHANGED
@@ -1 +1 @@
|
|
1
|
-
__version__ = "0.95.
|
1
|
+
__version__ = "0.95.2"
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import functools
|
1
2
|
from dataclasses import dataclass, field
|
2
3
|
from enum import Enum
|
3
4
|
from typing import (
|
@@ -142,19 +143,19 @@ class VariableMatcher:
|
|
142
143
|
|
143
144
|
self.base = match.base
|
144
145
|
|
145
|
-
self.normalized_name =
|
146
|
+
self.normalized_name = normalize(self.base)
|
146
147
|
|
147
148
|
def __eq__(self, o: object) -> bool:
|
148
|
-
if
|
149
|
+
if type(o) is VariableMatcher:
|
149
150
|
return o.normalized_name == self.normalized_name
|
150
151
|
|
151
|
-
if
|
152
|
+
if type(o) is str:
|
152
153
|
match = search_variable(o, "$@&%", ignore_errors=True)
|
153
154
|
base = match.base
|
154
155
|
if base is None:
|
155
156
|
return False
|
156
157
|
|
157
|
-
normalized =
|
158
|
+
normalized = normalize(base)
|
158
159
|
return self.normalized_name == normalized
|
159
160
|
|
160
161
|
return False
|
@@ -194,10 +195,9 @@ class VariableDefinition(SourceEntity):
|
|
194
195
|
value: Any = field(default=None, compare=False)
|
195
196
|
value_is_native: bool = field(default=False, compare=False)
|
196
197
|
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
self.matcher = VariableMatcher(self.name)
|
198
|
+
@functools.cached_property
|
199
|
+
def matcher(self) -> VariableMatcher:
|
200
|
+
return VariableMatcher(self.name)
|
201
201
|
|
202
202
|
@single_call
|
203
203
|
def __hash__(self) -> int:
|
@@ -573,12 +573,10 @@ class ImportsManager:
|
|
573
573
|
self._resource_document_changed_timer_interval = 1
|
574
574
|
self._resource_document_changed_documents: Set[TextDocument] = set()
|
575
575
|
|
576
|
-
self._resource_libdoc_cache: "weakref.WeakKeyDictionary[ast.AST, Dict[
|
576
|
+
self._resource_libdoc_cache: "weakref.WeakKeyDictionary[ast.AST, Dict[str, LibraryDoc]]" = (
|
577
577
|
weakref.WeakKeyDictionary()
|
578
578
|
)
|
579
579
|
|
580
|
-
self._process_pool_executor: Optional[ProcessPoolExecutor] = None
|
581
|
-
|
582
580
|
def __del__(self) -> None:
|
583
581
|
try:
|
584
582
|
if self._executor is not None:
|
@@ -1302,9 +1300,8 @@ class ImportsManager:
|
|
1302
1300
|
self,
|
1303
1301
|
model: ast.AST,
|
1304
1302
|
source: str,
|
1305
|
-
append_model_errors: bool = True,
|
1306
1303
|
) -> LibraryDoc:
|
1307
|
-
key =
|
1304
|
+
key = source
|
1308
1305
|
|
1309
1306
|
entry = None
|
1310
1307
|
if model in self._resource_libdoc_cache:
|
@@ -1313,11 +1310,7 @@ class ImportsManager:
|
|
1313
1310
|
if entry and key in entry:
|
1314
1311
|
return entry[key]
|
1315
1312
|
|
1316
|
-
result = get_model_doc(
|
1317
|
-
model=model,
|
1318
|
-
source=source,
|
1319
|
-
append_model_errors=append_model_errors,
|
1320
|
-
)
|
1313
|
+
result = get_model_doc(model=model, source=source)
|
1321
1314
|
if entry is None:
|
1322
1315
|
entry = {}
|
1323
1316
|
self._resource_libdoc_cache[model] = entry
|
@@ -39,9 +39,8 @@ DEFAULT_BDD_PREFIXES = {"Given ", "When ", "Then ", "And ", "But "}
|
|
39
39
|
|
40
40
|
|
41
41
|
class KeywordFinder:
|
42
|
-
def __init__(self, namespace: "Namespace"
|
43
|
-
self.
|
44
|
-
self.self_library_doc = library_doc
|
42
|
+
def __init__(self, namespace: "Namespace") -> None:
|
43
|
+
self._namespace = namespace
|
45
44
|
|
46
45
|
self.diagnostics: List[DiagnosticsEntry] = []
|
47
46
|
self.result_bdd_prefix: Optional[str] = None
|
@@ -57,9 +56,9 @@ class KeywordFinder:
|
|
57
56
|
],
|
58
57
|
] = {}
|
59
58
|
|
60
|
-
|
61
|
-
|
62
|
-
self.
|
59
|
+
@functools.cached_property
|
60
|
+
def _library_doc(self) -> LibraryDoc:
|
61
|
+
return self._namespace.get_library_doc()
|
63
62
|
|
64
63
|
def reset_diagnostics(self) -> None:
|
65
64
|
self.diagnostics = []
|
@@ -162,7 +161,7 @@ class KeywordFinder:
|
|
162
161
|
def _get_keyword_from_self(self, name: str) -> Optional[KeywordDoc]:
|
163
162
|
if get_robot_version() >= (6, 0):
|
164
163
|
found: List[Tuple[Optional[LibraryEntry], KeywordDoc]] = [
|
165
|
-
(None, v) for v in self.
|
164
|
+
(None, v) for v in self._library_doc.keywords.iter_all(name)
|
166
165
|
]
|
167
166
|
if len(found) > 1:
|
168
167
|
found = self._select_best_matches(found)
|
@@ -183,7 +182,7 @@ class KeywordFinder:
|
|
183
182
|
return None
|
184
183
|
|
185
184
|
try:
|
186
|
-
return self.
|
185
|
+
return self._library_doc.keywords.get(name, None)
|
187
186
|
except KeywordError as e:
|
188
187
|
self.diagnostics.append(DiagnosticsEntry(str(e), DiagnosticSeverity.ERROR, Error.KEYWORD_ERROR))
|
189
188
|
raise CancelSearchError from e
|
@@ -213,15 +212,16 @@ class KeywordFinder:
|
|
213
212
|
|
214
213
|
return found[0][1] if found else None
|
215
214
|
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
)
|
215
|
+
@functools.cached_property
|
216
|
+
def _all_keywords(self) -> List[LibraryEntry]:
|
217
|
+
return list(
|
218
|
+
chain(
|
219
|
+
self._namespace._libraries.values(),
|
220
|
+
self._namespace._resources.values(),
|
223
221
|
)
|
222
|
+
)
|
224
223
|
|
224
|
+
def find_keywords(self, owner_name: str, name: str) -> List[Tuple[LibraryEntry, KeywordDoc]]:
|
225
225
|
if get_robot_version() >= (6, 0):
|
226
226
|
result: List[Tuple[LibraryEntry, KeywordDoc]] = []
|
227
227
|
for v in self._all_keywords:
|
@@ -271,11 +271,11 @@ class KeywordFinder:
|
|
271
271
|
def _prioritize_same_file_or_public(
|
272
272
|
self, entries: List[Tuple[Optional[LibraryEntry], KeywordDoc]]
|
273
273
|
) -> List[Tuple[Optional[LibraryEntry], KeywordDoc]]:
|
274
|
-
matches = [h for h in entries if h[1].source == self.
|
274
|
+
matches = [h for h in entries if h[1].source == self._namespace.source]
|
275
275
|
if matches:
|
276
276
|
return matches
|
277
277
|
|
278
|
-
matches = [handler for handler in entries if not handler[1].is_private
|
278
|
+
matches = [handler for handler in entries if not handler[1].is_private]
|
279
279
|
|
280
280
|
return matches or entries
|
281
281
|
|
@@ -312,23 +312,24 @@ class KeywordFinder:
|
|
312
312
|
other: Tuple[Optional[LibraryEntry], KeywordDoc],
|
313
313
|
) -> bool:
|
314
314
|
return (
|
315
|
-
other[1].matcher.embedded_arguments
|
315
|
+
other[1].matcher.embedded_arguments is not None
|
316
|
+
and candidate[1].matcher.embedded_arguments is not None
|
317
|
+
and other[1].matcher.embedded_arguments.match(candidate[1].name) is not None
|
316
318
|
and candidate[1].matcher.embedded_arguments.match(other[1].name) is None
|
317
319
|
)
|
318
320
|
|
319
|
-
|
320
|
-
|
321
|
-
|
321
|
+
@functools.cached_property
|
322
|
+
def _resource_imports(self) -> List[ResourceEntry]:
|
323
|
+
return list(chain(self._namespace._resources.values()))
|
322
324
|
|
325
|
+
def _get_keyword_from_resource_files(self, name: str) -> Optional[KeywordDoc]:
|
323
326
|
if get_robot_version() >= (6, 0):
|
324
|
-
found: List[Tuple[Optional[LibraryEntry], KeywordDoc]] = [
|
325
|
-
|
326
|
-
|
327
|
-
if r:
|
328
|
-
found.extend([(v, k) for k in r])
|
327
|
+
found: List[Tuple[Optional[LibraryEntry], KeywordDoc]] = [
|
328
|
+
(v, k) for v in self._resource_imports for k in v.library_doc.keywords.iter_all(name)
|
329
|
+
]
|
329
330
|
else:
|
330
331
|
found = []
|
331
|
-
for k in self.
|
332
|
+
for k in self._resource_imports:
|
332
333
|
s = k.library_doc.keywords.get(name, None)
|
333
334
|
if s is not None:
|
334
335
|
found.append((k, s))
|
@@ -365,27 +366,27 @@ class KeywordFinder:
|
|
365
366
|
def _get_keyword_based_on_search_order(
|
366
367
|
self, entries: List[Tuple[Optional[LibraryEntry], KeywordDoc]]
|
367
368
|
) -> List[Tuple[Optional[LibraryEntry], KeywordDoc]]:
|
368
|
-
for libname in self.
|
369
|
+
for libname in self._namespace.search_order:
|
369
370
|
for e in entries:
|
370
371
|
if e[0] is not None and eq_namespace(libname, e[0].alias or e[0].name):
|
371
372
|
return [e]
|
372
373
|
|
373
374
|
return entries
|
374
375
|
|
375
|
-
|
376
|
-
|
377
|
-
|
376
|
+
@functools.cached_property
|
377
|
+
def _library_imports(self) -> List[LibraryEntry]:
|
378
|
+
return list(chain(self._namespace._libraries.values()))
|
378
379
|
|
380
|
+
def _get_keyword_from_libraries(self, name: str) -> Optional[KeywordDoc]:
|
379
381
|
if get_robot_version() >= (6, 0):
|
380
|
-
found: List[Tuple[Optional[LibraryEntry], KeywordDoc]] = [
|
381
|
-
|
382
|
-
|
383
|
-
|
384
|
-
found.extend([(v, k) for k in r])
|
382
|
+
found: List[Tuple[Optional[LibraryEntry], KeywordDoc]] = [
|
383
|
+
(v, k) for v in self._library_imports for k in v.library_doc.keywords.iter_all(name)
|
384
|
+
]
|
385
|
+
|
385
386
|
else:
|
386
387
|
found = []
|
387
388
|
|
388
|
-
for k in self.
|
389
|
+
for k in self._library_imports:
|
389
390
|
s = k.library_doc.keywords.get(name, None)
|
390
391
|
if s is not None:
|
391
392
|
found.append((k, s))
|
@@ -463,8 +464,8 @@ class KeywordFinder:
|
|
463
464
|
def bdd_prefix_regexp(self) -> "re.Pattern[str]":
|
464
465
|
prefixes = (
|
465
466
|
"|".join(
|
466
|
-
self.
|
467
|
-
if self.
|
467
|
+
self._namespace.languages.bdd_prefixes
|
468
|
+
if self._namespace.languages is not None
|
468
469
|
else ["given", "when", "then", "and", "but"]
|
469
470
|
)
|
470
471
|
.replace(" ", r"\s")
|