Skip to content

Commit a5fb1c2

Browse files
committed
Add method to retrieve locations
1 parent bf46ba9 commit a5fb1c2

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/codemodder/result.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,13 @@ def match_location(self, pos: CodeRange, node: cst.CSTNode) -> bool:
103103
def __hash__(self):
104104
return hash(self.rule_id)
105105

106+
def get_locations(self) -> Sequence[Sequence[Location]]:
107+
return self.codeflows or (
108+
[self.locations]
109+
if self.locations
110+
else [[loc.location for loc in self.related_locations]]
111+
)
112+
106113

107114
@dataclass(frozen=True, kw_only=True)
108115
class SASTResult(Result):

0 commit comments

Comments
 (0)