Commit 178f8834 authored by Philipp Wolfer's avatar Philipp Wolfer

AngularJS check: Implemented check_highlight

parent 33fca50f
......@@ -65,3 +65,12 @@ class AngularJSInterpolationCheck(TargetCheck):
tgt_tags = set([re.sub(WHITESPACE, '', x) for x in tgt_match])
return src_tags != tgt_tags
def check_highlight(self, source, unit):
if self.should_skip(unit):
return []
ret = []
match_objects = ANGULARJS_INTERPOLATION_MATCH.finditer(source)
for match in match_objects:
ret.append((match.start(), match.end(), match.group()))
return ret
......@@ -75,3 +75,19 @@ class AngularJSInterpolationCheckTest(TestCase):
u'{{nameerror}} string',
MockUnit('angularjs_wrong_value', flags='angularjs-format')
))
def test_check_highlight(self):
highlights = self.check.check_highlight(
u'{{name}} {{other}} string',
MockUnit('angularjs_format', flags='angularjs-format'))
self.assertEqual(2, len(highlights))
self.assertEqual(0, highlights[0][0])
self.assertEqual(8, highlights[0][1])
self.assertEqual(9, highlights[1][0])
self.assertEqual(18, highlights[1][1])
def test_check_highlight_ignored(self):
highlights = self.check.check_highlight(
u'{{name}} {{other}} string',
MockUnit('angularjs_format', flags='ignore-angularjs-format'))
self.assertEqual([], highlights)
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment