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


Java Node.isQualifiedName方法代码示例

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


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

示例1: apply

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
public boolean apply(Node n) {
  if (!n.isQualifiedName()) {
    return false;
  }

  Node current;
  for (current = n;
       current.getType() == Token.GETPROP;
       current = current.getFirstChild()) {
    if (newNodes.contains(current)) {
      return true;
    }
  }

  return current.getType() == Token.NAME && newNodes.contains(current);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:17,代码来源:GlobalNamespace.java

示例2: visitInterfaceGetprop

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Visits an ASSIGN node for cases such as
 * <pre>
 * interface.property2.property = ...;
 * </pre>
 */
private void visitInterfaceGetprop(NodeTraversal t, Node assign, Node object,
    String property, Node lvalue, Node rvalue) {

  JSType rvalueType = getJSType(rvalue);
  String abstractMethodName =
      compiler.getCodingConvention().getAbstractMethodName();
  if (!rvalueType.isOrdinaryFunction() &&
      !(rvalue.isQualifiedName() &&
        rvalue.getQualifiedName().equals(abstractMethodName))) {
    compiler.report(JSError.make(t, object, INTERFACE_FUNCTION_MEMBERS_ONLY,
                                 abstractMethodName));
  }

  if (assign.getLastChild().getType() == Token.FUNCTION
      && !NodeUtil.isEmptyBlock(assign.getLastChild().getLastChild())) {
    compiler.report(JSError.make(t, object, INTERFACE_FUNCTION_NOT_EMPTY,
                                 abstractMethodName));
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:26,代码来源:TypeCheck.java

示例3: 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

示例4: 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

示例5: getPreciserScopeKnowingConditionOutcome

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
public FlowScope getPreciserScopeKnowingConditionOutcome(Node condition,
    FlowScope blindScope, boolean outcome) {
  if (condition.getType() == CALL && condition.getChildCount() == 2) {
    Node callee = condition.getFirstChild();
    Node param = condition.getLastChild();
    if (callee.getType() == GETPROP && param.isQualifiedName()) {
      JSType paramType =  getTypeIfRefinable(param, blindScope);
      Node left = callee.getFirstChild();
      Node right = callee.getLastChild();
      if (left.getType() == NAME && "goog".equals(left.getString()) &&
          right.getType() == STRING) {
        Function<TypeRestriction, JSType> restricter =
            restricters.get(right.getString());
        if (restricter != null) {
          return restrictParameter(param, paramType, blindScope, restricter,
              outcome);
        }
      }
    }
  }
  return nextPreciserScopeKnowingConditionOutcome(
      condition, blindScope, outcome);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:ClosureReverseAbstractInterpreter.java

示例6: isValidDefineValue

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Determines whether the given value may be assigned to a define.
 *
 * @param val The value being assigned.
 * @param defines The list of names of existing defines.
 */
static boolean isValidDefineValue(Node val, Set<String> defines) {
  switch (val.getType()) {
    case Token.STRING:
    case Token.NUMBER:
    case Token.TRUE:
    case Token.FALSE:
      return true;

    // Single operators are valid if the child is valid.
    case Token.BITAND:
    case Token.BITNOT:
    case Token.BITOR:
    case Token.BITXOR:
    case Token.NOT:
    case Token.NEG:
      return isValidDefineValue(val.getFirstChild(), defines);

    // Names are valid if and only if they are defines themselves.
    case Token.NAME:
    case Token.GETPROP:
      if (val.isQualifiedName()) {
        return defines.contains(val.getQualifiedName());
      }
  }
  return false;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:33,代码来源:NodeUtil.java

示例7: visit

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
public void visit(NodeTraversal t, Node n, Node parent) {
  if (n.getType() == Token.ASSIGN) {
    Node nameNode = n.getFirstChild();
    Node valueNode = n.getLastChild();

    if (nameNode.isQualifiedName() &&
        valueNode.isQualifiedName() &&
        ABSTRACT_METHOD_NAME.equals(valueNode.getQualifiedName())) {
      abstractMethodAssignmentNodes.add(new RemovableAssignment(
          n.getFirstChild(), n, t));
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:14,代码来源:GoogleCodeRemoval.java

示例8: getPrototypePropertyOwner

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Given a node, determines whether that node names a prototype
 * property, and if so, returns the qualfied name node representing
 * the owner of that property. Otherwise, returns null.
 */
private static Node getPrototypePropertyOwner(Node n) {
  if (n.getType() == Token.GETPROP) {
    Node firstChild = n.getFirstChild();
    if (firstChild.getType() == Token.GETPROP &&
        firstChild.getLastChild().getString().equals("prototype")) {
      Node maybeOwner = firstChild.getFirstChild();
      if (maybeOwner.isQualifiedName()) {
        return maybeOwner;
      }
    }
  }
  return null;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:19,代码来源:TypedScopeCreator.java

示例9: getSingletonGetterClassName

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
@Override
public String getSingletonGetterClassName(Node callNode) {
  Node callName = callNode.getFirstChild();
  if (!"goog.addSingletonGetter".equals(callName.getQualifiedName()) ||
      callName.getChildCount() != 2) {
    return null;
  }

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

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

示例10: getClassOfMethod

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
/**
 * Gets the type of the class that "owns" a method, or null if
 * we know that its un-owned.
 */
private JSType getClassOfMethod(Node n, Node parent) {
  if (parent.getType() == Token.ASSIGN) {
    Node lValue = parent.getFirstChild();
    if (lValue.isQualifiedName()) {
      if (lValue.getType() == Token.GETPROP) {
        // We have an assignment of the form "a.b = ...".
        JSType lValueType = lValue.getJSType();
        if (lValueType != null && lValueType.isConstructor()) {
          // If a.b is a constructor, then everything in this function
          // belongs to the "a.b" type.
          return ((FunctionType) lValueType).getInstanceType();
        } else {
          // If a.b is not a constructor, then treat this as a method
          // of whatever type is on "a".
          return normalizeClassType(lValue.getFirstChild().getJSType());
        }
      } else {
        // We have an assignment of the form "a = ...", so pull the
        // type off the "a".
        return normalizeClassType(lValue.getJSType());
      }
    }
  } else if (NodeUtil.isFunctionDeclaration(n) ||
             parent.getType() == Token.NAME) {
    return normalizeClassType(n.getJSType());
  }

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

示例11: visit

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
public void visit(NodeTraversal t, Node n, Node parent) {
  if (OBJECT_PROPERTY_STRING.equals(n.getQualifiedName())) {
    Node newName =
        Node.newString(Token.NAME, EXTERN_OBJECT_PROPERTY_STRING);
    newName.copyInformationFrom(n);
    parent.replaceChild(n, newName);
    compiler.reportCodeChange();
    return;
  }

  // Rewrite "new goog.testing.ObjectPropertyString(foo, 'bar')" to
  // "new goog.testing.ObjectPropertyString(window, foo.bar)" and
  // issues errors if bad arguments are encountered.
  if (n.getType() != Token.NEW) {
    return;
  }

  Node objectName = n.getFirstChild();

  if (!EXTERN_OBJECT_PROPERTY_STRING.equals(
          objectName.getQualifiedName())) {
    return;
  }

  if (n.getChildCount() != 3) {
    compiler.report(JSError.make(t, n, INVALID_NUM_ARGUMENTS_ERROR,
        "" + n.getChildCount()));
    return;
  }

  Node firstArgument = objectName.getNext();
  if (!firstArgument.isQualifiedName()) {
    compiler.report(JSError.make(t, firstArgument,
        QUALIFIED_NAME_EXPECTED_ERROR,
        Token.name(firstArgument.getType())));
    return;
  }

  Node secondArgument = firstArgument.getNext();
  if (secondArgument.getType() != Token.STRING) {
    compiler.report(JSError.make(t, secondArgument,
        STRING_LITERAL_EXPECTED_ERROR,
        Token.name(secondArgument.getType())));
    return;
  }

  Node newFirstArgument = NodeUtil.newQualifiedNameNode(
      compiler.getCodingConvention().getGlobalObject(),
      firstArgument.getLineno(), firstArgument.getCharno());
  Node newSecondArgument = NodeUtil.newQualifiedNameNode(
      firstArgument.getQualifiedName() + "." +
      firstArgument.getNext().getString(),
      secondArgument.getLineno(), secondArgument.getCharno());
  n.replaceChild(firstArgument, newFirstArgument);
  n.replaceChild(secondArgument, newSecondArgument);

  compiler.reportCodeChange();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:59,代码来源:ObjectPropertyStringPreprocess.java

示例12: visit

import com.google.javascript.rhino.Node; //导入方法依赖的package包/类
public void visit(NodeTraversal t, Node n, Node parent) {
  // VOID nodes appear when there are extra semicolons at the BLOCK level.
  // I've been unable to think of any cases where this indicates a bug,
  // and apparently some people like keeping these semicolons around,
  // so we'll allow it.
  if (n.getType() == Token.EMPTY ||
      n.getType() == Token.COMMA) {
    return;
  }

  if (parent == null)
    return;

  int pt = parent.getType();
  if (pt == Token.COMMA) {
    Node gramps = parent.getParent();
    if (gramps.getType() == Token.CALL &&
        parent == gramps.getFirstChild()) {
      // Semantically, a direct call to eval is different from an indirect
      // call to an eval. See Ecma-262 S15.1.2.1. So it's ok for the first
      // expression to a comma to be a no-op if it's used to indirect
      // an eval.
      if (n == parent.getFirstChild() &&
          parent.getChildCount() == 2 &&
          n.getNext().getType() == Token.NAME &&
          "eval".equals(n.getNext().getString())) {
        return;
      }
    }

    if (n == parent.getLastChild()) {
      for (Node an : parent.getAncestors()) {
        int ancestorType = an.getType();
        if (ancestorType == Token.COMMA)
          continue;
        if (ancestorType != Token.EXPR_RESULT &&
            ancestorType != Token.BLOCK)
          return;
        else
          break;
      }
    }
  } else if (pt != Token.EXPR_RESULT && pt != Token.BLOCK) {
    if (pt == Token.FOR && parent.getChildCount() == 4 &&
        (n == parent.getFirstChild() ||
         n == parent.getFirstChild().getNext().getNext())) {
      // Fall through and look for warnings for the 1st and 3rd child
      // of a for.
    } else {
      return;  // it might be ok to not have a side-effect
    }
  }
  if (NodeUtil.isSimpleOperatorType(n.getType()) ||
      !NodeUtil.mayHaveSideEffects(n)) {
    if (n.isQualifiedName() && n.getJSDocInfo() != null) {
      // This no-op statement was there so that JSDoc information could
      // be attached to the name. This check should not complain about it.
      return;
    } else if (NodeUtil.isExpressionNode(n)) {
      // we already reported the problem when we visited the child.
      return;
    }

    String msg = "This code lacks side-effects. Is there a bug?";
    if (n.getType() == Token.STRING) {
      msg = "Is there a missing '+' on the previous line?";
    }

    t.getCompiler().report(
        JSError.make(t, n, level, USELESS_CODE_ERROR, msg));
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:73,代码来源:CheckSideEffects.java


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