From bcf146aeba4100084e51dcd626bd229efda5603c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20C=2E=20Silva?= <12188364+andrecsilva@users.noreply.github.com> Date: Wed, 24 Jul 2024 10:43:23 -0300 Subject: [PATCH] Fixed a bug with line matching in xml transformer (#737) --- src/codemodder/codemods/xml_transformer.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/src/codemodder/codemods/xml_transformer.py b/src/codemodder/codemods/xml_transformer.py index 4ddec0e1..beb07734 100644 --- a/src/codemodder/codemods/xml_transformer.py +++ b/src/codemodder/codemods/xml_transformer.py @@ -83,15 +83,12 @@ def match_result(self, line, column) -> bool: return True for result in self.results or []: for location in result.locations: - if self.line_only_matching: - return location.start.line == line - else: - # No two elements can have the same start but different ends. - # It suffices to only match the start. - return ( - location.start.line == line - and location.start.column - 1 == column - ) + # No two elements can have the same start but different ends. + # It suffices to only match the start. + if (self.line_only_matching and location.start.line == line) or ( + location.start.line == line and location.start.column - 1 == column + ): + return True return False def add_change(self, line):