Skip to content

Commit

Permalink
Analysis: record files that were indexed
Browse files Browse the repository at this point in the history
  • Loading branch information
ChrisTimperley committed Jul 13, 2024
1 parent 60b3ed4 commit e8e2c82
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/kaskara/analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
__all__ = ("Analysis",)

import json
import os
import typing as t

import attr
Expand All @@ -21,21 +22,31 @@ class Analysis:
Attributes
----------
files: t.FrozenSet[str]
The set of files that were analyzed within the program.
loops: ProgramLoops
The set of loop control-flow statements within the program.
functions: ProgramFunctions
The set of functions within the program.
statements: ProgramStatements
The set of statements within the program.
"""
files: frozenset[str]
loops: ProgramLoops
functions: ProgramFunctions
statements: ProgramStatements
insertions: ProgramInsertionPoints

def with_relative_locations(self, base: str) -> Analysis:
files: set[str] = set()
for filename in self.files:
if os.path.isabs(filename):
filename = os.path.relpath(filename, base) # noqa: PLW2901
files.add(filename)

return attr.evolve(
self,
files=frozenset(files),
loops=self.loops.with_relative_locations(base),
functions=self.functions.with_relative_locations(base),
statements=self.statements.with_relative_locations(base),
Expand Down
1 change: 1 addition & 0 deletions src/kaskara/clang/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def run(self) -> Analysis:
statements = self._find_statements()
insertions = statements.insertions()
return Analysis(
files=self._project.files,
loops=loops,
functions=functions,
statements=statements,
Expand Down
1 change: 1 addition & 0 deletions src/kaskara/python/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ def run(self) -> Analysis:
loops = collect_loops(self._container)
insertions = statements.insertions()
return Analysis(
files=self._project.files,
functions=functions,
statements=statements,
insertions=insertions,
Expand Down
1 change: 1 addition & 0 deletions src/kaskara/spoon/analyser.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ def run(self) -> Analysis:
insertions = statements.insertions()

return Analysis(
files=self._project.files,
loops=loops,
functions=functions,
statements=statements,
Expand Down

0 comments on commit e8e2c82

Please sign in to comment.