Skip to content
Snippets Groups Projects
Commit 04a5a907 authored by Henning Glawe's avatar Henning Glawe
Browse files

make coverageIgnore constructor kwarg of Annotator

parent 08fd09ac
No related branches found
No related tags found
No related merge requests found
...@@ -6,8 +6,9 @@ LOGGER = logging.getLogger(__name__) ...@@ -6,8 +6,9 @@ LOGGER = logging.getLogger(__name__)
class Annotator(object): class Annotator(object):
def __init__(self, annotateFilename=None): def __init__(self, annotateFilename=None, coverageIgnore=None):
self.matchHighlighter = MatchHighlighter() self.matchHighlighter = MatchHighlighter()
self.coverageIgnore = coverageIgnore
if annotateFilename is None: if annotateFilename is None:
self.annotateFile = None self.annotateFile = None
else: else:
...@@ -18,13 +19,8 @@ class Annotator(object): ...@@ -18,13 +19,8 @@ class Annotator(object):
def annotate(self,match,line,parser,matcher,targetStartEnd): def annotate(self,match,line,parser,matcher,targetStartEnd):
if not self.annotateFile: if not self.annotateFile:
return 1 return 1
coverageIgnore = None
try:
coverageIgnore = parser.superContext.coverageIgnore
except AttributeError:
pass
(matchtype, highlightedLine) = self.matchHighlighter.highlight( (matchtype, highlightedLine) = self.matchHighlighter.highlight(
match, line, coverageIgnore) match, line, self.coverageIgnore)
matchlabel = '' matchlabel = ''
if matchtype == 0: if matchtype == 0:
matchlabel='ign' matchlabel='ign'
......
...@@ -960,11 +960,14 @@ class SimpleParser(object): ...@@ -960,11 +960,14 @@ class SimpleParser(object):
self.superContext = superContext self.superContext = superContext
self.lastMatch = {} self.lastMatch = {}
annofilename = None annofilename = None
coverageIgnore = None
if annotate: if annotate:
annofilename=fIn.fIn.name + ".annotate" annofilename=fIn.fIn.name + ".annotate"
coverageIgnore = getattr(superContext, 'coverageIgnore', None)
else: else:
logger.info("no annotations requested for " + fIn.fIn.name) logger.info("no annotations requested for " + fIn.fIn.name)
self.annotator = Annotator(annotateFilename=annofilename) self.annotator = Annotator(annotateFilename=annofilename,
coverageIgnore=coverageIgnore)
def enterInState(self, stateIndex): def enterInState(self, stateIndex):
compiledMatcher = self.parserBuilder.compiledMatchers[stateIndex] compiledMatcher = self.parserBuilder.compiledMatchers[stateIndex]
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment