Package com.google.javascript.jscomp.NameReferenceGraph

Examples of com.google.javascript.jscomp.NameReferenceGraph.Name


    }
  }

  private void connectUnknowns() {
    for (GraphNode<Name, Reference> node : graph.getNodes()) {
      Name name = node.getValue();
      String propName = name.getPropertyName();
      if (propName == null) {
        continue;
      }
      Collection<NameUse> uses = unknownNameUse.get(propName);
      if (uses != null) {
View Full Code Here


  /**
   * Find the first containing function that's not an function expression
   * closure.
   */
  private Name getNamedContainingFunction() {
    Name containingFn = null;
    int pos;
    for (pos = currentFunctionStack.size() - 1; pos >= 0; pos = pos - 1) {
      Name cf = currentFunctionStack.get(pos);
      if (cf != graph.unknown) {
        containingFn = cf;
        break;
      }
    }
View Full Code Here

          }
          if (lhs.isName() ||
              lhs.isGetProp() ||
              rhs.isGetProp()) {
            if (NodeUtil.isPrototypeProperty(lhs)) {
              Name name = recordPrototypePropDefinition(
                  lhs, getType(rhs), n);
              name.setAliased(true);
            }
          }
          maybeAliasNamesOnAssign(lhs, rhs);
          break;
View Full Code Here

      if (type.isConstructor()) {
        return recordClassConstructorOrInterface(
            name, type.toMaybeFunctionType(),
            n, rValue);
      } else {
        Name symbol = graph.defineNameIfNotExists(name, isExtern);
        symbol.setType(type);
        if (n.isAssign()) {
          symbol.addAssignmentDeclaration(n);
        } else {
          symbol.addFunctionDeclaration(n);
        }
        return symbol;
      }
    }
View Full Code Here

      recordClassConstructorOrInterface(
          className, classType, null, null);

      String qNameStr = className + ".prototype." +
          NodeUtil.getPrototypePropertyName(qName);
      Name prototypeProp = graph.defineNameIfNotExists(qNameStr, isExtern);
      Preconditions.checkNotNull(prototypeProp,
          "%s should be in the name graph as a node.", qNameStr);
      if (assign != null) {
        prototypeProp.addAssignmentDeclaration(assign);
      }
      prototypeProp.setType(type);
      return prototypeProp;
    }
View Full Code Here

      if (isExtern) {
        // Don't count reference in extern as a use.
        return null;
      } else {
        Reference reference = new Reference(n);
        Name name = graph.defineNameIfNotExists(n.getQualifiedName(), isExtern);
        name.setType(getType(n));
        graph.connect(getNamedContainingFunction(), reference, name);
        return reference;
      }
    }
View Full Code Here

     * the properties and prototype properties of this name in the graph.
     */
    private Name recordClassConstructorOrInterface(
        String name, FunctionType type, @Nullable Node n, @Nullable Node rhs) {
      Preconditions.checkArgument(type.isConstructor() || type.isInterface());
      Name symbol = graph.defineNameIfNotExists(name, isExtern);
      if (rhs != null) {
        // TODO(user): record the definition.
        symbol.setType(getType(rhs));
        if (n.isAssign()) {
          symbol.addAssignmentDeclaration(n);
        } else {
          symbol.addFunctionDeclaration(n);
        }
      }
      ObjectType prototype = type.getPrototype();
      for (String prop : prototype.getOwnPropertyNames()) {
        graph.defineNameIfNotExists(
View Full Code Here

   * Remove all properties under a given name if the property name is
   * never referenced.
   */
  private void removeUnusedProperties(NameReferenceGraph graph) {
    for (GraphNode<Name, Reference> node : graph.getNodes()) {
      Name name = node.getValue();
      NameInfo nameInfo = node.getAnnotation();
      if (nameInfo == null || !nameInfo.isReferenced()) {
        if (canModifyExterns || !name.isExtern()) {
          name.remove();
          compiler.reportCodeChange();
          logger.fine("Removed unused name" + name);
        }
      }
    }
View Full Code Here

      for (Function function : getAllFunctions()) {
        if (!function.isMain()) {
          String functionName = function.getName();

          if (functionName != null) {
            Name symbol = referenceGraph.getSymbol(functionName);
            updateFunctionForName(function, symbol);
          }
        }
      }
    } else {
View Full Code Here

    }
  }

  private void connectUnknowns() {
    for (GraphNode<Name, Reference> node : graph.getNodes()) {
      Name name = node.getValue();
      String propName = name.getPropertyName();
      if (propName == null) {
        continue;
      }
      Collection<NameUse> uses = unknownNameUse.get(propName);
      if (uses != null) {
View Full Code Here

TOP

Related Classes of com.google.javascript.jscomp.NameReferenceGraph.Name

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.