def visit_Call(self, node): # Index function/method call sites name = convert_node_to_name(node.func) if name: start, end = self.file_to_index.get_node_start_end(node) self.yield_needle('py_callers', name, start, end) self.generic_visit(node)
def visit_Call(self, node): # Index function/method call sites name = convert_node_to_name(node.func) if name: start, end = self.file_to_index.get_node_start_end(node) if start is not None: self.yield_needle('py_callers', name, start, end) self.generic_visit(node)
def visit_Call(self, node): # Save this call if we're currently tracking function calls. if self.function_call_stack: call_needles = self.function_call_stack[-1] name = convert_node_to_name(node.func) if name: start, end = self.file_to_index.get_node_start_end(node) call_needles.append((name, start, end)) self.generic_visit(node)
def visit_ClassDef(self, node): super(AnalyzingNodeVisitor, self).visit_ClassDef(node) # Save the base classes of any class we find. class_path = self.abs_module_name + '.' + node.name bases = [] for base in node.bases: base_name = convert_node_to_name(base) if base_name: bases.append((self.abs_module_name, base_name)) self.tree_analysis.base_classes[class_path] = bases
def get_node_start_end(self, node): """Return start and end positions within the file for the given AST Node. """ start = node.lineno, node.col_offset if start in self.node_start_table: start = self.node_start_table[start] end = None if isinstance(node, ast.ClassDef) or isinstance(node, ast.FunctionDef): end = start[0], start[1] + len(node.name) elif isinstance(node, ast.Call): name = convert_node_to_name(node.func) if name: end = start[0], start[1] + len(name) return start, end