matchcompiler.py: skip comments in _replaceTokenMatch() (#3825)
This commit is contained in:
parent
6e57cc4323
commit
c690bfb03a
|
@ -384,6 +384,10 @@ class MatchCompiler:
|
|||
is_simplematch = func == 'simpleMatch'
|
||||
pattern_start = 0
|
||||
while True:
|
||||
# skip comments
|
||||
if line.strip().startswith('//'):
|
||||
break
|
||||
|
||||
pos1 = line.find('Token::' + func + '(', pattern_start)
|
||||
if pos1 == -1:
|
||||
break
|
||||
|
|
|
@ -191,5 +191,10 @@ class MatchCompilerTest(unittest.TestCase):
|
|||
'if (match16(parent->tokAt(-3)) && tok->strAt(1) == MatchCompiler::makeConstString(")"))',
|
||||
output)
|
||||
|
||||
def test_parseMatchSkipComments(self):
|
||||
input = '// TODO: suggest Token::exactMatch() for Token::simpleMatch() when pattern contains no whitespaces'
|
||||
output = self.mc._replaceTokenMatch(input, 0, "foo.cpp")
|
||||
self.assertEqual(output, '// TODO: suggest Token::exactMatch() for Token::simpleMatch() when pattern contains no whitespaces')
|
||||
|
||||
if __name__ == '__main__':
|
||||
unittest.main()
|
||||
|
|
Loading…
Reference in New Issue