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


Java FunctionParamBuilder.newParameterFromNode方法代码示例

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


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

示例1: inferFromOverriddenFunction

import com.google.javascript.rhino.jstype.FunctionParamBuilder; //导入方法依赖的package包/类
/**
 * Infer the parameter and return types of a function from
 * the parameter and return types of the function it is overriding.
 *
 * @param oldType The function being overridden.
 * @param paramsParent The LP node of the function that we're assigning to.
 *     If null, that just means we're not initializing this to a function
 *     literal.
 */
FunctionTypeBuilder inferFromOverriddenFunction(
    FunctionType oldType, @Nullable Node paramsParent) {
  returnType = oldType.getReturnType();
  if (paramsParent == null) {
    // Not a function literal.
    parametersNode = oldType.getParametersNode();
    if (parametersNode == null) {
      parametersNode = new FunctionParamBuilder(typeRegistry).build();
    }
  } else {
    // We're overriding with a function literal. Apply type information
    // to each parameter of the literal.
    FunctionParamBuilder paramBuilder =
        new FunctionParamBuilder(typeRegistry);
    Iterator<Node> oldParams = oldType.getParameters().iterator();
    boolean warnedAboutArgList = false;
    for (Node currentParam = paramsParent.getFirstChild();
         currentParam != null; currentParam = currentParam.getNext()) {
      if (oldParams.hasNext()) {
        paramBuilder.newParameterFromNode(oldParams.next());
      } else {
        warnedAboutArgList |= addParameter(
            paramBuilder,
            typeRegistry.getNativeType(UNKNOWN_TYPE),
            warnedAboutArgList,
            codingConvention.isOptionalParameter(currentParam),
            codingConvention.isVarArgsParameter(currentParam));
      }
    }
    parametersNode = paramBuilder.build();
  }
  return this;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:43,代码来源:FunctionTypeBuilder.java

示例2: inferFromOverriddenFunction

import com.google.javascript.rhino.jstype.FunctionParamBuilder; //导入方法依赖的package包/类
/**
 * Infer the parameter and return types of a function from
 * the parameter and return types of the function it is overriding.
 *
 * @param oldType The function being overridden. Does nothing if this is null.
 * @param paramsParent The LP node of the function that we're assigning to.
 *     If null, that just means we're not initializing this to a function
 *     literal.
 */
FunctionTypeBuilder inferFromOverriddenFunction(
    @Nullable FunctionType oldType, @Nullable Node paramsParent) {
  if (oldType == null) {
    return this;
  }

  returnType = oldType.getReturnType();
  returnTypeInferred = oldType.isReturnTypeInferred();
  if (paramsParent == null) {
    // Not a function literal.
    parametersNode = oldType.getParametersNode();
    if (parametersNode == null) {
      parametersNode = new FunctionParamBuilder(typeRegistry).build();
    }
  } else {
    // We're overriding with a function literal. Apply type information
    // to each parameter of the literal.
    FunctionParamBuilder paramBuilder =
        new FunctionParamBuilder(typeRegistry);
    Iterator<Node> oldParams = oldType.getParameters().iterator();
    boolean warnedAboutArgList = false;
    boolean oldParamsListHitOptArgs = false;
    for (Node currentParam = paramsParent.getFirstChild();
         currentParam != null; currentParam = currentParam.getNext()) {
      if (oldParams.hasNext()) {
        Node oldParam = oldParams.next();
        Node newParam = paramBuilder.newParameterFromNode(oldParam);

        oldParamsListHitOptArgs = oldParamsListHitOptArgs ||
            oldParam.isVarArgs() ||
            oldParam.isOptionalArg();

        // The subclass method might right its var_args as individual
        // arguments.
        if (currentParam.getNext() != null && newParam.isVarArgs()) {
          newParam.setVarArgs(false);
          newParam.setOptionalArg(true);
        }
      } else {
        warnedAboutArgList |= addParameter(
            paramBuilder,
            typeRegistry.getNativeType(UNKNOWN_TYPE),
            warnedAboutArgList,
            codingConvention.isOptionalParameter(currentParam) ||
                oldParamsListHitOptArgs,
            codingConvention.isVarArgsParameter(currentParam));
      }
    }
    parametersNode = paramBuilder.build();
  }
  return this;
}
 
开发者ID:ehsan,项目名称:js-symbolic-executor,代码行数:62,代码来源:FunctionTypeBuilder.java

示例3: inferFromOverriddenFunction

import com.google.javascript.rhino.jstype.FunctionParamBuilder; //导入方法依赖的package包/类
/**
 * Infer the parameter and return types of a function from
 * the parameter and return types of the function it is overriding.
 *
 * @param oldType The function being overridden. Does nothing if this is null.
 * @param paramsParent The LP node of the function that we're assigning to.
 *     If null, that just means we're not initializing this to a function
 *     literal.
 */
FunctionTypeBuilder inferFromOverriddenFunction(
    @Nullable FunctionType oldType, @Nullable Node paramsParent) {
  if (oldType == null) {
    return this;
  }

  returnType = oldType.getReturnType();
  returnTypeInferred = oldType.isReturnTypeInferred();
  if (paramsParent == null) {
    // Not a function literal.
    parametersNode = oldType.getParametersNode();
    if (parametersNode == null) {
      parametersNode = new FunctionParamBuilder(typeRegistry).build();
    }
  } else {
    // We're overriding with a function literal. Apply type information
    // to each parameter of the literal.
    FunctionParamBuilder paramBuilder =
        new FunctionParamBuilder(typeRegistry);
    Iterator<Node> oldParams = oldType.getParameters().iterator();
    boolean warnedAboutArgList = false;
    boolean oldParamsListHitOptArgs = false;
    for (Node currentParam = paramsParent.getFirstChild();
         currentParam != null; currentParam = currentParam.getNext()) {
      if (oldParams.hasNext()) {
        Node oldParam = oldParams.next();
        Node newParam = paramBuilder.newParameterFromNode(oldParam);

        oldParamsListHitOptArgs = oldParamsListHitOptArgs ||
            oldParam.isVarArgs() ||
            oldParam.isOptionalArg();

        // The subclass method might write its var_args as individual
        // arguments.
        if (currentParam.getNext() != null && newParam.isVarArgs()) {
          newParam.setVarArgs(false);
          newParam.setOptionalArg(true);
        }
      } else {
        warnedAboutArgList |= addParameter(
            paramBuilder,
            typeRegistry.getNativeType(UNKNOWN_TYPE),
            warnedAboutArgList,
            codingConvention.isOptionalParameter(currentParam) ||
                oldParamsListHitOptArgs,
            codingConvention.isVarArgsParameter(currentParam));
      }
    }

    // Clone any remaining params that aren't in the function literal,
    // but make them optional.
    while (oldParams.hasNext()) {
      paramBuilder.newOptionalParameterFromNode(oldParams.next());
    }

    parametersNode = paramBuilder.build();
  }
  return this;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:69,代码来源:FunctionTypeBuilder.java

示例4: inferParameterTypes

import com.google.javascript.rhino.jstype.FunctionParamBuilder; //导入方法依赖的package包/类
/**
 * Infer the parameter types from the list of argument names and
 * the doc info.
 */
FunctionTypeBuilder inferParameterTypes(@Nullable Node argsParent,
    @Nullable JSDocInfo info) {
  if (argsParent == null) {
    if (info == null) {
      return this;
    } else {
      return inferParameterTypes(info);
    }
  }

  // arguments
  Node oldParameterType = null;
  if (parametersNode != null) {
    oldParameterType = parametersNode.getFirstChild();
  }

  FunctionParamBuilder builder = new FunctionParamBuilder(typeRegistry);
  boolean warnedAboutArgList = false;
  Set<String> allJsDocParams = (info == null) ?
      Sets.<String>newHashSet() :
      Sets.newHashSet(info.getParameterNames());
  boolean foundTemplateType = false;
  boolean isVarArgs = false;
  for (Node arg : argsParent.children()) {
    String argumentName = arg.getString();
    allJsDocParams.remove(argumentName);

    // type from JSDocInfo
    JSType parameterType = null;
    boolean isOptionalParam = isOptionalParameter(arg, info);
    isVarArgs = isVarArgsParameter(arg, info);

    if (info != null && info.hasParameterType(argumentName)) {
      parameterType =
          info.getParameterType(argumentName).evaluate(scope, typeRegistry);
    } else if (oldParameterType != null &&
        oldParameterType.getJSType() != null) {
      parameterType = oldParameterType.getJSType();
      isOptionalParam = oldParameterType.isOptionalArg();
      isVarArgs = oldParameterType.isVarArgs();
    } else {
      parameterType = typeRegistry.getNativeType(UNKNOWN_TYPE);
    }

    warnedAboutArgList |= addParameter(
        builder, parameterType, warnedAboutArgList,
        isOptionalParam,
        isVarArgs);

    if (oldParameterType != null) {
      oldParameterType = oldParameterType.getNext();
    }
  }

  // Copy over any old parameters that aren't in the param list.
  if (!isVarArgs) {
    while (oldParameterType != null && !isVarArgs) {
      builder.newParameterFromNode(oldParameterType);
      oldParameterType = oldParameterType.getNext();
    }
  }

  for (String inexistentName : allJsDocParams) {
    reportWarning(INEXISTANT_PARAM, inexistentName, fnName);
  }

  parametersNode = builder.build();
  return this;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:74,代码来源:FunctionTypeBuilder.java

示例5: inferFromOverriddenFunction

import com.google.javascript.rhino.jstype.FunctionParamBuilder; //导入方法依赖的package包/类
/**
 * Infer the parameter and return types of a function from
 * the parameter and return types of the function it is overriding.
 *
 * @param oldType The function being overridden. Does nothing if this is null.
 * @param paramsParent The PARAM_LIST node of the function that we're assigning to.
 *     If null, that just means we're not initializing this to a function
 *     literal.
 */
FunctionTypeBuilder inferFromOverriddenFunction(
    @Nullable FunctionType oldType, @Nullable Node paramsParent) {
  if (oldType == null) {
    return this;
  }

  // Propagate the template types, if they exist.
  templateTypeNames = oldType.getTemplateTypeMap().getTemplateKeys();

  returnType = oldType.getReturnType();
  returnTypeInferred = oldType.isReturnTypeInferred();
  if (paramsParent == null) {
    // Not a function literal.
    parametersNode = oldType.getParametersNode();
    if (parametersNode == null) {
      parametersNode = new FunctionParamBuilder(typeRegistry).build();
    }
  } else {
    // We're overriding with a function literal. Apply type information
    // to each parameter of the literal.
    FunctionParamBuilder paramBuilder =
        new FunctionParamBuilder(typeRegistry);
    Iterator<Node> oldParams = oldType.getParameters().iterator();
    boolean warnedAboutArgList = false;
    boolean oldParamsListHitOptArgs = false;
    for (Node currentParam = paramsParent.getFirstChild();
         currentParam != null; currentParam = currentParam.getNext()) {
      if (oldParams.hasNext()) {
        Node oldParam = oldParams.next();
        Node newParam = paramBuilder.newParameterFromNode(oldParam);

        oldParamsListHitOptArgs = oldParamsListHitOptArgs ||
            oldParam.isVarArgs() ||
            oldParam.isOptionalArg();

        // The subclass method might write its var_args as individual
        // arguments.
        if (currentParam.getNext() != null && newParam.isVarArgs()) {
          newParam.setVarArgs(false);
          newParam.setOptionalArg(true);
        }
      } else {
        warnedAboutArgList |= addParameter(
            paramBuilder,
            typeRegistry.getNativeType(UNKNOWN_TYPE),
            warnedAboutArgList,
            codingConvention.isOptionalParameter(currentParam) ||
                oldParamsListHitOptArgs,
            codingConvention.isVarArgsParameter(currentParam));
      }
    }

    // Clone any remaining params that aren't in the function literal,
    // but make them optional.
    while (oldParams.hasNext()) {
      paramBuilder.newOptionalParameterFromNode(oldParams.next());
    }

    parametersNode = paramBuilder.build();
  }
  return this;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:72,代码来源:FunctionTypeBuilder.java

示例6: inferParameterTypes

import com.google.javascript.rhino.jstype.FunctionParamBuilder; //导入方法依赖的package包/类
/**
 * Infer the parameter types from the list of argument names and
 * the doc info.
 */
FunctionTypeBuilder inferParameterTypes(@Nullable Node argsParent,
    @Nullable JSDocInfo info) {
  if (argsParent == null) {
    if (info == null) {
      return this;
    } else {
      return inferParameterTypes(info);
    }
  }

  // arguments
  Node oldParameterType = null;
  if (parametersNode != null) {
    oldParameterType = parametersNode.getFirstChild();
  }

  FunctionParamBuilder builder = new FunctionParamBuilder(typeRegistry);
  boolean warnedAboutArgList = false;
  Set<String> allJsDocParams = (info == null) ?
       new HashSet<String>() :
       new HashSet<>(info.getParameterNames());
  boolean isVarArgs = false;
  for (Node arg : argsParent.children()) {
    String argumentName = arg.getString();
    allJsDocParams.remove(argumentName);

    // type from JSDocInfo
    JSType parameterType = null;
    boolean isOptionalParam = isOptionalParameter(arg, info);
    isVarArgs = isVarArgsParameter(arg, info);

    if (info != null && info.hasParameterType(argumentName)) {
      parameterType =
          info.getParameterType(argumentName).evaluate(scope, typeRegistry);
    } else if (arg.getJSDocInfo() != null && arg.getJSDocInfo().hasType()) {
      parameterType =
          arg.getJSDocInfo().getType().evaluate(scope, typeRegistry);
    } else if (oldParameterType != null &&
        oldParameterType.getJSType() != null) {
      parameterType = oldParameterType.getJSType();
      isOptionalParam = oldParameterType.isOptionalArg();
      isVarArgs = oldParameterType.isVarArgs();
    } else {
      parameterType = typeRegistry.getNativeType(UNKNOWN_TYPE);
    }

    warnedAboutArgList |= addParameter(
        builder, parameterType, warnedAboutArgList,
        isOptionalParam,
        isVarArgs);

    if (oldParameterType != null) {
      oldParameterType = oldParameterType.getNext();
    }
  }

  // Copy over any old parameters that aren't in the param list.
  if (!isVarArgs) {
    while (oldParameterType != null && !isVarArgs) {
      builder.newParameterFromNode(oldParameterType);
      oldParameterType = oldParameterType.getNext();
    }
  }

  for (String inexistentName : allJsDocParams) {
    reportWarning(INEXISTENT_PARAM, inexistentName, formatFnName());
  }

  parametersNode = builder.build();
  return this;
}
 
开发者ID:google,项目名称:closure-compiler,代码行数:76,代码来源:FunctionTypeBuilder.java

示例7: inferFromOverriddenFunction

import com.google.javascript.rhino.jstype.FunctionParamBuilder; //导入方法依赖的package包/类
/**
 * Infer the parameter and return types of a function from
 * the parameter and return types of the function it is overriding.
 *
 * @param oldType The function being overridden. Does nothing if this is null.
 * @param paramsParent The LP node of the function that we're assigning to.
 *     If null, that just means we're not initializing this to a function
 *     literal.
 */
FunctionTypeBuilder inferFromOverriddenFunction(
    @Nullable FunctionType oldType, @Nullable Node paramsParent) {
  if (oldType == null) {
    return this;
  }

  // Propagate the template types, if they exist.
  templateTypeNames = oldType.getTemplateTypeMap().getTemplateKeys();

  returnType = oldType.getReturnType();
  returnTypeInferred = oldType.isReturnTypeInferred();
  if (paramsParent == null) {
    // Not a function literal.
    parametersNode = oldType.getParametersNode();
    if (parametersNode == null) {
      parametersNode = new FunctionParamBuilder(typeRegistry).build();
    }
  } else {
    // We're overriding with a function literal. Apply type information
    // to each parameter of the literal.
    FunctionParamBuilder paramBuilder =
        new FunctionParamBuilder(typeRegistry);
    Iterator<Node> oldParams = oldType.getParameters().iterator();
    boolean warnedAboutArgList = false;
    boolean oldParamsListHitOptArgs = false;
    for (Node currentParam = paramsParent.getFirstChild();
         currentParam != null; currentParam = currentParam.getNext()) {
      if (oldParams.hasNext()) {
        Node oldParam = oldParams.next();
        Node newParam = paramBuilder.newParameterFromNode(oldParam);

        oldParamsListHitOptArgs = oldParamsListHitOptArgs ||
            oldParam.isVarArgs() ||
            oldParam.isOptionalArg();

        // The subclass method might write its var_args as individual
        // arguments.
        if (currentParam.getNext() != null && newParam.isVarArgs()) {
          newParam.setVarArgs(false);
          newParam.setOptionalArg(true);
        }
      } else {
        warnedAboutArgList |= addParameter(
            paramBuilder,
            typeRegistry.getNativeType(UNKNOWN_TYPE),
            warnedAboutArgList,
            codingConvention.isOptionalParameter(currentParam) ||
                oldParamsListHitOptArgs,
            codingConvention.isVarArgsParameter(currentParam));
      }
    }

    // Clone any remaining params that aren't in the function literal,
    // but make them optional.
    while (oldParams.hasNext()) {
      paramBuilder.newOptionalParameterFromNode(oldParams.next());
    }

    parametersNode = paramBuilder.build();
  }
  return this;
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:72,代码来源:FunctionTypeBuilder.java

示例8: inferParameterTypes

import com.google.javascript.rhino.jstype.FunctionParamBuilder; //导入方法依赖的package包/类
/**
 * Infer the parameter types from the list of argument names and
 * the doc info.
 */
FunctionTypeBuilder inferParameterTypes(@Nullable Node argsParent,
    @Nullable JSDocInfo info) {
  if (argsParent == null) {
    if (info == null) {
      return this;
    } else {
      return inferParameterTypes(info);
    }
  }

  // arguments
  Node oldParameterType = null;
  if (parametersNode != null) {
    oldParameterType = parametersNode.getFirstChild();
  }

  FunctionParamBuilder builder = new FunctionParamBuilder(typeRegistry);
  boolean warnedAboutArgList = false;
  Set<String> allJsDocParams = (info == null) ?
      Sets.<String>newHashSet() :
      Sets.newHashSet(info.getParameterNames());
  boolean isVarArgs = false;
  for (Node arg : argsParent.children()) {
    String argumentName = arg.getString();
    allJsDocParams.remove(argumentName);

    // type from JSDocInfo
    JSType parameterType = null;
    boolean isOptionalParam = isOptionalParameter(arg, info);
    isVarArgs = isVarArgsParameter(arg, info);

    if (info != null && info.hasParameterType(argumentName)) {
      parameterType =
          info.getParameterType(argumentName).evaluate(scope, typeRegistry);
    } else if (arg.getJSDocInfo() != null && arg.getJSDocInfo().hasType()) {
      parameterType =
          arg.getJSDocInfo().getType().evaluate(scope, typeRegistry);
    } else if (oldParameterType != null &&
        oldParameterType.getJSType() != null) {
      parameterType = oldParameterType.getJSType();
      isOptionalParam = oldParameterType.isOptionalArg();
      isVarArgs = oldParameterType.isVarArgs();
    } else {
      parameterType = typeRegistry.getNativeType(UNKNOWN_TYPE);
    }

    warnedAboutArgList |= addParameter(
        builder, parameterType, warnedAboutArgList,
        isOptionalParam,
        isVarArgs);

    if (oldParameterType != null) {
      oldParameterType = oldParameterType.getNext();
    }
  }

  // Copy over any old parameters that aren't in the param list.
  if (!isVarArgs) {
    while (oldParameterType != null && !isVarArgs) {
      builder.newParameterFromNode(oldParameterType);
      oldParameterType = oldParameterType.getNext();
    }
  }

  for (String inexistentName : allJsDocParams) {
    reportWarning(INEXISTANT_PARAM, inexistentName, formatFnName());
  }

  parametersNode = builder.build();
  return this;
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:76,代码来源:FunctionTypeBuilder.java


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