File tree Expand file tree Collapse file tree 2 files changed +22
-12
lines changed
robotcode/language_server/robotframework/diagnostics Expand file tree Collapse file tree 2 files changed +22
-12
lines changed Original file line number Diff line number Diff line change @@ -239,21 +239,34 @@ async def visit(self, node: ast.AST) -> None:
239
239
finally :
240
240
self .node_stack = self .node_stack [:- 1 ]
241
241
242
+ @staticmethod
243
+ async def get_ignored_lines (document : TextDocument ) -> List [int ]:
244
+ return await document .get_cache (Analyzer .__get_ignored_lines )
245
+
246
+ @staticmethod
247
+ async def __get_ignored_lines (document : TextDocument ) -> List [int ]:
248
+ result = []
249
+ lines = await document .get_lines ()
250
+ for line_no , line in enumerate (lines ):
251
+
252
+ comment = EXTRACT_COMMENT_PATTERN .match (line )
253
+ if comment and comment .group ("comment" ):
254
+ for match in ROBOTCODE_PATTERN .finditer (comment .group ("comment" )):
255
+
256
+ if match .group ("rule" ) == "ignore" :
257
+ result .append (line_no )
258
+
259
+ return result
260
+
242
261
@staticmethod
243
262
async def should_ignore (document : Optional [TextDocument ], range : Range ) -> bool :
244
263
import builtins
245
264
246
265
if document is not None :
247
- lines = await document . get_lines ( )
266
+ lines = await Analyzer . get_ignored_lines ( document )
248
267
for line_no in builtins .range (range .start .line , range .end .line + 1 ):
249
- line = lines [line_no ]
250
-
251
- comment = EXTRACT_COMMENT_PATTERN .match (line )
252
- if comment and comment .group ("comment" ):
253
- for match in ROBOTCODE_PATTERN .finditer (comment .group ("comment" )):
254
-
255
- if match .group ("rule" ) == "ignore" :
256
- return True
268
+ if line_no in lines :
269
+ return True
257
270
258
271
return False
259
272
Original file line number Diff line number Diff line change @@ -856,7 +856,6 @@ async def get_global_variables(self) -> List[VariableDefinition]:
856
856
857
857
return self ._global_variables
858
858
859
- @_logger .call
860
859
async def yield_variables (
861
860
self ,
862
861
nodes : Optional [List [ast .AST ]] = None ,
@@ -906,7 +905,6 @@ async def get_resolvable_variables(
906
905
if v .has_value
907
906
}
908
907
909
- @_logger .call
910
908
async def get_variable_matchers (
911
909
self , nodes : Optional [List [ast .AST ]] = None , position : Optional [Position ] = None
912
910
) -> Dict [VariableMatcher , VariableDefinition ]:
@@ -945,7 +943,6 @@ async def find_variable(
945
943
946
944
return None
947
945
948
- @_logger .call
949
946
async def _import_imports (
950
947
self ,
951
948
imports : Iterable [Import ],
You can’t perform that action at this time.
0 commit comments