todo: check for possible redefinition
185248
function (dereference) {
        if (dereference.object.type !== 'Identifier') return
        if (!namespaces.has(dereference.object.name)) return

        if (dereference.parent.type === 'AssignmentExpression' &&
            dereference.parent.left === dereference) {
            context.report(dereference.parent,
                `Assignment to member of namespace '${dereference.object.name}'.`)
        }

        // go deep
        var namespace = namespaces.get(dereference.object.name)
        var namepath = [dereference.object.name]
        // while property is namespace and parent is member expression, keep validating
        while (namespace instanceof Exports &&
               dereference.type === 'MemberExpression') {

          if (dereference.computed) {
            if (!allowComputed) {
              context.report(dereference.property,
                'Unable to validate computed reference to imported namespace \'' +
                dereference.object.name + '\'.')
            }
            return
          }

          if (!namespace.has(dereference.property.name)) {
            context.report(
              dereference.property,
              makeMessage(dereference.property, namepath))
            break
          }

          const exported = namespace.get(dereference.property.name)
          if (exported == null) return

          // stash and pop
          namepath.push(dereference.property.name)
          namespace = exported.namespace
          dereference = dereference.parent
        }

      }
1153625
private static ShrinkWrapPath relativizeCommonRoot(final ShrinkWrapPath thisOriginal, final Path thisCurrent,
        final Path otherOriginal, Path otherCurrent, final int backupCount) {
        // Preconditions
        assert thisOriginal != null;
        assert thisCurrent != null;
        assert otherOriginal != null;
        assert otherCurrent != null;
        assert backupCount >= 0;

        // Do we yet have a common root?
        if (!otherCurrent.startsWith(thisCurrent)) {
            // Back up until we do
            final Path otherParent = otherCurrent.getParent();
            final ShrinkWrapPath thisParent = (ShrinkWrapPath) thisCurrent.getParent();
            if (otherParent != null && thisParent != null) {
                return relativizeCommonRoot(thisOriginal, thisParent, otherOriginal, otherParent, backupCount + 1);
            } else {
                throw new IllegalArgumentException("No common components");
            }
        }

        // Common root. Now relativize that.
        final List<String> thisTokens = tokenize(thisOriginal);
        final List<String> otherTokens = tokenize((ShrinkWrapPath) otherOriginal);
        final int numOtherTokens = otherTokens.size();
        final int numToTake = otherTokens.size() - thisTokens.size();
        final StringBuilder sb = new StringBuilder();
        for (int i = 0; i < backupCount; i++) {
            sb.append(DIR_BACK);
            sb.append(ArchivePath.SEPARATOR);
        }
        final int startCounter = numOtherTokens - numToTake - backupCount;
        final int stopCounter = numOtherTokens - 1;
        if (log.isLoggable(Level.FINEST)) {
            log.finest("Backup: " + backupCount);
            log.finest("This tokens: " + thisTokens);
            log.finest("Other tokens: " + otherTokens);
            log.finest("Differential: " + numToTake);
            log.finest("Start: " + startCounter);
            log.finest("Stop: " + stopCounter);
        }
        for (int i = startCounter; i <= stopCounter; i++) {
            if (i > startCounter) {
                sb.append(ArchivePath.SEPARATOR);
            }
            sb.append(otherTokens.get(i));
        }

        return new ShrinkWrapPath(sb.toString(), thisOriginal.fileSystem);
    }
1303062
static void cannotConvertYet(AbstractCompiler compiler, Node n, String feature) {
    compiler.report(JSError.make(n, CANNOT_CONVERT_YET, feature));
  }
777473
private boolean allDefinitionsEquivalent(Collection<Node> definitions) {
    if (definitions.isEmpty()) {
      return true;
    }

    Node definition = Iterables.get(definitions, 0);
    checkArgument(definition.isFunction(), definition);

    return definitions.stream().allMatch((d) -> compiler.areNodesEqualForInlining(d, definition));
  }
730992
@Override
    public boolean redefineClasses(Notification notification) {
        // if there are no paths to process, this is a minor update
        if (notification.getPaths().isEmpty()) {
            return true;
        }

        boolean success;
        synchronized (classLoaders) {
            if (classLoaders.isEmpty()) {
                success = false;
            } else {
                success = true;
                for (ContainerClassLoader loader : classLoaders) {
                    if (!loader.redefineClasses(notification)) {
                        success = false;
                        break;
                    }
                }
            }
        }

        return success;
    }
242211
private Symbol isAnySymbolDeclared(String name, Node declNode, SymbolScope scope) {
    Symbol sym = symbols.get(declNode, name);
    if (sym == null) {
      // Sometimes, our symbol tables will disagree on where the
      // declaration node should be. In the rare case where this happens,
      // trust the existing symbol.
      // See SymbolTableTest#testDeclarationDisagreement.
      return scope.ownSymbols.get(name);
    }
    return sym;
  }
