robotcode-robot 0.93.1__tar.gz → 0.95.0__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.
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/PKG-INFO +2 -2
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/pyproject.toml +1 -1
- robotcode_robot-0.95.0/src/robotcode/robot/__version__.py +1 -0
- robotcode_robot-0.95.0/src/robotcode/robot/diagnostics/data_cache.py +83 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/diagnostics/document_cache_helper.py +11 -6
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/diagnostics/entities.py +3 -3
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/diagnostics/errors.py +7 -2
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/diagnostics/imports_manager.py +176 -135
- robotcode_robot-0.95.0/src/robotcode/robot/diagnostics/keyword_finder.py +485 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/diagnostics/library_doc.py +178 -112
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/diagnostics/model_helper.py +49 -30
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/diagnostics/namespace.py +159 -580
- robotcode_robot-0.95.0/src/robotcode/robot/diagnostics/namespace_analyzer.py +1802 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/utils/markdownformatter.py +8 -11
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/utils/match.py +2 -2
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/utils/robot_path.py +14 -15
- robotcode_robot-0.95.0/src/robotcode/robot/utils/variables.py +72 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/utils/visitor.py +7 -13
- robotcode_robot-0.93.1/src/robotcode/robot/__version__.py +0 -1
- robotcode_robot-0.93.1/src/robotcode/robot/diagnostics/namespace_analyzer.py +0 -1235
- robotcode_robot-0.93.1/src/robotcode/robot/utils/variables.py +0 -37
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/.gitignore +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/LICENSE.txt +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/README.md +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/__init__.py +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/config/__init__.py +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/config/loader.py +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/config/model.py +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/config/utils.py +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/diagnostics/__init__.py +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/diagnostics/diagnostics_modifier.py +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/diagnostics/workspace_config.py +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/py.typed +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/utils/__init__.py +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/utils/ast.py +0 -0
- {robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/utils/stubs.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: robotcode-robot
|
3
|
-
Version: 0.
|
3
|
+
Version: 0.95.0
|
4
4
|
Summary: Support classes for RobotCode for handling Robot Framework projects.
|
5
5
|
Project-URL: Homepage, https://robotcode.io
|
6
6
|
Project-URL: Donate, https://opencollective.com/robotcode
|
@@ -26,7 +26,7 @@ Classifier: Topic :: Utilities
|
|
26
26
|
Classifier: Typing :: Typed
|
27
27
|
Requires-Python: >=3.8
|
28
28
|
Requires-Dist: platformdirs<4.2.0,>=3.2.0
|
29
|
-
Requires-Dist: robotcode-core==0.
|
29
|
+
Requires-Dist: robotcode-core==0.95.0
|
30
30
|
Requires-Dist: robotframework>=4.1.0
|
31
31
|
Requires-Dist: tomli>=1.1.0; python_version < '3.11'
|
32
32
|
Description-Content-Type: text/markdown
|
@@ -0,0 +1 @@
|
|
1
|
+
__version__ = "0.95.0"
|
@@ -0,0 +1,83 @@
|
|
1
|
+
import pickle
|
2
|
+
from abc import ABC, abstractmethod
|
3
|
+
from enum import Enum
|
4
|
+
from pathlib import Path
|
5
|
+
from typing import Any, Tuple, Type, TypeVar, Union, cast
|
6
|
+
|
7
|
+
from robotcode.core.utils.dataclasses import as_json, from_json
|
8
|
+
|
9
|
+
_T = TypeVar("_T")
|
10
|
+
|
11
|
+
|
12
|
+
class CacheSection(Enum):
|
13
|
+
LIBRARY = "libdoc"
|
14
|
+
VARIABLES = "variables"
|
15
|
+
|
16
|
+
|
17
|
+
class DataCache(ABC):
|
18
|
+
@abstractmethod
|
19
|
+
def cache_data_exists(self, section: CacheSection, entry_name: str) -> bool: ...
|
20
|
+
|
21
|
+
@abstractmethod
|
22
|
+
def read_cache_data(
|
23
|
+
self, section: CacheSection, entry_name: str, types: Union[Type[_T], Tuple[Type[_T], ...]]
|
24
|
+
) -> _T: ...
|
25
|
+
|
26
|
+
@abstractmethod
|
27
|
+
def save_cache_data(self, section: CacheSection, entry_name: str, data: Any) -> None: ...
|
28
|
+
|
29
|
+
|
30
|
+
class JsonDataCache(DataCache):
|
31
|
+
def __init__(self, cache_dir: Path) -> None:
|
32
|
+
self.cache_dir = cache_dir
|
33
|
+
|
34
|
+
def build_cache_data_filename(self, section: CacheSection, entry_name: str) -> Path:
|
35
|
+
return self.cache_dir / section.value / (entry_name + ".json")
|
36
|
+
|
37
|
+
def cache_data_exists(self, section: CacheSection, entry_name: str) -> bool:
|
38
|
+
cache_file = self.build_cache_data_filename(section, entry_name)
|
39
|
+
return cache_file.exists()
|
40
|
+
|
41
|
+
def read_cache_data(
|
42
|
+
self, section: CacheSection, entry_name: str, types: Union[Type[_T], Tuple[Type[_T], ...]]
|
43
|
+
) -> _T:
|
44
|
+
cache_file = self.build_cache_data_filename(section, entry_name)
|
45
|
+
return from_json(cache_file.read_text("utf-8"), types)
|
46
|
+
|
47
|
+
def save_cache_data(self, section: CacheSection, entry_name: str, data: Any) -> None:
|
48
|
+
cached_file = self.build_cache_data_filename(section, entry_name)
|
49
|
+
|
50
|
+
cached_file.parent.mkdir(parents=True, exist_ok=True)
|
51
|
+
cached_file.write_text(as_json(data), "utf-8")
|
52
|
+
|
53
|
+
|
54
|
+
class PickleDataCache(DataCache):
|
55
|
+
def __init__(self, cache_dir: Path) -> None:
|
56
|
+
self.cache_dir = cache_dir
|
57
|
+
|
58
|
+
def build_cache_data_filename(self, section: CacheSection, entry_name: str) -> Path:
|
59
|
+
return self.cache_dir / section.value / (entry_name + ".pkl")
|
60
|
+
|
61
|
+
def cache_data_exists(self, section: CacheSection, entry_name: str) -> bool:
|
62
|
+
cache_file = self.build_cache_data_filename(section, entry_name)
|
63
|
+
return cache_file.exists()
|
64
|
+
|
65
|
+
def read_cache_data(
|
66
|
+
self, section: CacheSection, entry_name: str, types: Union[Type[_T], Tuple[Type[_T], ...]]
|
67
|
+
) -> _T:
|
68
|
+
cache_file = self.build_cache_data_filename(section, entry_name)
|
69
|
+
|
70
|
+
with cache_file.open("rb") as f:
|
71
|
+
result = pickle.load(f)
|
72
|
+
|
73
|
+
if isinstance(result, types):
|
74
|
+
return cast(_T, result)
|
75
|
+
|
76
|
+
raise TypeError(f"Expected {types} but got {type(result)}")
|
77
|
+
|
78
|
+
def save_cache_data(self, section: CacheSection, entry_name: str, data: Any) -> None:
|
79
|
+
cached_file = self.build_cache_data_filename(section, entry_name)
|
80
|
+
|
81
|
+
cached_file.parent.mkdir(parents=True, exist_ok=True)
|
82
|
+
with cached_file.open("wb") as f:
|
83
|
+
pickle.dump(data, f)
|
@@ -118,8 +118,7 @@ class DocumentsCacheHelper:
|
|
118
118
|
except ValueError as e:
|
119
119
|
ex = e
|
120
120
|
self._logger.exception(
|
121
|
-
lambda: f"Language configuration is not valid: {ex}"
|
122
|
-
"\nPlease check your 'robotcode.robot.language' configuration.",
|
121
|
+
lambda: f"Language configuration is not valid: {ex}",
|
123
122
|
exc_info=ex,
|
124
123
|
level=CRITICAL,
|
125
124
|
)
|
@@ -410,7 +409,16 @@ class DocumentsCacheHelper:
|
|
410
409
|
return document.get_cache(self.__get_namespace)
|
411
410
|
|
412
411
|
def __get_namespace(self, document: TextDocument) -> Namespace:
|
413
|
-
|
412
|
+
document_type = self.get_document_type(document)
|
413
|
+
|
414
|
+
if document_type == DocumentType.INIT:
|
415
|
+
return self.get_init_namespace(document)
|
416
|
+
if document_type == DocumentType.RESOURCE:
|
417
|
+
return self.get_resource_namespace(document)
|
418
|
+
if document_type == DocumentType.GENERAL:
|
419
|
+
return self.get_general_namespace(document)
|
420
|
+
|
421
|
+
return self.__get_namespace_for_document_type(document, document_type)
|
414
422
|
|
415
423
|
def get_resource_namespace(self, document: TextDocument) -> Namespace:
|
416
424
|
return document.get_cache(self.__get_resource_namespace)
|
@@ -448,9 +456,6 @@ class DocumentsCacheHelper:
|
|
448
456
|
|
449
457
|
def __namespace_initialized(self, sender: Namespace) -> None:
|
450
458
|
if sender.document is not None:
|
451
|
-
self._logger.debug(
|
452
|
-
lambda: f"Save initialized Namespace: {sender.document.uri if sender.document else None}"
|
453
|
-
)
|
454
459
|
sender.document.set_data(self.INITIALIZED_NAMESPACE, sender)
|
455
460
|
self.namespace_initialized(self, sender)
|
456
461
|
|
{robotcode_robot-0.93.1 → robotcode_robot-0.95.0}/src/robotcode/robot/diagnostics/entities.py
RENAMED
@@ -12,11 +12,11 @@ from typing import (
|
|
12
12
|
)
|
13
13
|
|
14
14
|
from robot.parsing.lexer.tokens import Token
|
15
|
-
from robot.variables.search import search_variable
|
16
15
|
from robotcode.core.lsp.types import Position, Range
|
17
16
|
from robotcode.robot.utils.match import normalize
|
18
17
|
|
19
18
|
from ..utils.ast import range_from_token
|
19
|
+
from ..utils.variables import search_variable
|
20
20
|
|
21
21
|
if TYPE_CHECKING:
|
22
22
|
from robotcode.robot.diagnostics.library_doc import KeywordDoc, LibraryDoc
|
@@ -246,7 +246,7 @@ class GlobalVariableDefinition(VariableDefinition):
|
|
246
246
|
|
247
247
|
|
248
248
|
@dataclass
|
249
|
-
class BuiltInVariableDefinition(
|
249
|
+
class BuiltInVariableDefinition(GlobalVariableDefinition):
|
250
250
|
type: VariableDefinitionType = VariableDefinitionType.BUILTIN_VARIABLE
|
251
251
|
resolvable: bool = True
|
252
252
|
|
@@ -266,7 +266,7 @@ class CommandLineVariableDefinition(GlobalVariableDefinition):
|
|
266
266
|
|
267
267
|
|
268
268
|
@dataclass
|
269
|
-
class ArgumentDefinition(
|
269
|
+
class ArgumentDefinition(LocalVariableDefinition):
|
270
270
|
type: VariableDefinitionType = VariableDefinitionType.ARGUMENT
|
271
271
|
keyword_doc: Optional["KeywordDoc"] = field(default=None, compare=False, metadata={"nosave": True})
|
272
272
|
|
@@ -1,12 +1,12 @@
|
|
1
1
|
from typing import final
|
2
2
|
|
3
|
-
DIAGNOSTICS_SOURCE_NAME = "robotcode
|
3
|
+
DIAGNOSTICS_SOURCE_NAME = "robotcode"
|
4
4
|
|
5
5
|
|
6
6
|
@final
|
7
7
|
class Error:
|
8
8
|
VARIABLE_NOT_FOUND = "VariableNotFound"
|
9
|
-
|
9
|
+
ENVIRONMENT_VARIABLE_NOT_FOUND = "EnvironmentVariableNotFound"
|
10
10
|
KEYWORD_NOT_FOUND = "KeywordNotFound"
|
11
11
|
LIBRARY_CONTAINS_NO_KEYWORDS = "LibraryContainsNoKeywords"
|
12
12
|
POSSIBLE_CIRCULAR_IMPORT = "PossibleCircularImport"
|
@@ -35,3 +35,8 @@ class Error:
|
|
35
35
|
CONFLICTING_LIBRARY_KEYWORDS = "ConflictingLibraryKeywords"
|
36
36
|
INVALID_HEADER = "InvalidHeader"
|
37
37
|
DEPRECATED_HEADER = "DeprecatedHeader"
|
38
|
+
OVERRIDDEN_BY_COMMANDLINE = "OverriddenByCommandLine"
|
39
|
+
VARIABLE_ALREADY_DEFINED = "VariableAlreadyDefined"
|
40
|
+
VARIABLE_OVERRIDDEN = "VariableOverridden"
|
41
|
+
MODEL_ERROR = "ModelError"
|
42
|
+
TOKEN_ERROR = "TokenError"
|