当前位置: 首页>>代码示例>>Java>>正文


Java Node.getQualifiedName方法代码示例

本文整理汇总了Java中com.google.javascript.rhino.Node.getQualifiedName方法的典型用法代码示例。如果您正苦于以下问题:Java Node.getQualifiedName方法的具体用法?Java Node.getQualifiedName怎么用?Java Node.getQualifiedName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.rhino.Node的用法示例。


在下文中一共展示了Node.getQualifiedName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: trySimplifyNewDate

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Try to simplify "new Date(goog.now())" to "new Date()".
 */
private void trySimplifyNewDate(NodeTraversal t, Node n, Node parent) {
  if (!rewriteNewDateGoogNow) {
    return;
  }
  Preconditions.checkArgument(n.getType() == Token.NEW);
  Node date = n.getFirstChild();
  if (!NodeUtil.isName(date) || !"Date".equals(date.getString())) {
    return;
  }
  Node callGoogNow = date.getNext();
  if (callGoogNow == null || !NodeUtil.isCall(callGoogNow) ||
      callGoogNow.getNext() != null) {
    return;
  }
  Node googNow = callGoogNow.getFirstChild();
  String googNowQName = googNow.getQualifiedName();
  if (googNowQName == null || !"goog.now".equals(googNowQName)
      || googNow.getNext() != null) {
    return;
  }
  n.removeChild(callGoogNow);
  compiler.reportCodeChange();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:27,代码来源:ProcessClosurePrimitives.java

示例2: visitFunctionNode

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private void visitFunctionNode(Node n, Node parent) {
  Node name = null;
  JSDocInfo info = parent.getJSDocInfo();
  if (info != null && info.isConstructor()) {
    name = parent.getFirstChild();
  } else {
    // look to the child, maybe it's a named function
    info = n.getJSDocInfo();
    if (info != null && info.isConstructor()) {
      name = n.getFirstChild();
    }
  }
  if (name != null && name.isQualifiedName()) {
    String qualifiedName = name.getQualifiedName();
    if (!this.convention.isPrivate(qualifiedName)) {
      Visibility visibility = info.getVisibility();
      if (!visibility.equals(JSDocInfo.Visibility.PRIVATE)) {
        ctors.put(qualifiedName, name);
      }
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:23,代码来源:CheckProvides.java

示例3: declareNameInScope

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Declares a refined type in {@code scope} for the name represented by
 * {@code node}. It must be possible to refine the type of the given node in
 * the given scope, as determined by {@link #getTypeIfRefinable}.
 */
protected void declareNameInScope(FlowScope scope, Node node, JSType type) {
  switch (node.getType()) {
    case Token.NAME:
      scope.inferSlotType(node.getString(), type);
      break;

    case Token.GETPROP:
      String qualifiedName = node.getQualifiedName();
      Preconditions.checkNotNull(qualifiedName);

      JSType origType = node.getJSType();
      origType = origType == null ? getNativeType(UNKNOWN_TYPE) : origType;
      scope.inferQualifiedSlot(qualifiedName, origType, type);
      break;

    default:
      throw new IllegalArgumentException("Node cannot be refined. \n" +
          node.toStringTree());
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:26,代码来源:ChainableReverseAbstractInterpreter.java

示例4: getObjectLiteralCast

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
public ObjectLiteralCast getObjectLiteralCast(NodeTraversal t,
    Node callNode) {
  Preconditions.checkArgument(callNode.getType() == Token.CALL);
  Node callName = callNode.getFirstChild();
  if (!"goog.reflect.object".equals(callName.getQualifiedName()) ||
      callName.getChildCount() != 2) {
    return null;
  }

  Node typeNode = callName.getNext();
  if (!typeNode.isQualifiedName()) {
    return null;
  }

  Node objectNode = typeNode.getNext();
  if (objectNode.getType() != Token.OBJECTLIT) {
    t.getCompiler().report(JSError.make(t.getSourceName(), callNode,
                                        OBJECTLIT_EXPECTED));
    return null;
  }

  return new ObjectLiteralCast(typeNode.getQualifiedName(),
                               typeNode.getNext());
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:26,代码来源:ClosureCodingConvention.java

示例5: identifyTypeDefAssign

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
public String identifyTypeDefAssign(Node n) {
  Node firstChild = n.getFirstChild();
  int type = n.getType();
  if (type == Token.ASSIGN) {
    if (TYPEDEF_NAME.equals(n.getLastChild().getQualifiedName())) {
      return firstChild.getQualifiedName();
    }
  } else if (type == Token.VAR && firstChild.hasChildren()) {
    if (TYPEDEF_NAME.equals(
            firstChild.getFirstChild().getQualifiedName())) {
      return firstChild.getString();
    }
  }

  return null;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:18,代码来源:ClosureCodingConvention.java

示例6: isPrototypeProperty

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
static boolean isPrototypeProperty(Node n) {
  String lhsString = n.getQualifiedName();
  if (lhsString == null) {
    return false;
  }
  int prototypeIdx = lhsString.indexOf(".prototype.");
  return prototypeIdx != -1;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:9,代码来源:NodeUtil.java

示例7: SymbolExport

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
public SymbolExport(String symbolName, Node value) {
  this.symbolName = symbolName;
  this.value = value;

  String qualifiedName = value.getQualifiedName();

  if (qualifiedName != null) {
    mappedPaths.put(qualifiedName, symbolName);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:11,代码来源:ExternExportsPass.java

示例8: inferThisType

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Infers the type of {@code this}.
 * @param info The JSDocInfo for this function.
 * @param owner The node for the object whose prototype "owns" this function.
 *     For example, {@code A} in the expression {@code A.prototype.foo}. May
 *     be null to indicate that this is not a prototype property.
 */
FunctionTypeBuilder inferThisType(JSDocInfo info,
    @Nullable Node owner) {
  ObjectType maybeThisType = null;
  if (info != null && info.hasThisType()) {
    maybeThisType = ObjectType.cast(info.getThisType().evaluate(scope));
  }
  if (maybeThisType != null) {
    // TODO(user): Doing an instanceof check here is too
    // restrictive as (Date,Error) is, for instance, an object type
    // even though its implementation is a UnionType. Would need to
    // create interfaces JSType, ObjectType, FunctionType etc and have
    // separate implementation instead of the class hierarchy, so that
    // union types can also be object types, etc.
    thisType = maybeThisType;
  } else if (owner != null &&
             (info == null || !info.hasType())) {
    // If the function is of the form:
    // x.prototype.y = function() {}
    // then we can assume "x" is the @this type. On the other hand,
    // if it's of the form:
    // /** @type {Function} */ x.prototype.y;
    // then we should not give it a @this type.
    String ownerTypeName = owner.getQualifiedName();
    ObjectType ownerType = ObjectType.cast(
        typeRegistry.getType(
            scope, ownerTypeName, sourceName,
            owner.getLineno(), owner.getCharno()));
    if (ownerType != null) {
      thisType = ownerType;
    }
  }

  return this;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:42,代码来源:FunctionTypeBuilder.java

示例9: getTypeIfRefinable

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Returns the type of a node in the given scope if the node corresponds to a
 * name whose type is capable of being refined.
 * @return The current type of the node if it can be refined, null otherwise.
 */
JSType getTypeIfRefinable(Node node, FlowScope scope) {
  switch (node.getType()) {
    case Token.NAME:
      StaticSlot<JSType> nameVar = scope.getSlot(node.getString());
      if (nameVar != null) {
        JSType nameVarType = nameVar.getType();
        if (nameVarType == null) {
          nameVarType = node.getJSType();
        }
        return nameVarType;
      }
      return null;

    case Token.GETPROP:
      String qualifiedName = node.getQualifiedName();
      if (qualifiedName == null) {
        return null;
      }
      StaticSlot<JSType> propVar = scope.getSlot(qualifiedName);
      JSType propVarType = null;
      if (propVar != null) {
        propVarType = propVar.getType();
      }
      if (propVarType == null) {
        propVarType = node.getJSType();
      }
      if (propVarType == null) {
        propVarType = getNativeType(UNKNOWN_TYPE);
      }
      return propVarType;
  }
  return null;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:39,代码来源:ChainableReverseAbstractInterpreter.java

示例10: maybeRecordExport

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
private void maybeRecordExport(Node call) {
  Preconditions.checkArgument(NodeUtil.isCall(call));
  Node getProp = call.getFirstChild();
  if (!NodeUtil.isGetProp(getProp)) {
    return;
  }

  String propQName = getProp.getQualifiedName();

  if (propQName == null) {
    return;
  }

  // Keep track of calls to "call" and "apply" because they mess up the name
  // graph.
  if (propQName.endsWith(".call") || propQName.endsWith(".apply")) {
    graph.defineNameIfNotExists(getProp.getFirstChild().getQualifiedName(),
        isExtern).markExposedToCallOrApply();
  }

  if (!"goog.exportSymbol".equals(propQName)) {
    return;
  }

  Node symbol = getProp.getNext();
  if (!NodeUtil.isString(symbol)) {
    return;
  }

  Node obj = symbol.getNext();
  String qName = obj.getQualifiedName();

  if (qName == null || obj.getNext() != null) {
    return;
  }

  graph.defineNameIfNotExists(qName, false).markExported();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:39,代码来源:NameReferenceGraphConstruction.java

示例11: isStaticNameReference

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * @return true if n MUST be a static name reference.
 */
private boolean isStaticNameReference(Node n, Scope scope) {
  Preconditions.checkArgument(NodeUtil.isName(n) || NodeUtil.isGetProp(n));
  if (NodeUtil.isName(n)) {
    return true;
  }
  String qName = n.getQualifiedName();
  if (qName == null) {
    return false;
  }
  // TODO(user): This does not always work due to type system bugs.
  return scope.isDeclared(qName, true);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:16,代码来源:NameReferenceGraphConstruction.java

示例12: caseIn

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Given 'property in object', ensures that the object has the property in the
 * informed scope by defining it as a qualified name if the object type lacks
 * the property and it's not in the blind scope.
 * @param object The node of the right-side of the in.
 * @param propertyName The string of the left-side of the in.
 */
private FlowScope caseIn(Node object, String propertyName, FlowScope blindScope) {
  JSType jsType = object.getJSType();
  jsType = this.getRestrictedWithoutNull(jsType);
  jsType = this.getRestrictedWithoutUndefined(jsType);

  boolean hasProperty = false;
  ObjectType objectType = ObjectType.cast(jsType);
  if (objectType != null) {
    hasProperty = objectType.hasProperty(propertyName);
  }
  if (!hasProperty) {
    String qualifiedName = object.getQualifiedName();
    if (qualifiedName != null) {
      String propertyQualifiedName = qualifiedName + "." + propertyName;
      if (blindScope.getSlot(propertyQualifiedName) == null) {
        FlowScope informed = blindScope.createChildFlowScope();
        JSType unknownType = typeRegistry.getNativeType(
            JSTypeNative.UNKNOWN_TYPE);
        informed.inferQualifiedSlot(
            propertyQualifiedName, unknownType, unknownType);
        return informed;
      }
    }
  }
  return blindScope;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:34,代码来源:SemanticReverseAbstractInterpreter.java

示例13: SubclassRelationship

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
SubclassRelationship(SubclassType type,
    Node subclassNode, Node superclassNode) {
  this.type = type;
  this.subclassNode = subclassNode;
  this.superclassNode = superclassNode;
  this.subclassName = subclassNode.getQualifiedName();
  this.superclassName = superclassNode.getQualifiedName();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:9,代码来源:CodingConvention.java

示例14: checkForTypedef

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Handle typedefs.
 * @param t The current traversal.
 * @param candidate A qualified name node.
 * @param info JSDoc comments.
 */
private void checkForTypedef(
    NodeTraversal t, Node candidate, JSDocInfo info) {
  if (info == null || !info.hasTypedefType()) {
    return;
  }

  String typedef = candidate.getQualifiedName();
  if (typedef == null) {
    return;
  }

  // TODO(nicksantos|user): This is a terrible, terrible hack
  // to bail out on recusive typedefs. We'll eventually need
  // to handle these properly.
  typeRegistry.forwardDeclareType(typedef);

  JSType realType = info.getTypedefType().evaluate(scope);
  if (realType == null) {
    compiler.report(
        JSError.make(
            t.getSourceName(), candidate, MALFORMED_TYPEDEF, typedef));
  }

  typeRegistry.declareType(typedef, realType);
  if (candidate.getType() == Token.GETPROP) {
    defineSlot(candidate, candidate.getParent(),
        typeRegistry.getNativeType(NO_TYPE), false);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:36,代码来源:TypedScopeCreator.java

示例15: shouldTraverse

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Since this pass reports errors only when a global {@code this} keyword
 * is encountered, there is no reason to traverse non global contexts.
 */
public boolean shouldTraverse(NodeTraversal t, Node n, Node parent) {
  
  if (n.getType() == Token.FUNCTION) {
    // Don't traverse functions that are constructors or have the @this
    // annotation.
    JSDocInfo jsDoc = getFunctionJsDocInfo(n);
    if (jsDoc != null && (jsDoc.isConstructor() || jsDoc.hasThisType())) {
      return false;
    }
  }
  
  if (parent != null && parent.getType() == Token.ASSIGN) {
    Node lhs = parent.getFirstChild();
    Node rhs = lhs.getNext();
    
    if (n == lhs) {
      // Always traverse the left side of the assignment. To handle
      // nested assignments properly (e.g., (a = this).property = c;),
      // assignLhsChild should not be overridden.
      if (assignLhsChild == null) {
        assignLhsChild = lhs;
      }
    } else {
      // Only traverse the right side if it's not an assignment to a prototype
      // property or subproperty.
      if (lhs.getType() == Token.GETPROP) {
        if (lhs.getLastChild().getString().equals("prototype")) {
          return false;
        }
        String leftName = lhs.getQualifiedName();
        if (leftName != null && leftName.contains(".prototype.")) {
          return false;
        }
      }
    }
  }
  
  return true;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:44,代码来源:CheckGlobalThis.java


注:本文中的com.google.javascript.rhino.Node.getQualifiedName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。