@@ -26,10 +26,12 @@ class XMLTransformer(XMLGenerator, LexicalHandler):
2626 def __init__ (
2727 self ,
2828 out ,
29+ file_context : FileContext ,
2930 encoding : str = "utf-8" ,
3031 short_empty_elements : bool = False ,
3132 results : list [Result ] | None = None ,
3233 ) -> None :
34+ self .file_context = file_context
3335 self .results = results
3436 self .changes : list [Change ] = []
3537 self ._my_locator = Locator ()
@@ -87,7 +89,11 @@ def match_result(self, line, column) -> bool:
8789
8890 def add_change (self , line ):
8991 self .changes .append (
90- Change (lineNumber = line , description = self .change_description )
92+ Change (
93+ lineNumber = line ,
94+ description = self .change_description ,
95+ findings = self .file_context .get_findings_for_location (line ),
96+ )
9197 )
9298
9399
@@ -99,13 +105,14 @@ class ElementAttributeXMLTransformer(XMLTransformer):
99105 def __init__ (
100106 self ,
101107 out ,
108+ file_context : FileContext ,
102109 name_attributes_map : dict [str , dict [str , str ]],
103110 encoding : str = "utf-8" ,
104111 short_empty_elements : bool = False ,
105112 results : list [Result ] | None = None ,
106113 ) -> None :
107114 self .name_attributes_map = name_attributes_map
108- super ().__init__ (out , encoding , short_empty_elements , results )
115+ super ().__init__ (out , file_context , encoding , short_empty_elements , results )
109116
110117 def startElement (self , name , attrs ):
111118 new_attrs : AttributesImpl = attrs
@@ -131,12 +138,13 @@ class NewElementXMLTransformer(XMLTransformer):
131138 def __init__ (
132139 self ,
133140 out ,
141+ file_context : FileContext ,
134142 encoding : str = "utf-8" ,
135143 short_empty_elements : bool = False ,
136144 results : list [Result ] | None = None ,
137145 new_elements : list [NewElement ] | None = None ,
138146 ) -> None :
139- super ().__init__ (out , encoding , short_empty_elements , results )
147+ super ().__init__ (out , file_context , encoding , short_empty_elements , results )
140148 self .new_elements = new_elements or []
141149
142150 def startElement (self , name , attrs ):
@@ -175,7 +183,9 @@ def apply(
175183 # this will fail fast for files that are not XML
176184 try :
177185 transformer_instance = self .xml_transformer (
178- out = output_file , results = results
186+ out = output_file ,
187+ file_context = file_context ,
188+ results = results ,
179189 )
180190 parser = make_parser ()
181191 parser .setContentHandler (transformer_instance )
0 commit comments