File tree Expand file tree Collapse file tree 3 files changed +35
-10
lines changed
language_server/src/robotcode/language_server/robotframework/parts
robot/src/robotcode/robot Expand file tree Collapse file tree 3 files changed +35
-10
lines changed Original file line number Diff line number Diff line change 101
101
from robot .variables .search import VariableMatches
102
102
103
103
104
+ if get_robot_version () < (5 , 0 ):
105
+ ALLOWED_VARIABLE_TOKENS = [
106
+ Token .NAME ,
107
+ Token .ARGUMENT ,
108
+ Token .KEYWORD ,
109
+ Token .ASSIGN ,
110
+ ]
111
+ else :
112
+ ALLOWED_VARIABLE_TOKENS = [
113
+ Token .NAME ,
114
+ Token .ARGUMENT ,
115
+ Token .KEYWORD ,
116
+ Token .ASSIGN ,
117
+ Token .OPTION ,
118
+ ]
119
+
120
+
104
121
DEFAULT_HEADER_STYLE = "*** {name}s ***"
105
122
DEFAULT_HEADER_STYLE_51 = "*** {name} ***"
106
123
@@ -1141,12 +1158,7 @@ def complete_default(
1141
1158
break
1142
1159
token_at_position = tokens_at_position [token_at_position_index ]
1143
1160
1144
- if token_at_position .type not in [
1145
- Token .NAME ,
1146
- Token .ARGUMENT ,
1147
- Token .KEYWORD ,
1148
- Token .ASSIGN ,
1149
- ]:
1161
+ if token_at_position .type not in ALLOWED_VARIABLE_TOKENS :
1150
1162
return None
1151
1163
1152
1164
close_brace_index_before = token_at_position .value .rfind (
Original file line number Diff line number Diff line change @@ -538,7 +538,7 @@ def visit_Var(self, node: Statement) -> None: # noqa: N802
538
538
source = self .namespace .source ,
539
539
)
540
540
541
- if var_name not in self ._results or type (self ._results [var_name ]) is type (var ):
541
+ if var_name not in self ._results or type (self ._results [var_name ]) is not type (var ):
542
542
if isinstance (var , LocalVariableDefinition ) or not any (
543
543
l for l in self .namespace .get_global_variables () if l .matcher == var .matcher
544
544
):
Original file line number Diff line number Diff line change @@ -225,6 +225,21 @@ def _tokenize_no_variables(token: Token) -> Iterator[Token]:
225
225
yield token
226
226
227
227
228
+ if get_robot_version () < (5 , 0 ):
229
+ ALLOWED_TOKEN_TYPES = {
230
+ * Token .ALLOW_VARIABLES ,
231
+ Token .KEYWORD ,
232
+ Token .ASSIGN ,
233
+ }
234
+ else :
235
+ ALLOWED_TOKEN_TYPES = {
236
+ * Token .ALLOW_VARIABLES ,
237
+ Token .KEYWORD ,
238
+ Token .ASSIGN ,
239
+ Token .OPTION ,
240
+ }
241
+
242
+
228
243
def tokenize_variables (
229
244
token : Token ,
230
245
identifiers : str = "$@&%" ,
@@ -233,9 +248,7 @@ def tokenize_variables(
233
248
extra_types : Optional [Set [str ]] = None ,
234
249
) -> Iterator [Token ]:
235
250
if token .type not in {
236
- * Token .ALLOW_VARIABLES ,
237
- Token .KEYWORD ,
238
- Token .ASSIGN ,
251
+ * ALLOWED_TOKEN_TYPES ,
239
252
* (extra_types if extra_types is not None else set ()),
240
253
}:
241
254
return _tokenize_no_variables (token )
You can’t perform that action at this time.
0 commit comments