MCPcopy Create free account
hub / github.com/SourceCode-AI/aura / PatternMatchingVisitor

Class PatternMatchingVisitor

tests/test_ast_pattern_matching.py:10–35  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

8
9
10class PatternMatchingVisitor:
11 def __init__(self, pattern: ASTPattern):
12 self.p = pattern
13 self.q = deque()
14 self.call_graph = CallGraph()
15 self.hits = []
16 self.normalized_path = "pytest_src"
17 self.path = self.normalized_path
18
19 def traverse(self, initial_node):
20 self.q.clear()
21 self.q.append(Context(node=initial_node, parent=None, visitor=self))
22
23 while len(self.q):
24 ctx = self.q.popleft()
25 if self.p.match(ctx.node):
26 self.p.apply(ctx)
27 return ctx.node
28
29 if isinstance(ctx.node, ASTNode):
30 ctx.node._visit_node(ctx)
31
32 return False
33
34 def push(self, ctx):
35 self.q.append(ctx)
36
37
38CASES = (

Callers 4

test_patternsFunction · 0.85
test_matching_triggersFunction · 0.85
test_any_ofFunction · 0.85
disabled_test_decoratorFunction · 0.85

Calls

no outgoing calls

Tested by 4

test_patternsFunction · 0.68
test_matching_triggersFunction · 0.68
test_any_ofFunction · 0.68
disabled_test_decoratorFunction · 0.68