Traverses the tree upward to see if the identifier is defined in a higher scope that is nested within outermostScope. path: babel path identifierName: string outermostScopeUid: number (Higher number means deeper nesting)
502292
function isDefinedInNestedScope(path, outermostScopeUid) {
  return path.findParent(
    parent =>
      parent.scope.hasOwnBinding(path.node.name) &&
      parent.scope.uid > outermostScopeUid
  );
}
692130
function visitTypedVariableDeclarator(traverse, node, path, state) {
  var ctx = new Context(state);
  if (node.init) {
    utils.catchup(node.init.range[0], state);
    utils.append(ctx.getProperty('check') + '(', state);
    traverse(node.init, path, state);
    utils.catchup(node.init.range[1], state);
    utils.append(', ' + ctx.getType(node.id.typeAnnotation.typeAnnotation) + ')', state);
  }
  utils.catchup(node.range[1], state);
  return false;
}
872973
function getScope(scopeManager, currentNode) {

    // On Program node, get the outermost scope to avoid return Node.js special function scope or ES modules scope.
    const inner = currentNode.type !== "Program";

    for (let node = currentNode; node; node = node.parent) {
        const scope = scopeManager.acquire(node, inner);

        if (scope) {
            if (scope.type === "function-expression-name") {
                return scope.childScopes[0];
            }
            return scope;
        }
    }

    return scopeManager.scopes[0];
}
774176
def module_def(self):
        
        if self.module_level == MAX_NESTING_LEVELS:
            self.error("Module nested too deep")
        self.module_level += 1
        module = ModuleDefinition()
        self.parse(module, end_token="}")
        self.module_level -= 1
        self.current_module.pop()
        return module
1323810
function visitIdentifier(context, node, scope, state) {
  // check if this node matches our function id
  if (node.name !== state.name) return;

  // check that we don't have a local variable declared as that removes the need
  // for the wrapper
  var localDeclar = scope.getBindingIdentifier(state.name);
  if (localDeclar !== state.outerDeclar) return;

  state.selfReference = true;
  context.stop();
}
107693
private static boolean inStaticContext(TreePath path) {
    Tree prev = path.getLeaf();
    path = path.getParentPath();

    ClassSymbol enclosingClass =
        ASTHelpers.getSymbol(ASTHelpers.findEnclosingNode(path, ClassTree.class));
    ClassSymbol directSuperClass = (ClassSymbol) enclosingClass.getSuperclass().tsym;

    for (Tree tree : path) {
      switch (tree.getKind()) {
        case METHOD:
          return ASTHelpers.getSymbol(tree).isStatic();
        case BLOCK: // static initializer
          if (((BlockTree) tree).isStatic()) {
            return true;
          }
          break;
        case VARIABLE: // variable initializer of static variable
          VariableTree variableTree = (VariableTree) tree;
          VarSymbol variableSym = ASTHelpers.getSymbol(variableTree);
          if (variableSym.getKind() == ElementKind.FIELD) {
            return Objects.equals(variableTree.getInitializer(), prev) && variableSym.isStatic();
          }
          break;
        case METHOD_INVOCATION: // JLS 8.8.7.1 explicit constructor invocation
          MethodSymbol methodSym = ASTHelpers.getSymbol((MethodInvocationTree) tree);
          if (methodSym == null) {
            // sometimes javac can't resolve the symbol. In this case just assume that we are
            // in a static context - this is a safe approximation in our context (checking
            // visibility)
            return true;
          }
          if (methodSym.isConstructor()
              && (Objects.equals(methodSym.owner, enclosingClass)
                  || Objects.equals(methodSym.owner, directSuperClass))) {
            return true;
          }
          break;
        default:
          break;
      }
      prev = tree;
    }
    return false;
  }
201346
function parseAttributePath(attrPath, context) {
    const parsed = attrPath.split('.');
    parsed.forEach(item => checkIdentifier(item, context));
    return parsed;
}
696742
private int getLexicalScopeDepth(SymbolScope scope) {
    if (scope.isLexicalScope() || scope.isDocScope()) {
      return scope.getScopeDepth();
    } else {
      checkState(scope.isPropertyScope());
      Symbol sym = scope.getSymbolForScope();
      checkNotNull(sym);
      return getLexicalScopeDepth(getScope(sym)) + 1;
    }
  }
65696
function getNameForPath(path: Path): string {
  const {node, parent, parentPath} = path;
  if (t.isProgram(node)) {
    return '<global>';
  }
  let {id} = path;
  // has an `id` so we don't need to infer one
  if (node.id) {
    return node.id.name;
  }
  let propertyPath;
  let kind = '';
  if (t.isObjectMethod(node) || t.isClassMethod(node)) {
    id = node.key;
    if (node.kind !== 'method') {
      kind = node.kind;
    }
    propertyPath = path;
  } else if (t.isObjectProperty(parent) || t.isClassProperty(parent)) {
    // { foo() {} };
    id = parent.key;
    propertyPath = parentPath;
  } else if (t.isVariableDeclarator(parent)) {
    // let foo = function () {};
    id = parent.id;
  } else if (t.isAssignmentExpression(parent)) {
    // foo = function () {};
    id = parent.left;
  } else if (t.isJSXExpressionContainer(parent)) {
    if (t.isJSXElement(parentPath.parentPath.node)) {
      // <foo>{function () {}}</foo>
      const openingElement = parentPath.parentPath.node.openingElement;
      id = t.JSXMemberExpression(
        t.JSXMemberExpression(openingElement.name, t.JSXIdentifier('props')),
        t.JSXIdentifier('children'),
      );
    } else if (t.isJSXAttribute(parentPath.parentPath.node)) {
      // <foo bar={function () {}} />
      const openingElement = parentPath.parentPath.parentPath.node;
      const prop = parentPath.parentPath.node;
      id = t.JSXMemberExpression(
        t.JSXMemberExpression(openingElement.name, t.JSXIdentifier('props')),
        prop.name,
      );
    }
  }

  let name = getNameFromId(id);

  if (name == null) {
    if (t.isCallExpression(parent)) {
      // foo(function () {})
      const argIndex = parent.arguments.indexOf(node);
      if (argIndex !== -1) {
        const calleeName = getNameFromId(parent.callee);
        if (calleeName) {
          return `${calleeName}$argument_${argIndex}`;
        }
      }
    }
    return ANONYMOUS_NAME;
  }

  if (kind) {
    name = kind + '__' + name;
  }

  if (propertyPath) {
    if (t.isClassBody(propertyPath.parent)) {
      const className = getNameForPath(propertyPath.parentPath.parentPath);
      if (className !== ANONYMOUS_NAME) {
        const separator = propertyPath.node.static ? '.' : '#';
        name = className + separator + name;
      }
    } else if (t.isObjectExpression(propertyPath.parent)) {
      const objectName = getNameForPath(propertyPath.parentPath);
      if (objectName !== ANONYMOUS_NAME) {
        name = objectName + '.' + name;
      }
    }
  }

  return name;
}
171850
@Override
    public void visitIdent(JCIdent tree) {
        if (context == null || !analyzer.lambdaIdentSymbolFilter(tree.sym)) {
            super.visitIdent(tree);
        } else {
            int prevPos = make.pos;
            try {
                make.at(tree);

                LambdaTranslationContext lambdaContext = (LambdaTranslationContext) context;
                JCTree ltree = lambdaContext.translate(tree);
                if (ltree != null) {
                    result = ltree;
                } else {
                    //access to untranslated symbols (i.e. compile-time constants,
                    //members defined inside the lambda body, etc.) )
                    super.visitIdent(tree);
                }
            } finally {
                make.at(prevPos);
            }
        }
    }
533094
function(path) {
            if (!path.inList) {
              return;
            }

            const { node } = path;
            if (node.kind !== "var") {
              return;
            }

            const next = path.getSibling(path.key + 1);
            if (!next.isForStatement()) {
              return;
            }

            const init = next.get("init");
            if (!init.isVariableDeclaration({ kind: node.kind })) {
              return;
            }

            const declarations = node.declarations.concat(
              init.node.declarations
            );

            // temporary workaround to forces babel recalculate scope,
            // references and binding until babel/babel#4818 resolved
            path.remove();
            init.replaceWith(t.variableDeclaration("var", declarations));
          }
45854
function buildElementIdentifier(element) {
			if (element.id) {
				return `#${element.id}`;
			}
			let identifier = element.tagName.toLowerCase();
			if (!element.parentNode) {
				return identifier;
			}
			const siblings = getSiblings(element);
			const childIndex = siblings.indexOf(element);
			if (!isOnlySiblingOfType(element, siblings) && childIndex !== -1) {
				identifier += `:nth-child(${childIndex + 1})`;
			}
			return identifier;
		}
646174
function getLeftmostName(node) {
	while ( node.type === Syntax.MemberExpression ) {
		node = node.object;
	}
	if ( node.type === Syntax.Identifier ) {
		return node.name;
	}
	// return undefined;
}
949150
function labelForScope(scope) {
        if (scope) {
            return StringUtils.format(
                Strings.FIND_IN_FILES_SCOPED,
                StringUtils.breakableUrl(
                    ProjectManager.makeProjectRelativeIfPossible(scope.fullPath)
                )
            );
        } else {
            return Strings.FIND_IN_FILES_NO_SCOPE;
        }
    }
1279468
private int inOrderAnalyse(StructuralNode node) {
        int subtreeNodes = 0;

        if (isStop) {
            return 0;
        }

        if (node == null) {
            return 0;
        }

        // analyse entity if not root and not leaf.
        // Leaf is not analysed because only folder entity is used to determine if path exist.
        try {
            if (!node.isRoot()) {
                if (!node.isLeaf() || node.isLeaf() && node.getParent().isRoot()) {
                    analyse(node);
                    
                } else {
                    //ZAP: it's a Leaf then no children are available
                    return 1;
                }
            }
            
        } catch (Exception e) {
        }

        Iterator<StructuralNode> iter = node.getChildIterator();
        while (iter.hasNext()) {
            subtreeNodes += inOrderAnalyse(iter.next());
        }
        
        return subtreeNodes + 1;
    }
1021968
private Symbol findSymbolForScope(SymbolScope scope) {
    Node rootNode = scope.getRootNode();
    if (rootNode.getParent() == null) {
      return globalScope.getSlot(GLOBAL_THIS);
    }

    if (!rootNode.isFunction()) {
      return null;
    }

    String name = NodeUtil.getBestLValueName(NodeUtil.getBestLValue(rootNode));
    return name == null ? null : scope.getParentScope().getQualifiedSlot(name);
  }
298795
def path(self):
        ""
        if self.parent:
            return '.'.join([self.parent.path, str(self.identifier)])
        else:
            return self.identifier if self.identifier else self.__class__.__name__