1218318
def scope=(input)
      @scope = (input.instance_of?(Redistat::Scope)) ? input : Scope.new(input)
    end
756317
function shouldRenameDeclaration(name, path, binding, rootScope) {
  const isRootScope = path.scope === rootScope;
  const isGlobal = isRootScope && name in rootScope.globals;
  const program = rootScope.path;

  if (isGlobal) return false;

  if (!isRootScope) {
    const functionParent = path.getFunctionParent();
    const declarationParent = getDeclarationParent(path);

    // Bail if not a declaration or is property/key of object
    if (!declarationParent || isPropertyOrKey(path)) return false;

    if (declarationParent.isBlockScoped()) {
      // Handle function declaration (which defines it's own scope)
      if (declarationParent.isFunctionDeclaration()) {
        return declarationParent.parentPath.scope === rootScope && declarationParent.node.id === path.node;
      }
      // Skip let/const in block scope
      return false;
      // Handle re-assignment of root bound declaration (ignore function expressions)
    } else if (declarationParent.isAssignmentExpression() && !path.parentPath.isFunctionExpression()) {
      const declarationBinding = declarationParent.scope.getBinding(name);

      return declarationBinding ? declarationBinding.scope === rootScope : false;
      // Skip if in function scope
    } else if (functionParent !== program) {
      return false;
    }
  }

  // Skip if property or key of object
  return !isPropertyOrKey(path);
}
1123529
function define(value, key, src, propHash){
  var inSrc = key in src
    , isDescriptor = descriptors.isDescriptor(value)
    , isRequired = descriptors.isRequired(value)
    , prev;

  if (isRequired && inSrc) 
    return

  if ( !isRequired ) {
    if ( isDescriptor) {
      prev = (propHash[key] || []).splice(0) //assume this descriptor is resolving all of the conflicts
      return define(value.resolve.call(src, key, prev), key, src, propHash)
    }
    else
      add(propHash, key, value)
  }

  Object.defineProperty(src, key, {
    enumerable: true, 
    writable: true, 
    configurable: true,
    value: value
  })
}
711790
private boolean tryReplacingAliasingAssignment(Ref alias, Node aliasLhsNode) {
    // either VAR/CONST/LET or ASSIGN.
    Node assignment = aliasLhsNode.getParent();
    if (!NodeUtil.isNameDeclaration(assignment) && NodeUtil.isExpressionResultUsed(assignment)) {
      // e.g. don't change "if (alias = someVariable)" to "if (alias = null)"
      // TODO(lharker): instead replace the entire assignment with the RHS - "alias = x" becomes "x"
      return false;
    }
    Node aliasParent = alias.getNode().getParent();
    aliasParent.replaceChild(alias.getNode(), IR.nullNode());
    alias.name.removeRef(alias);
    codeChanged = true;
    compiler.reportChangeToEnclosingScope(aliasParent);
    return true;
  }
977109
static boolean hasDuplicateDeclarationSuppression(
      AbstractCompiler compiler, Node n, Node origVar) {
    // For VarCheck and VariableReferenceCheck, variables in externs do not generate duplicate
    // warnings.
    if (isExternNamespace(n)) {
      return true;
    }
    return TypeValidator.hasDuplicateDeclarationSuppression(compiler, origVar);
  }
547114
@Override
    public void sawOpcode(int seen) {
        Integer tosIsSyncColReg = null;
        try {
            stack.precomputation(this);

            if (seen == Const.INVOKESPECIAL) {
                tosIsSyncColReg = checkConstructors();
            } else if (seen == Const.INVOKESTATIC) {
                tosIsSyncColReg = checkStaticCreations();
            } else if ((seen == Const.INVOKEVIRTUAL) || (seen == Const.INVOKEINTERFACE)) {
                tosIsSyncColReg = checkSelfReturningMethods();
            } else if (isAStore(seen)) {
                dealWithStoring(seen);
            } else if (isALoad(seen)) {
                int reg = RegisterUtils.getALoadReg(this, seen);
                RegisterInfo cri = suspectLocals.get(Integer.valueOf(reg));
                if ((cri != null) && !cri.getIgnore()) {
                    tosIsSyncColReg = Integer.valueOf(reg);
                }
            } else if (((seen == Const.PUTFIELD) || (seen == Const.ARETURN)) && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item item = stack.getStackItem(0);
                suspectLocals.remove(item.getUserValue());
            }

            if (!suspectLocals.isEmpty()) {
                if (isStandardInvoke(seen)) {
                    String sig = getSigConstantOperand();
                    int argCount = SignatureUtils.getNumParameters(sig);
                    if (stack.getStackDepth() >= argCount) {
                        for (int i = 0; i < argCount; i++) {
                            OpcodeStack.Item item = stack.getStackItem(i);
                            RegisterInfo cri = suspectLocals.get(item.getUserValue());
                            if (cri != null) {
                                if (SignatureUtils.similarPackages(SignatureUtils.getPackageName(SignatureUtils.stripSignature(getClassConstantOperand())),
                                        SignatureUtils.getPackageName(SignatureUtils.stripSignature(this.getClassName())), 2)) {
                                    cri.setPriority(LOW_PRIORITY);
                                } else {
                                    cri.setIgnore();
                                }
                            }
                        }
                    }
                } else if (seen == Const.MONITORENTER) {
                    // Assume if synchronized blocks are used then something
                    // tricky is going on.
                    // There is really no valid reason for this, other than
                    // folks who use
                    // synchronized blocks tend to know what's going on.
                    if (stack.getStackDepth() > 0) {
                        OpcodeStack.Item item = stack.getStackItem(0);
                        suspectLocals.remove(item.getUserValue());
                    }
                } else if ((seen == Const.AASTORE) && (stack.getStackDepth() > 0)) {
                    OpcodeStack.Item item = stack.getStackItem(0);
                    suspectLocals.remove(item.getUserValue());
                }
            }

            reportTroublesomeLocals();
        } finally {
            TernaryPatcher.pre(stack, seen);
            stack.sawOpcode(this, seen);
            TernaryPatcher.post(stack, seen);
            if ((tosIsSyncColReg != null) && (stack.getStackDepth() > 0)) {
                OpcodeStack.Item item = stack.getStackItem(0);
                item.setUserValue(tosIsSyncColReg);
            }
        }
    }
