Scan a single node. The current path is updated for the duration of the scan.
336441
@Override
  public Void scan(Tree tree, VisitorState state) {
    if (tree == null) {
      return null;
    }

    SuppressionInfo prevSuppressionInfo = updateSuppressions(tree, state);
    try {
      return super.scan(tree, state);
    } finally {
      // Restore old suppression state.
      currentSuppressions = prevSuppressionInfo;
    }
  }
671570
def RemoveScanNode(self, path_spec):
    
    scan_node = self._scan_nodes.get(path_spec, None)
    if not scan_node:
      return None

    if scan_node.sub_nodes:
      raise RuntimeError('Scan node has sub nodes.')

    parent_scan_node = scan_node.parent_node
    if parent_scan_node:
      parent_scan_node.sub_nodes.remove(scan_node)

    if path_spec == self._root_path_spec:
      self._root_path_spec = None
    del self._scan_nodes[path_spec]

    if path_spec.IsFileSystem():
      del self._file_system_scan_nodes[path_spec]

    return parent_scan_node
493186
def scan_in_memory(node, env, path=()):
    
    try:
        entries = node.entries
    except AttributeError:
        # It's not a Node.FS.Dir (or doesn't look enough like one for
        # our purposes), which can happen if a target list containing
        # mixed Node types (Dirs and Files, for example) has a Dir as
        # the first entry.
        return []
    entry_list = sorted(filter(do_not_scan, list(entries.keys())))
    return [entries[n] for n in entry_list]
724046
def scan_on_disk(node, env, path=()):
    
    try:
        flist = node.fs.listdir(node.get_abspath())
    except (IOError, OSError):
        return []
    e = node.Entry
    for f in  filter(do_not_scan, flist):
        # Add ./ to the beginning of the file name so if it begins with a
        # '#' we don't look it up relative to the top-level directory.
        e('./' + f)
    return scan_in_memory(node, env, path)
495195
@Override
  public Void scan(TreePath path, VisitorState state) {
    SuppressionInfo prevSuppressionInfo = updateSuppressions(path.getLeaf(), state);
    try {
      return super.scan(path, state);
    } finally {
      // Restore old suppression state.
      currentSuppressions = prevSuppressionInfo;
    }
  }
1035246
def nodes(self, path):
        
        path = posix_path(path)

        yield from (self.path(path, e) for e in self._handler.find(path))
1350754
def setCurrentSchemaPath(self, path):
        
        if not path:
            return False
        
        parts = path.split('.')
        name  = parts[0]
        next  = parts[1:]
        
        if name == self.text(0):
            if next:
                self.load()
                path = '.'.join(next)
                for c in range(self.childCount()):
                    if self.child(c).setCurrentSchemaPath(path):
                        self.setExpanded(True)
                        return True
                return False
            else:
                self.treeWidget().setCurrentItem(self)
                return True
        return False
601918
public R scan(TreePath path, P p) {
        this.path = path;
        try {
            return path.getLeaf().accept(this, p);
        } finally {
            this.path = null;
        }
    }
485559
def get_node(self, path):
        

        path = self._fix_path(path)

        if not path in self.nodes:
            if path in self._file_paths:
                node = FileNode(path, changeset=self)
            elif path in self._dir_paths or path in self._dir_paths:
                if path == '':
                    node = RootNode(changeset=self)
                else:
                    node = DirNode(path, changeset=self)
            else:
                raise NodeDoesNotExistError("There is no file nor directory "
                    "at the given path: '%s' at revision %s"
                    % (path, self.short_id))
            # cache node
            self.nodes[path] = node
        return self.nodes[path]
913097
@Override
    public R scan(DocTree tree, P p) {
        if (tree == null)
            return null;

        DocTreePath prev = path;
        path = new DocTreePath(path, tree);
        try {
            return tree.accept(this, p);
        } finally {
            path = prev;
        }
    }
1146542
def _scan_nodes(nodelist, context, instance_types, current_block=None, ignore_blocks=None):
    
    results = []
    for node in nodelist:
        # first check if this is the object instance to look for.
        if isinstance(node, instance_types):
            results.append(node)
            # if it's a Constant Include Node ({% include "template_name.html" %})
        # scan the child template
        elif isinstance(node, IncludeNode):
            # if there's an error in the to-be-included template, node.template becomes None
            if node.template:
                # This is required for Django 1.7 but works on older version too
                # Check if it quacks like a template object, if not
                # presume is a template path and get the object out of it
                if not callable(getattr(node.template, 'render', None)):
                    template = get_template(node.template.var)
                else:
                    template = node.template

                if TemplateAdapter is not None and isinstance(template, TemplateAdapter):
                    # Django 1.8: received a new object, take original template
                    template = template.template

                results += _scan_nodes(template.nodelist, context, instance_types, current_block)
        # handle {% extends ... %} tags
        elif isinstance(node, ExtendsNode):
            results += _extend_nodelist(node, context, instance_types)
        # in block nodes we have to scan for super blocks
        elif isinstance(node, VariableNode) and current_block:
            if node.filter_expression.token == 'block.super':
                # Found a {{ block.super }} line
                if not hasattr(current_block.parent, 'nodelist'):
                    raise TemplateSyntaxError(
                        "Cannot read {{{{ block.super }}}} for {{% block {0} %}}, "
                        "the parent template doesn't have this block.".format(
                        current_block.name
                    ))
                results += _scan_nodes(current_block.parent.nodelist, context, instance_types, current_block.parent)
        # ignore nested blocks which are already handled
        elif isinstance(node, BlockNode) and ignore_blocks and node.name in ignore_blocks:
            continue
        # if the node has the newly introduced 'child_nodelists' attribute, scan
        # those attributes for nodelists and recurse them
        elif hasattr(node, 'child_nodelists'):
            for nodelist_name in node.child_nodelists:
                if hasattr(node, nodelist_name):
                    subnodelist = getattr(node, nodelist_name)
                    if isinstance(subnodelist, NodeList):
                        if isinstance(node, BlockNode):
                            current_block = node
                        results += _scan_nodes(subnodelist, context, instance_types, current_block)
        # else just scan the node for nodelist instance attributes
        else:
            for attr in dir(node):
                obj = getattr(node, attr)
                if isinstance(obj, NodeList):
                    if isinstance(node, BlockNode):
                        current_block = node
                    results += _scan_nodes(obj, context, instance_types, current_block)
    return results
1133082
def in_single_path(self):
        
        return len(self.successor) == 1 and not self.successor[0].in_or_out and \
               len(self.precedence) == 1 and len(self.precedence[0].successor) <= 1
537595
def LockScanNode(self, path_spec):
    
    scan_node = self._scan_nodes.get(path_spec, None)
    if not scan_node:
      raise KeyError('Scan node does not exist.')

    self._locked_scan_nodes[path_spec] = scan_node
377297
def walk(self, node):
        ""
        node = self.visit(node)

        if node is None:
            return None

        if isinstance(node, parso.tree.BaseNode):
            walked = map(self.walk, node.children)
            node.children = [child for child in walked if child is not None]

        return node
768404
@GuardedBy("monitor")
  private /*@Nullable*/ TreeNode findNode(/*@Nullable*/ String path) {
    if (Strings.isNullOrEmpty(path) || "/".equals(path)) { // Go back to the root directory.
      return root;
    } else {
      List<String> dirs = PATH_SPLITTER.splitToList(path);
      TreeNode node = root;
      for (int i = 0; i < dirs.size(); i++) {
        String dir = dirs.get(i);
        if ("".equals(dir) && i == 0) {
          continue; // Skip the first "", the path of root node.
        }
        if (!node.children.containsKey(dir)) {
          return null;
        } else {
          node = node.children.get(dir);
        }
      }
      return node;
    }
  }
1141666
def _ScanFileSystem(self, scan_node, base_path_specs):
    
    if not scan_node or not scan_node.path_spec:
      raise errors.ScannerError('Invalid or missing file system scan node.')

    base_path_specs.append(scan_node.path_spec)
82150
def visit_Yield(self, node):
        
        self.generic_visit(node)
        self.combine(self.current, node.value)