MCPcopy Create free account
hub / github.com/nodejs/node / UndeclaredNameVisitor

Class UndeclaredNameVisitor

tools/inspector_protocol/jinja2/compiler.py:215–234  ·  view source on GitHub ↗

A visitor that checks if a name is accessed without being declared. This is different from the frame visitor as it will not stop at closure frames.

Source from the content-addressed store, hash-verified

213
214
215class UndeclaredNameVisitor(NodeVisitor):
216 """A visitor that checks if a name is accessed without being
217 declared. This is different from the frame visitor as it will
218 not stop at closure frames.
219 """
220
221 def __init__(self, names):
222 self.names = set(names)
223 self.undeclared = set()
224
225 def visit_Name(self, node):
226 if node.ctx == 'load' and node.name in self.names:
227 self.undeclared.add(node.name)
228 if self.undeclared == self.names:
229 raise VisitorExit()
230 else:
231 self.names.discard(node.name)
232
233 def visit_Block(self, node):
234 """Stop visiting a blocks."""
235
236
237class CompilerExit(Exception):

Callers 1

find_undeclaredFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected