Coverage for src/robotide/utils/highlightmatcher.py: 89%
24 statements
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
« prev ^ index » next coverage.py v7.8.0, created at 2025-05-06 10:40 +0100
1# Copyright 2008-2015 Nokia Networks
2# Copyright 2016- Robot Framework Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
16from .. import utils 1op
17from . import variablematcher 1op
20def highlight_matcher(value, content): 1op
21 if not value or not content: 1ijklmaqhdgfbnce
22 return False 1q
23 selection = utils.normalize(value, ignore=['_']) 1ijklmahdgfbnce
24 if not selection: 24 ↛ 25line 24 didn't jump to line 25 because the condition on line 24 was never true1ijklmahdgfbnce
25 return False
26 target = utils.normalize(content, ignore=['_']) 1ijklmahdgfbnce
27 if not target: 27 ↛ 28line 27 didn't jump to line 28 because the condition on line 27 was never true1ijklmahdgfbnce
28 return False
29 if selection == target: 1ijklmahdgfbnce
30 return True 1ijklmhn
31 return _variable_matches(selection, target) 1ahdgfbce
34def _variable_matches(selection, target): 1op
35 variable = variablematcher.get_variable_basename(selection) 1ahdgfbce
36 if not variable: 1ahdgfbce
37 return False 1ahbc
38 variables = variablematcher.find_variable_basenames(target) 1adgfbce
39 if variable in variables: 1adgfbce
40 return True 1adgbce
41 return _list_variable_used_as_scalar(variable, variables) 1adfbce
44def _list_variable_used_as_scalar(variable, variables): 1op
45 return '$%s' % variable[1:] in variables 1adfbce