robotcode-language-server 2.4.0__py3-none-any.whl → 2.5.1__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/language_server/__version__.py +1 -1
- robotcode/language_server/common/protocol.py +0 -3
- robotcode/language_server/robotframework/parts/code_action_documentation.py +4 -4
- robotcode/language_server/robotframework/parts/code_action_quick_fixes.py +8 -8
- robotcode/language_server/robotframework/parts/code_action_refactor.py +19 -25
- robotcode/language_server/robotframework/parts/code_lens.py +1 -1
- robotcode/language_server/robotframework/parts/completion.py +88 -83
- robotcode/language_server/robotframework/parts/debugging_utils.py +3 -3
- robotcode/language_server/robotframework/parts/diagnostics.py +16 -7
- robotcode/language_server/robotframework/parts/document_highlight.py +3 -3
- robotcode/language_server/robotframework/parts/document_symbols.py +1 -1
- robotcode/language_server/robotframework/parts/folding_range.py +8 -12
- robotcode/language_server/robotframework/parts/formatting.py +2 -45
- robotcode/language_server/robotframework/parts/goto.py +3 -3
- robotcode/language_server/robotframework/parts/hover.py +4 -4
- robotcode/language_server/robotframework/parts/inlay_hint.py +3 -3
- robotcode/language_server/robotframework/parts/inline_value.py +3 -6
- robotcode/language_server/robotframework/parts/keywords_treeview.py +6 -8
- robotcode/language_server/robotframework/parts/references.py +26 -34
- robotcode/language_server/robotframework/parts/rename.py +2 -2
- robotcode/language_server/robotframework/parts/robocop_diagnostics.py +2 -2
- robotcode/language_server/robotframework/parts/selection_range.py +1 -2
- robotcode/language_server/robotframework/parts/semantic_tokens.py +39 -53
- robotcode/language_server/robotframework/parts/signature_help.py +1 -1
- robotcode/language_server/robotframework/parts/workspace_symbols.py +4 -4
- robotcode/language_server/robotframework/protocol.py +4 -3
- {robotcode_language_server-2.4.0.dist-info → robotcode_language_server-2.5.1.dist-info}/METADATA +1 -1
- {robotcode_language_server-2.4.0.dist-info → robotcode_language_server-2.5.1.dist-info}/RECORD +30 -30
- {robotcode_language_server-2.4.0.dist-info → robotcode_language_server-2.5.1.dist-info}/WHEEL +0 -0
- {robotcode_language_server-2.4.0.dist-info → robotcode_language_server-2.5.1.dist-info}/entry_points.txt +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
__version__ = "2.
|
|
1
|
+
__version__ = "2.5.1"
|
|
@@ -67,7 +67,7 @@ class RobotCodeActionDocumentationProtocolPart(RobotLanguageServerProtocolPart,
|
|
|
67
67
|
|
|
68
68
|
namespace = self.parent.documents_cache.get_namespace(document)
|
|
69
69
|
|
|
70
|
-
model = self.parent.documents_cache.get_model(document
|
|
70
|
+
model = self.parent.documents_cache.get_model(document)
|
|
71
71
|
node = get_node_at_position(model, range.start)
|
|
72
72
|
|
|
73
73
|
if context.only and isinstance(node, (LibraryImport, ResourceImport)):
|
|
@@ -115,17 +115,17 @@ class RobotCodeActionDocumentationProtocolPart(RobotLanguageServerProtocolPart,
|
|
|
115
115
|
|
|
116
116
|
if kw_doc.libtype == "LIBRARY":
|
|
117
117
|
entry = next(
|
|
118
|
-
(v for v in
|
|
118
|
+
(v for v in namespace.libraries.values() if v.library_doc == kw_doc.parent),
|
|
119
119
|
None,
|
|
120
120
|
)
|
|
121
121
|
|
|
122
122
|
elif kw_doc.libtype == "RESOURCE":
|
|
123
123
|
entry = next(
|
|
124
|
-
(v for v in
|
|
124
|
+
(v for v in namespace.resources.values() if v.library_doc == kw_doc.parent),
|
|
125
125
|
None,
|
|
126
126
|
)
|
|
127
127
|
|
|
128
|
-
self_libdoc = namespace.
|
|
128
|
+
self_libdoc = namespace.library_doc
|
|
129
129
|
if entry is None and self_libdoc == kw_doc.parent:
|
|
130
130
|
entry = LibraryEntry(
|
|
131
131
|
self_libdoc.name,
|
|
@@ -155,7 +155,7 @@ class RobotCodeActionQuickFixesProtocolPart(RobotLanguageServerProtocolPart, Mod
|
|
|
155
155
|
CodeActionTriggerKind.INVOKED,
|
|
156
156
|
CodeActionTriggerKind.AUTOMATIC,
|
|
157
157
|
]:
|
|
158
|
-
model = self.parent.documents_cache.get_model(document
|
|
158
|
+
model = self.parent.documents_cache.get_model(document)
|
|
159
159
|
namespace = self.parent.documents_cache.get_namespace(document)
|
|
160
160
|
|
|
161
161
|
for diagnostic in (
|
|
@@ -218,7 +218,7 @@ class RobotCodeActionQuickFixesProtocolPart(RobotLanguageServerProtocolPart, Mod
|
|
|
218
218
|
if document is None:
|
|
219
219
|
return None
|
|
220
220
|
|
|
221
|
-
model = self.parent.documents_cache.get_model(document
|
|
221
|
+
model = self.parent.documents_cache.get_model(document)
|
|
222
222
|
node = get_node_at_position(model, data.range.start)
|
|
223
223
|
|
|
224
224
|
if isinstance(node, (KeywordCall, Fixture, TestTemplate, Template)):
|
|
@@ -282,7 +282,7 @@ class RobotCodeActionQuickFixesProtocolPart(RobotLanguageServerProtocolPart, Mod
|
|
|
282
282
|
return None
|
|
283
283
|
|
|
284
284
|
def _apply_create_keyword(self, document: TextDocument, insert_text: str) -> Tuple[WorkspaceEdit, Range]:
|
|
285
|
-
model = self.parent.documents_cache.get_model(document
|
|
285
|
+
model = self.parent.documents_cache.get_model(document)
|
|
286
286
|
namespace = self.parent.documents_cache.get_namespace(document)
|
|
287
287
|
|
|
288
288
|
insert_text, insert_range = self.create_insert_keyword_workspace_edit(document, model, namespace, insert_text)
|
|
@@ -406,7 +406,7 @@ class RobotCodeActionQuickFixesProtocolPart(RobotLanguageServerProtocolPart, Mod
|
|
|
406
406
|
diagnostic.range.start.line == diagnostic.range.end.line
|
|
407
407
|
and diagnostic.range.start.character < diagnostic.range.end.character
|
|
408
408
|
):
|
|
409
|
-
model = self.parent.documents_cache.get_model(document
|
|
409
|
+
model = self.parent.documents_cache.get_model(document)
|
|
410
410
|
nodes = get_nodes_at_position(model, range.start)
|
|
411
411
|
|
|
412
412
|
if not any(n for n in nodes if isinstance(n, (Keyword, TestCase))):
|
|
@@ -451,7 +451,7 @@ class RobotCodeActionQuickFixesProtocolPart(RobotLanguageServerProtocolPart, Mod
|
|
|
451
451
|
if document is None:
|
|
452
452
|
return None
|
|
453
453
|
|
|
454
|
-
model = self.parent.documents_cache.get_model(document
|
|
454
|
+
model = self.parent.documents_cache.get_model(document)
|
|
455
455
|
nodes = get_nodes_at_position(model, data.range.start)
|
|
456
456
|
|
|
457
457
|
if not any(n for n in nodes if isinstance(n, (Keyword, TestCase))):
|
|
@@ -554,7 +554,7 @@ class RobotCodeActionQuickFixesProtocolPart(RobotLanguageServerProtocolPart, Mod
|
|
|
554
554
|
if document is None:
|
|
555
555
|
return None
|
|
556
556
|
|
|
557
|
-
model = self.parent.documents_cache.get_model(document
|
|
557
|
+
model = self.parent.documents_cache.get_model(document)
|
|
558
558
|
nodes = get_nodes_at_position(model, data.range.start)
|
|
559
559
|
|
|
560
560
|
node = nodes[-1] if nodes else None
|
|
@@ -679,7 +679,7 @@ class RobotCodeActionQuickFixesProtocolPart(RobotLanguageServerProtocolPart, Mod
|
|
|
679
679
|
if not text:
|
|
680
680
|
continue
|
|
681
681
|
|
|
682
|
-
model = self.parent.documents_cache.get_model(document
|
|
682
|
+
model = self.parent.documents_cache.get_model(document)
|
|
683
683
|
nodes = get_nodes_at_position(model, range.start)
|
|
684
684
|
|
|
685
685
|
if not any(n for n in nodes if isinstance(n, Keyword)):
|
|
@@ -713,7 +713,7 @@ class RobotCodeActionQuickFixesProtocolPart(RobotLanguageServerProtocolPart, Mod
|
|
|
713
713
|
if not text:
|
|
714
714
|
return None
|
|
715
715
|
|
|
716
|
-
model = self.parent.documents_cache.get_model(document
|
|
716
|
+
model = self.parent.documents_cache.get_model(document)
|
|
717
717
|
nodes = get_nodes_at_position(model, data.range.start)
|
|
718
718
|
|
|
719
719
|
keyword = next((n for n in nodes if isinstance(n, Keyword)), None)
|
|
@@ -27,7 +27,6 @@ from robotcode.core.utils.dataclasses import as_dict, from_dict
|
|
|
27
27
|
from robotcode.core.utils.inspect import iter_methods
|
|
28
28
|
from robotcode.core.utils.logging import LoggingDescriptor
|
|
29
29
|
from robotcode.robot.diagnostics.model_helper import ModelHelper
|
|
30
|
-
from robotcode.robot.utils import get_robot_version
|
|
31
30
|
from robotcode.robot.utils.ast import (
|
|
32
31
|
get_node_at_position,
|
|
33
32
|
get_nodes_at_position,
|
|
@@ -152,36 +151,31 @@ class RobotCodeActionRefactorProtocolPart(RobotLanguageServerProtocolPart, Model
|
|
|
152
151
|
|
|
153
152
|
def get_valid_nodes_in_range(self, model: ast.AST, range: Range, also_return: bool = False) -> List[ast.AST]:
|
|
154
153
|
from robot.parsing.lexer.tokens import Token as RobotToken
|
|
155
|
-
from robot.parsing.model.blocks import Block, Keyword, TestCase
|
|
154
|
+
from robot.parsing.model.blocks import Block, Keyword, TestCase, Try
|
|
156
155
|
from robot.parsing.model.statements import (
|
|
156
|
+
Break,
|
|
157
157
|
Comment,
|
|
158
|
+
Continue,
|
|
158
159
|
Documentation,
|
|
159
160
|
ElseHeader,
|
|
160
161
|
ElseIfHeader,
|
|
161
162
|
EmptyLine,
|
|
162
163
|
End,
|
|
164
|
+
ExceptHeader,
|
|
165
|
+
FinallyHeader,
|
|
163
166
|
Fixture,
|
|
164
167
|
ForHeader,
|
|
165
168
|
IfHeader,
|
|
166
169
|
KeywordName,
|
|
167
170
|
MultiValue,
|
|
171
|
+
ReturnStatement,
|
|
168
172
|
SingleValue,
|
|
169
173
|
TemplateArguments,
|
|
170
174
|
TestCaseName,
|
|
175
|
+
TryHeader,
|
|
176
|
+
WhileHeader,
|
|
171
177
|
)
|
|
172
178
|
|
|
173
|
-
if get_robot_version() >= (5, 0, 0):
|
|
174
|
-
from robot.parsing.model.blocks import Try
|
|
175
|
-
from robot.parsing.model.statements import (
|
|
176
|
-
Break,
|
|
177
|
-
Continue,
|
|
178
|
-
ExceptHeader,
|
|
179
|
-
FinallyHeader,
|
|
180
|
-
ReturnStatement,
|
|
181
|
-
TryHeader,
|
|
182
|
-
WhileHeader,
|
|
183
|
-
)
|
|
184
|
-
|
|
185
179
|
if not isinstance(model, (Keyword, TestCase)):
|
|
186
180
|
return []
|
|
187
181
|
|
|
@@ -205,7 +199,7 @@ class RobotCodeActionRefactorProtocolPart(RobotLanguageServerProtocolPart, Model
|
|
|
205
199
|
KeywordName,
|
|
206
200
|
TemplateArguments,
|
|
207
201
|
),
|
|
208
|
-
) or (also_return and
|
|
202
|
+
) or (also_return and isinstance(node, ReturnStatement)):
|
|
209
203
|
return []
|
|
210
204
|
|
|
211
205
|
result.append(node)
|
|
@@ -241,11 +235,11 @@ class RobotCodeActionRefactorProtocolPart(RobotLanguageServerProtocolPart, Model
|
|
|
241
235
|
n
|
|
242
236
|
for n in result
|
|
243
237
|
if isinstance(n, (IfHeader, ElseIfHeader, ElseHeader, ForHeader, End))
|
|
244
|
-
or
|
|
238
|
+
or isinstance(n, (WhileHeader, TryHeader, ExceptHeader, FinallyHeader))
|
|
245
239
|
):
|
|
246
240
|
return []
|
|
247
241
|
|
|
248
|
-
if
|
|
242
|
+
if any(
|
|
249
243
|
n
|
|
250
244
|
for n in result
|
|
251
245
|
if isinstance(n, (Continue, Break))
|
|
@@ -267,7 +261,7 @@ class RobotCodeActionRefactorProtocolPart(RobotLanguageServerProtocolPart, Model
|
|
|
267
261
|
if range.start == range.end:
|
|
268
262
|
return None
|
|
269
263
|
|
|
270
|
-
model = self.parent.documents_cache.get_model(document
|
|
264
|
+
model = self.parent.documents_cache.get_model(document)
|
|
271
265
|
start_nodes = get_nodes_at_position(model, range.start)
|
|
272
266
|
|
|
273
267
|
enabled = False
|
|
@@ -427,7 +421,7 @@ class RobotCodeActionRefactorProtocolPart(RobotLanguageServerProtocolPart, Model
|
|
|
427
421
|
(context.only and CodeActionKind.REFACTOR_EXTRACT in context.only)
|
|
428
422
|
or context.trigger_kind in [CodeActionTriggerKind.INVOKED, CodeActionTriggerKind.AUTOMATIC]
|
|
429
423
|
):
|
|
430
|
-
model = self.parent.documents_cache.get_model(document
|
|
424
|
+
model = self.parent.documents_cache.get_model(document)
|
|
431
425
|
node = get_node_at_position(model, range.start)
|
|
432
426
|
|
|
433
427
|
if not isinstance(node, KeywordCall) or node.assign:
|
|
@@ -480,7 +474,7 @@ class RobotCodeActionRefactorProtocolPart(RobotLanguageServerProtocolPart, Model
|
|
|
480
474
|
if document is None:
|
|
481
475
|
return None
|
|
482
476
|
|
|
483
|
-
model = self.parent.documents_cache.get_model(document
|
|
477
|
+
model = self.parent.documents_cache.get_model(document)
|
|
484
478
|
nodes = get_nodes_at_position(model, range.start)
|
|
485
479
|
if not nodes:
|
|
486
480
|
return None
|
|
@@ -502,7 +496,7 @@ class RobotCodeActionRefactorProtocolPart(RobotLanguageServerProtocolPart, Model
|
|
|
502
496
|
counter = 0
|
|
503
497
|
namespace = self.parent.documents_cache.get_namespace(document)
|
|
504
498
|
while True:
|
|
505
|
-
if namespace.find_variable(f"${{{var_name}}}",
|
|
499
|
+
if namespace.find_variable(f"${{{var_name}}}", range.start) is None:
|
|
506
500
|
break
|
|
507
501
|
counter += 1
|
|
508
502
|
var_name = f"new_variable_{counter}"
|
|
@@ -544,7 +538,7 @@ class RobotCodeActionRefactorProtocolPart(RobotLanguageServerProtocolPart, Model
|
|
|
544
538
|
if range.start == range.end:
|
|
545
539
|
return None
|
|
546
540
|
|
|
547
|
-
model = self.parent.documents_cache.get_model(document
|
|
541
|
+
model = self.parent.documents_cache.get_model(document)
|
|
548
542
|
start_nodes = get_nodes_at_position(model, range.start)
|
|
549
543
|
|
|
550
544
|
enabled = False
|
|
@@ -595,7 +589,7 @@ class RobotCodeActionRefactorProtocolPart(RobotLanguageServerProtocolPart, Model
|
|
|
595
589
|
lines = document.get_lines()
|
|
596
590
|
spaces = "".join(itertools.takewhile(str.isspace, lines[data.range.start.line]))
|
|
597
591
|
|
|
598
|
-
model = self.parent.documents_cache.get_model(document
|
|
592
|
+
model = self.parent.documents_cache.get_model(document)
|
|
599
593
|
namespace = self.parent.documents_cache.get_namespace(document)
|
|
600
594
|
|
|
601
595
|
orig_keyword_name = "New Keyword"
|
|
@@ -619,8 +613,8 @@ class RobotCodeActionRefactorProtocolPart(RobotLanguageServerProtocolPart, Model
|
|
|
619
613
|
if block is None:
|
|
620
614
|
return None
|
|
621
615
|
|
|
622
|
-
variable_references = namespace.
|
|
623
|
-
local_variable_assignments = namespace.
|
|
616
|
+
variable_references = namespace.variable_references
|
|
617
|
+
local_variable_assignments = namespace.local_variable_assignments
|
|
624
618
|
|
|
625
619
|
block_range = range_from_node(block, skip_non_data=True, allow_comments=True)
|
|
626
620
|
argument_variables = {
|
|
@@ -73,7 +73,7 @@ class RobotCodeLensProtocolPart(RobotLanguageServerProtocolPart, ModelHelper):
|
|
|
73
73
|
line = code_lens.data["line"]
|
|
74
74
|
|
|
75
75
|
if self.parent.diagnostics.workspace_loaded_event.is_set():
|
|
76
|
-
kw_doc = self.get_keyword_definition_at_line(namespace.
|
|
76
|
+
kw_doc = self.get_keyword_definition_at_line(namespace.library_doc, line)
|
|
77
77
|
|
|
78
78
|
if kw_doc is not None and not kw_doc.is_error_handler:
|
|
79
79
|
if not self.parent.robot_references.has_cached_keyword_references(
|
|
@@ -71,7 +71,7 @@ from robotcode.robot.diagnostics.library_doc import (
|
|
|
71
71
|
)
|
|
72
72
|
from robotcode.robot.diagnostics.model_helper import ModelHelper
|
|
73
73
|
from robotcode.robot.diagnostics.namespace import DocumentType, Namespace
|
|
74
|
-
from robotcode.robot.utils import
|
|
74
|
+
from robotcode.robot.utils import RF_VERSION
|
|
75
75
|
from robotcode.robot.utils.ast import (
|
|
76
76
|
get_nodes_at_position,
|
|
77
77
|
get_tokens_at_position,
|
|
@@ -85,7 +85,7 @@ from ...common.decorators import trigger_characters
|
|
|
85
85
|
from ..configuration import CompletionConfig
|
|
86
86
|
from .protocol_part import RobotLanguageServerProtocolPart
|
|
87
87
|
|
|
88
|
-
if
|
|
88
|
+
if RF_VERSION >= (6, 1):
|
|
89
89
|
from robot.parsing.lexer.settings import SuiteFileSettings
|
|
90
90
|
else:
|
|
91
91
|
from robot.parsing.lexer.settings import (
|
|
@@ -95,27 +95,19 @@ else:
|
|
|
95
95
|
if TYPE_CHECKING:
|
|
96
96
|
from ..protocol import RobotLanguageServerProtocol
|
|
97
97
|
|
|
98
|
-
if
|
|
98
|
+
if RF_VERSION < (7, 0):
|
|
99
99
|
from robot.variables.search import VariableIterator
|
|
100
100
|
else:
|
|
101
101
|
from robot.variables.search import VariableMatches
|
|
102
102
|
|
|
103
103
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
else:
|
|
112
|
-
ALLOWED_VARIABLE_TOKENS = [
|
|
113
|
-
Token.NAME,
|
|
114
|
-
Token.ARGUMENT,
|
|
115
|
-
Token.KEYWORD,
|
|
116
|
-
Token.ASSIGN,
|
|
117
|
-
Token.OPTION,
|
|
118
|
-
]
|
|
104
|
+
ALLOWED_VARIABLE_TOKENS = [
|
|
105
|
+
Token.NAME,
|
|
106
|
+
Token.ARGUMENT,
|
|
107
|
+
Token.KEYWORD,
|
|
108
|
+
Token.ASSIGN,
|
|
109
|
+
Token.OPTION,
|
|
110
|
+
]
|
|
119
111
|
|
|
120
112
|
|
|
121
113
|
DEFAULT_HEADER_STYLE = "*** {name}s ***"
|
|
@@ -141,7 +133,7 @@ class RobotCompletionProtocolPart(RobotLanguageServerProtocolPart):
|
|
|
141
133
|
if config.header_style is not None:
|
|
142
134
|
return config.header_style
|
|
143
135
|
|
|
144
|
-
return DEFAULT_HEADER_STYLE if
|
|
136
|
+
return DEFAULT_HEADER_STYLE if RF_VERSION < (6, 0) else DEFAULT_HEADER_STYLE_51
|
|
145
137
|
|
|
146
138
|
@language_id("robotframework")
|
|
147
139
|
@trigger_characters(
|
|
@@ -168,7 +160,7 @@ class RobotCompletionProtocolPart(RobotLanguageServerProtocolPart):
|
|
|
168
160
|
context: Optional[CompletionContext],
|
|
169
161
|
) -> Union[List[CompletionItem], CompletionList, None]:
|
|
170
162
|
namespace = self.parent.documents_cache.get_initialized_namespace(document)
|
|
171
|
-
model = self.parent.documents_cache.get_model(document
|
|
163
|
+
model = self.parent.documents_cache.get_model(document)
|
|
172
164
|
|
|
173
165
|
config = self.get_config(document)
|
|
174
166
|
self.doc_cache = {}
|
|
@@ -190,7 +182,7 @@ class RobotCompletionProtocolPart(RobotLanguageServerProtocolPart):
|
|
|
190
182
|
document = self.parent.documents.get(document_uri)
|
|
191
183
|
if document is not None:
|
|
192
184
|
namespace = self.parent.documents_cache.get_initialized_namespace(document)
|
|
193
|
-
model = self.parent.documents_cache.get_model(document
|
|
185
|
+
model = self.parent.documents_cache.get_model(document)
|
|
194
186
|
if namespace is not None:
|
|
195
187
|
config = self.get_config(document)
|
|
196
188
|
|
|
@@ -231,29 +223,28 @@ def get_snippets() -> Dict[str, List[str]]:
|
|
|
231
223
|
"IF": [r"IF \${${1}}", " $0", "END", ""],
|
|
232
224
|
}
|
|
233
225
|
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
"
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
"
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
if get_robot_version() >= (7, 0):
|
|
226
|
+
__snippets.update(
|
|
227
|
+
{
|
|
228
|
+
"TRYEX": [
|
|
229
|
+
"TRY",
|
|
230
|
+
" $0",
|
|
231
|
+
r"EXCEPT message",
|
|
232
|
+
" ",
|
|
233
|
+
"END",
|
|
234
|
+
"",
|
|
235
|
+
],
|
|
236
|
+
"TRYEXAS": [
|
|
237
|
+
"TRY",
|
|
238
|
+
" $0",
|
|
239
|
+
r"EXCEPT message AS \${ex}",
|
|
240
|
+
" ",
|
|
241
|
+
"END",
|
|
242
|
+
"",
|
|
243
|
+
],
|
|
244
|
+
"WHILE": [r"WHILE ${1:expression}", " $0", "END", ""],
|
|
245
|
+
}
|
|
246
|
+
)
|
|
247
|
+
if RF_VERSION >= (7, 0):
|
|
257
248
|
__snippets.update(
|
|
258
249
|
{
|
|
259
250
|
"VAR ${}": [r"VAR \${${1}} ${0}"],
|
|
@@ -262,7 +253,7 @@ def get_snippets() -> Dict[str, List[str]]:
|
|
|
262
253
|
}
|
|
263
254
|
)
|
|
264
255
|
|
|
265
|
-
if
|
|
256
|
+
if RF_VERSION >= (7, 2):
|
|
266
257
|
__snippets.update(
|
|
267
258
|
{
|
|
268
259
|
"GROUP": [
|
|
@@ -283,23 +274,25 @@ def get_reserved_keywords() -> List[str]:
|
|
|
283
274
|
global __reserved_keywords
|
|
284
275
|
|
|
285
276
|
if __reserved_keywords is None:
|
|
286
|
-
__reserved_keywords = [
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
277
|
+
__reserved_keywords = [
|
|
278
|
+
"FOR",
|
|
279
|
+
"END",
|
|
280
|
+
"IF",
|
|
281
|
+
"ELSE",
|
|
282
|
+
"ELSE IF",
|
|
283
|
+
"TRY",
|
|
284
|
+
"EXCEPT",
|
|
285
|
+
"FINALLY",
|
|
286
|
+
"WHILE",
|
|
287
|
+
"BREAK",
|
|
288
|
+
"CONTINUE",
|
|
289
|
+
"RETURN",
|
|
290
|
+
]
|
|
298
291
|
|
|
299
|
-
if
|
|
292
|
+
if RF_VERSION >= (7, 0):
|
|
300
293
|
__reserved_keywords += ["VAR"]
|
|
301
294
|
|
|
302
|
-
if
|
|
295
|
+
if RF_VERSION >= (7, 2):
|
|
303
296
|
__reserved_keywords += ["GROUP"]
|
|
304
297
|
|
|
305
298
|
__reserved_keywords = sorted(__reserved_keywords)
|
|
@@ -419,7 +412,7 @@ class CompletionCollector(ModelHelper):
|
|
|
419
412
|
lib_doc = next(
|
|
420
413
|
(
|
|
421
414
|
ld.library_doc
|
|
422
|
-
for ld in
|
|
415
|
+
for ld in self.namespace.libraries.values()
|
|
423
416
|
if str(id(ld.library_doc)) == lib_id
|
|
424
417
|
),
|
|
425
418
|
None,
|
|
@@ -467,7 +460,7 @@ class CompletionCollector(ModelHelper):
|
|
|
467
460
|
lib_doc = next(
|
|
468
461
|
(
|
|
469
462
|
ld.library_doc
|
|
470
|
-
for ld in
|
|
463
|
+
for ld in self.namespace.resources.values()
|
|
471
464
|
if str(id(ld.library_doc)) == res_id
|
|
472
465
|
),
|
|
473
466
|
None,
|
|
@@ -493,7 +486,7 @@ class CompletionCollector(ModelHelper):
|
|
|
493
486
|
|
|
494
487
|
elif (name := data.get("name", None)) is not None:
|
|
495
488
|
try:
|
|
496
|
-
lib_doc = self.namespace.imports_manager.
|
|
489
|
+
lib_doc = self.namespace.imports_manager.get_resource_doc_for_resource_import(
|
|
497
490
|
name,
|
|
498
491
|
str(document.uri.to_path().parent),
|
|
499
492
|
variables=self.namespace.get_resolvable_variables(),
|
|
@@ -514,7 +507,7 @@ class CompletionCollector(ModelHelper):
|
|
|
514
507
|
if kw_id is not None:
|
|
515
508
|
try:
|
|
516
509
|
kw_doc = next(
|
|
517
|
-
(kw for kw in self.namespace.
|
|
510
|
+
(kw for kw in self.namespace.keywords if str(id(kw)) == kw_id),
|
|
518
511
|
None,
|
|
519
512
|
)
|
|
520
513
|
|
|
@@ -623,7 +616,7 @@ class CompletionCollector(ModelHelper):
|
|
|
623
616
|
text_edit=TextEdit(range=range, new_text=s.name[2:-1]),
|
|
624
617
|
filter_text=s.name[2:-1] if range is not None else None,
|
|
625
618
|
)
|
|
626
|
-
for s in (self.namespace.get_variable_matchers(
|
|
619
|
+
for s in (self.namespace.get_variable_matchers(position)).values()
|
|
627
620
|
if s.name is not None and (s.name_token is None or not position.is_in_range(range_from_token(s.name_token)))
|
|
628
621
|
]
|
|
629
622
|
|
|
@@ -774,7 +767,7 @@ class CompletionCollector(ModelHelper):
|
|
|
774
767
|
if not kw.is_embedded:
|
|
775
768
|
return kw.name
|
|
776
769
|
|
|
777
|
-
if
|
|
770
|
+
if RF_VERSION < (7, 0):
|
|
778
771
|
for index, (before, variable, after) in enumerate(
|
|
779
772
|
VariableIterator(kw.name, identifiers="$", ignore_errors=True)
|
|
780
773
|
):
|
|
@@ -881,7 +874,7 @@ class CompletionCollector(ModelHelper):
|
|
|
881
874
|
if lib_name_index >= 0:
|
|
882
875
|
namespace_name = token.value[0 : lib_name_index - r.start.character]
|
|
883
876
|
|
|
884
|
-
libraries = self.namespace.
|
|
877
|
+
libraries = self.namespace.libraries
|
|
885
878
|
|
|
886
879
|
namespace_matcher = KeywordMatcher(namespace_name, is_namespace=True)
|
|
887
880
|
namespace_name = next(
|
|
@@ -931,7 +924,7 @@ class CompletionCollector(ModelHelper):
|
|
|
931
924
|
|
|
932
925
|
resources = {
|
|
933
926
|
k: v
|
|
934
|
-
for k, v in self.namespace.
|
|
927
|
+
for k, v in self.namespace.resources.items()
|
|
935
928
|
if namespace_matcher == KeywordMatcher(v.name, is_namespace=True)
|
|
936
929
|
}
|
|
937
930
|
|
|
@@ -983,7 +976,7 @@ class CompletionCollector(ModelHelper):
|
|
|
983
976
|
if namespace_matcher is not None:
|
|
984
977
|
namespace_matcher = KeywordMatcher(namespace_matcher.name)
|
|
985
978
|
|
|
986
|
-
for kw in self.namespace.
|
|
979
|
+
for kw in self.namespace.keywords:
|
|
987
980
|
if kw.is_error_handler:
|
|
988
981
|
continue
|
|
989
982
|
if (
|
|
@@ -1019,7 +1012,7 @@ class CompletionCollector(ModelHelper):
|
|
|
1019
1012
|
if valid_namespace and namespace_matcher is not None:
|
|
1020
1013
|
return result
|
|
1021
1014
|
|
|
1022
|
-
for k, v in
|
|
1015
|
+
for k, v in self.namespace.libraries.items():
|
|
1023
1016
|
result.append(
|
|
1024
1017
|
CompletionItem(
|
|
1025
1018
|
label=k,
|
|
@@ -1042,7 +1035,7 @@ class CompletionCollector(ModelHelper):
|
|
|
1042
1035
|
)
|
|
1043
1036
|
)
|
|
1044
1037
|
|
|
1045
|
-
for k, v in self.namespace.
|
|
1038
|
+
for k, v in self.namespace.resources.items():
|
|
1046
1039
|
result.append(
|
|
1047
1040
|
CompletionItem(
|
|
1048
1041
|
label=v.name,
|
|
@@ -1705,7 +1698,7 @@ class CompletionCollector(ModelHelper):
|
|
|
1705
1698
|
complete_list = self.namespace.imports_manager.complete_library_import(
|
|
1706
1699
|
first_part if first_part else None,
|
|
1707
1700
|
str(self.document.uri.to_path().parent),
|
|
1708
|
-
self.namespace.get_resolvable_variables(
|
|
1701
|
+
self.namespace.get_resolvable_variables(position),
|
|
1709
1702
|
)
|
|
1710
1703
|
if not complete_list:
|
|
1711
1704
|
return None
|
|
@@ -1816,7 +1809,7 @@ class CompletionCollector(ModelHelper):
|
|
|
1816
1809
|
):
|
|
1817
1810
|
return [
|
|
1818
1811
|
CompletionItem(
|
|
1819
|
-
label="AS" if
|
|
1812
|
+
label="AS" if RF_VERSION >= (6, 0) else "WITH NAME",
|
|
1820
1813
|
kind=CompletionItemKind.KEYWORD,
|
|
1821
1814
|
# detail=e.detail,
|
|
1822
1815
|
sort_text="99_NAMESPACE_MARKER",
|
|
@@ -1907,7 +1900,7 @@ class CompletionCollector(ModelHelper):
|
|
|
1907
1900
|
complete_list = self.namespace.imports_manager.complete_resource_import(
|
|
1908
1901
|
first_part if first_part else None,
|
|
1909
1902
|
str(self.document.uri.to_path().parent),
|
|
1910
|
-
self.namespace.get_resolvable_variables(
|
|
1903
|
+
self.namespace.get_resolvable_variables(position),
|
|
1911
1904
|
)
|
|
1912
1905
|
if not complete_list:
|
|
1913
1906
|
return None
|
|
@@ -2031,7 +2024,7 @@ class CompletionCollector(ModelHelper):
|
|
|
2031
2024
|
complete_list = self.namespace.imports_manager.complete_variables_import(
|
|
2032
2025
|
first_part if first_part else None,
|
|
2033
2026
|
str(self.document.uri.to_path().parent),
|
|
2034
|
-
self.namespace.get_resolvable_variables(
|
|
2027
|
+
self.namespace.get_resolvable_variables(position),
|
|
2035
2028
|
)
|
|
2036
2029
|
if not complete_list:
|
|
2037
2030
|
return None
|
|
@@ -2270,7 +2263,7 @@ class CompletionCollector(ModelHelper):
|
|
|
2270
2263
|
type_infos = keyword_doc.parent.get_types(kw_arguments[argument_index].types)
|
|
2271
2264
|
for i, type_info in enumerate(type_infos):
|
|
2272
2265
|
if type_info.name == "boolean":
|
|
2273
|
-
if
|
|
2266
|
+
if RF_VERSION >= (6, 0) and self.namespace.languages:
|
|
2274
2267
|
languages = self.namespace.languages.languages
|
|
2275
2268
|
|
|
2276
2269
|
if self.config.filter_default_language:
|
|
@@ -2400,6 +2393,20 @@ class CompletionCollector(ModelHelper):
|
|
|
2400
2393
|
)
|
|
2401
2394
|
)
|
|
2402
2395
|
|
|
2396
|
+
argument = kw_arguments[argument_index]
|
|
2397
|
+
if argument.literal_values:
|
|
2398
|
+
for literal_index, literal_value in enumerate(argument.literal_values):
|
|
2399
|
+
result.append(
|
|
2400
|
+
CompletionItem(
|
|
2401
|
+
label=literal_value,
|
|
2402
|
+
kind=CompletionItemKind.ENUM_MEMBER,
|
|
2403
|
+
detail="Literal",
|
|
2404
|
+
sort_text=f"09_{literal_index:09}_{literal_value}",
|
|
2405
|
+
insert_text_format=InsertTextFormat.PLAIN_TEXT,
|
|
2406
|
+
text_edit=TextEdit(range=completion_range, new_text=literal_value),
|
|
2407
|
+
)
|
|
2408
|
+
)
|
|
2409
|
+
|
|
2403
2410
|
if complete_argument_names:
|
|
2404
2411
|
known_names = []
|
|
2405
2412
|
|
|
@@ -2495,19 +2502,17 @@ class CompletionCollector(ModelHelper):
|
|
|
2495
2502
|
"robot:stop-on-failure",
|
|
2496
2503
|
"robot:no-dry-run",
|
|
2497
2504
|
"robot:exit",
|
|
2505
|
+
"robot:skip",
|
|
2506
|
+
"robot:skip-on-failure",
|
|
2507
|
+
"robot:exclude",
|
|
2508
|
+
"robot:recursive-continue-on-failure",
|
|
2498
2509
|
}
|
|
2499
2510
|
|
|
2500
|
-
if
|
|
2501
|
-
built_in_tags.add("robot:skip")
|
|
2502
|
-
built_in_tags.add("robot:skip-on-failure")
|
|
2503
|
-
built_in_tags.add("robot:exclude")
|
|
2504
|
-
built_in_tags.add("robot:recursive-continue-on-failure")
|
|
2505
|
-
|
|
2506
|
-
if get_robot_version() >= (6, 0):
|
|
2511
|
+
if RF_VERSION >= (6, 0):
|
|
2507
2512
|
built_in_tags.add("robot:recursive-stop-on-failure")
|
|
2508
2513
|
built_in_tags.add("robot:private")
|
|
2509
2514
|
|
|
2510
|
-
if
|
|
2515
|
+
if RF_VERSION >= (6, 1):
|
|
2511
2516
|
built_in_tags.add("robot:flatten")
|
|
2512
2517
|
|
|
2513
2518
|
return [
|
|
@@ -56,7 +56,7 @@ class RobotDebuggingUtilsProtocolPart(RobotLanguageServerProtocolPart, ModelHelp
|
|
|
56
56
|
return None
|
|
57
57
|
|
|
58
58
|
namespace = self.parent.documents_cache.get_namespace(document)
|
|
59
|
-
model = self.parent.documents_cache.get_model(document
|
|
59
|
+
model = self.parent.documents_cache.get_model(document)
|
|
60
60
|
|
|
61
61
|
nodes = get_nodes_at_position(model, position)
|
|
62
62
|
node = nodes[-1]
|
|
@@ -69,7 +69,7 @@ class RobotDebuggingUtilsProtocolPart(RobotLanguageServerProtocolPart, ModelHelp
|
|
|
69
69
|
token_and_var = next(
|
|
70
70
|
(
|
|
71
71
|
(t, v)
|
|
72
|
-
for t, v in self.iter_variables_from_token(token, namespace,
|
|
72
|
+
for t, v in self.iter_variables_from_token(token, namespace, position)
|
|
73
73
|
if position in range_from_token(t)
|
|
74
74
|
),
|
|
75
75
|
None,
|
|
@@ -84,7 +84,7 @@ class RobotDebuggingUtilsProtocolPart(RobotLanguageServerProtocolPart, ModelHelp
|
|
|
84
84
|
token_and_var = next(
|
|
85
85
|
(
|
|
86
86
|
(var_token, var)
|
|
87
|
-
for var_token, var in self.iter_expression_variables_from_token(token, namespace,
|
|
87
|
+
for var_token, var in self.iter_expression_variables_from_token(token, namespace, position)
|
|
88
88
|
if position in range_from_token(var_token)
|
|
89
89
|
),
|
|
90
90
|
None,
|