400432
@Override
  public void updateModifiableFieldsFromEntity(ProcessDefinitionEntity updatingProcessDefinition) {
    if (this.key.equals(updatingProcessDefinition.key) && this.deploymentId.equals(updatingProcessDefinition.deploymentId)) {
      // TODO: add a guard once the mismatch between revisions in deployment cache and database has been resolved
      this.revision = updatingProcessDefinition.revision;
      this.suspensionState = updatingProcessDefinition.suspensionState;
      this.historyTimeToLive = updatingProcessDefinition.historyTimeToLive;
    }
    else {
      LOG.logUpdateUnrelatedProcessDefinitionEntity(this.key, updatingProcessDefinition.key, this.deploymentId, updatingProcessDefinition.deploymentId);
    }
  }
337462
function processNonSpecifier() {
                    const secondToken = sourceCode.getFirstToken(node, 1)
                    if (isLeftBrace(secondToken)) {
                        setOffsetToToken(
                            [
                                secondToken,
                                sourceCode.getTokenAfter(secondToken),
                            ],
                            0,
                            importToken
                        )
                        tokens.push(
                            sourceCode.getLastToken(node, hasSemi ? 2 : 1), // from
                            sourceCode.getLastToken(node, hasSemi ? 1 : 0) // "foo"
                        )
                    } else {
                        tokens.push(
                            sourceCode.getLastToken(node, hasSemi ? 1 : 0)
                        )
                    }
                }
623312
function replaceDefine(code) {
    var defineList = getDefineBlock(code);
    var segments = [];
    var index = 0;
    defineList.forEach(function (block) {

        if (block.type === 'function') {
            segments.push(code.slice(index, block.defineRange[0]));
            index = block.factoryRange[0] + 1;

            block.returnRange.forEach(function (range) {
                segments.push(code.slice(index, range[0]));
                segments.push('module.exports =');
                segments.push(code.slice(range[0] + 6, range[1]));
                index = range[1];
            });
            segments.push(code.slice(index, block.factoryRange[1] - 1));

            index = block.defineRange[1];
        }
        else if (block.type === 'object') {
            segments.push(code.slice(index, block.defineRange[0]));
            segments.push('module.exports = ');
            segments.push(code.slice(block.factoryRange[0], block.factoryRange[1]) + ';');
            index = block.defineRange[1];
        }
    });

    segments.push(code.slice(index));

    code = segments.join('');

    return code;
}
544560
private void convertTokenDefinitions() throws GrammarException,
	    TreeException {
	tokenVisibility.clear();
	Map<String, ParseTreeNode> helpers = getHelperTokens();
	Map<String, ParseTreeNode> tokens = getTokens();
	convertTokenDefinitions(helpers, tokens);
    }
126459
void initInputsByIdMap() {
    inputsById.clear();
    for (CompilerInput input : externs) {
      InputId id = input.getInputId();
      CompilerInput previous = putCompilerInput(id, input);
      if (previous != null) {
        report(JSError.make(DUPLICATE_EXTERN_INPUT, input.getName()));
      }
    }
    for (CompilerInput input : moduleGraph.getAllInputs()) {
      InputId id = input.getInputId();
      CompilerInput previous = putCompilerInput(id, input);
      if (previous != null) {
        report(JSError.make(DUPLICATE_INPUT, input.getName()));
      }
    }
  }