com.sun.tools.javac.util.List.indexOf()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(7.6k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中com.sun.tools.javac.util.List.indexOf()方法的一些代码示例,展示了List.indexOf()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。List.indexOf()方法的具体详情如下:
包路径:com.sun.tools.javac.util.List
类名称:List
方法名:indexOf

List.indexOf介绍

暂无

代码示例

代码示例来源:origin: google/error-prone

private static boolean isAnnotationOnType(Symbol sym, TypeAnnotationPosition position) {
 if (!position.location.isEmpty()) {
  return false;
 }
 switch (sym.getKind()) {
  case LOCAL_VARIABLE:
   return position.type == TargetType.LOCAL_VARIABLE;
  case FIELD:
   return position.type == TargetType.FIELD;
  case CONSTRUCTOR:
  case METHOD:
   return position.type == TargetType.METHOD_RETURN;
  case PARAMETER:
   switch (position.type) {
    case METHOD_FORMAL_PARAMETER:
     return ((MethodSymbol) sym.owner).getParameters().indexOf(sym)
       == position.parameter_index;
    default:
     return false;
   }
  case CLASS:
   // There are no type annotations on the top-level type of the class being declared, only
   // on other types in the signature (e.g. `class Foo extends Bar<@A Baz> {}`).
   return false;
  default:
   throw new AssertionError(
     "unsupported element kind in MoreAnnotation#isAnnotationOnType: " + sym.getKind());
 }
}

代码示例来源:origin: google/error-prone

private static ImmutableList<SuggestedFix> buildUnusedParameterFixes(
  Symbol varSymbol, List<TreePath> usagePaths, VisitorState state) {
 MethodSymbol methodSymbol = (MethodSymbol) varSymbol.owner;
 int index = methodSymbol.params.indexOf(varSymbol);
 SuggestedFix.Builder fix = SuggestedFix.builder();
 for (TreePath path : usagePaths) {

代码示例来源:origin: cincheo/jsweet

StringBuilder permutationString = new StringBuilder();
for (int i = 0; i < orderedCompilationUnits.size(); i++) {
  permutation[i] = compilationUnits.indexOf(orderedCompilationUnits.get(i));
  permutationString.append("" + i + "=" + permutation[i] + ";");

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

@Override
protected String capturedVarId(CapturedType t, Locale locale) {
  return "" + (allCaptured.indexOf(t) + 1);
}
@Override

代码示例来源:origin: konsoletyper/teavm-javac

@Override
protected String capturedVarId(CapturedType t, Locale locale) {
  return "" + (allCaptured.indexOf(t) + 1);
}
@Override

代码示例来源:origin: konsoletyper/teavm-javac

@Override
public <A extends Annotation> Attribute.Compound getAttribute(Class<A> annoType) {
  String name = annoType.getName();
  // Declaration annotations on type variables are stored in type attributes
  // on the owner of the TypeVariableSymbol
  List<Attribute.TypeCompound> candidates = owner.getRawTypeAttributes();
  int index = owner.getTypeParameters().indexOf(this);
  for (Attribute.TypeCompound anno : candidates)
    if (isCurrentSymbolsAnnotation(anno, index) &&
      name.contentEquals(anno.type.tsym.flatName()))
      return anno;
  return null;
}
  //where:

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

private int methodParamIndex(List<JCTree> path, JCTree param) {
  List<JCTree> curr = path;
  while (curr.head.getTag() != Tag.METHODDEF &&
      curr.head.getTag() != Tag.LAMBDA) {
    curr = curr.tail;
  }
  if (curr.head.getTag() == Tag.METHODDEF) {
    JCMethodDecl method = (JCMethodDecl)curr.head;
    return method.params.indexOf(param);
  } else if (curr.head.getTag() == Tag.LAMBDA) {
    JCLambda lambda = (JCLambda)curr.head;
    return lambda.params.indexOf(param);
  } else {
    Assert.error("methodParamIndex expected to find method or lambda for param: " + param);
    return -1;
  }
}

代码示例来源:origin: konsoletyper/teavm-javac

private int methodParamIndex(List<JCTree> path, JCTree param) {
  List<JCTree> curr = path;
  while (curr.head.getTag() != Tag.METHODDEF &&
      curr.head.getTag() != Tag.LAMBDA) {
    curr = curr.tail;
  }
  if (curr.head.getTag() == Tag.METHODDEF) {
    JCMethodDecl method = (JCMethodDecl)curr.head;
    return method.params.indexOf(param);
  } else if (curr.head.getTag() == Tag.LAMBDA) {
    JCLambda lambda = (JCLambda)curr.head;
    return lambda.params.indexOf(param);
  } else {
    Assert.error("methodParamIndex expected to find method or lambda for param: " + param);
    return -1;
  }
}

代码示例来源:origin: com.google.errorprone/error_prone_check_api

private static boolean isAnnotationOnType(Symbol sym, TypeAnnotationPosition position) {
 if (!position.location.isEmpty()) {
  return false;
 }
 switch (sym.getKind()) {
  case LOCAL_VARIABLE:
   return position.type == TargetType.LOCAL_VARIABLE;
  case FIELD:
   return position.type == TargetType.FIELD;
  case METHOD:
   return position.type == TargetType.METHOD_RETURN;
  case PARAMETER:
   switch (position.type) {
    case METHOD_FORMAL_PARAMETER:
     return ((MethodSymbol) sym.owner).getParameters().indexOf(sym)
       == position.parameter_index;
    default:
     return false;
   }
  default:
   throw new AssertionError(sym.getKind());
 }
}

代码示例来源:origin: konsoletyper/teavm-javac

@Override
public List<Attribute.Compound> getAnnotationMirrors() {
  // Declaration annotations on type variables are stored in type attributes
  // on the owner of the TypeVariableSymbol
  List<Attribute.TypeCompound> candidates = owner.getRawTypeAttributes();
  int index = owner.getTypeParameters().indexOf(this);
  List<Attribute.Compound> res = List.nil();
  for (Attribute.TypeCompound a : candidates) {
    if (isCurrentSymbolsAnnotation(a, index))
      res = res.prepend(a);
  }
  return res.reverse();
}

代码示例来源:origin: com.google.errorprone/error_prone_core

private static ImmutableList<SuggestedFix> buildUnusedParameterFixes(
  Symbol varSymbol, List<TreePath> usagePaths, VisitorState state) {
 MethodSymbol methodSymbol = (MethodSymbol) varSymbol.owner;
 int index = methodSymbol.params.indexOf(varSymbol);
 SuggestedFix.Builder fix = SuggestedFix.builder();
 for (TreePath path : usagePaths) {

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

} else if (frameClassDecl.implementing.contains(tree)) {
    p.type = TargetType.CLASS_EXTENDS;
    p.type_index = frameClassDecl.implementing.indexOf(tree);
  } else {
  p.type_index = frameNewClass.typeargs.indexOf(tree);
} else {
  p.type = TargetType.NEW;
} else if (((JCClassDecl)frame).implementing.contains(tree)) {
  p.type = TargetType.CLASS_EXTENDS;
  p.type_index = ((JCClassDecl)frame).implementing.indexOf(tree);
} else if (((JCClassDecl)frame).typarams.contains(tree)) {
  p.type = TargetType.CLASS_TYPE_PARAMETER;
  p.parameter_index = ((JCClassDecl)frame).typarams.indexOf(tree);
} else {
  Assert.error("Could not determine position of tree " + tree +
if (frameMethod.thrown.contains(tree)) {
  p.type = TargetType.THROWS;
  p.type_index = frameMethod.thrown.indexOf(tree);
} else if (frameMethod.restype == tree) {
  p.type = TargetType.METHOD_RETURN;
} else if (frameMethod.typarams.contains(tree)) {
  p.type = TargetType.METHOD_TYPE_PARAMETER;
  p.parameter_index = frameMethod.typarams.indexOf(tree);
} else {
  Assert.error("Could not determine position of tree " + tree +

代码示例来源:origin: konsoletyper/teavm-javac

} else if (frameClassDecl.implementing.contains(tree)) {
    p.type = TargetType.CLASS_EXTENDS;
    p.type_index = frameClassDecl.implementing.indexOf(tree);
  } else {
  p.type_index = frameNewClass.typeargs.indexOf(tree);
} else {
  p.type = TargetType.NEW;
} else if (((JCClassDecl)frame).implementing.contains(tree)) {
  p.type = TargetType.CLASS_EXTENDS;
  p.type_index = ((JCClassDecl)frame).implementing.indexOf(tree);
} else if (((JCClassDecl)frame).typarams.contains(tree)) {
  p.type = TargetType.CLASS_TYPE_PARAMETER;
  p.parameter_index = ((JCClassDecl)frame).typarams.indexOf(tree);
} else {
  Assert.error("Could not determine position of tree " + tree +
if (frameMethod.thrown.contains(tree)) {
  p.type = TargetType.THROWS;
  p.type_index = frameMethod.thrown.indexOf(tree);
} else if (frameMethod.restype == tree) {
  p.type = TargetType.METHOD_RETURN;
} else if (frameMethod.typarams.contains(tree)) {
  p.type = TargetType.METHOD_TYPE_PARAMETER;
  p.parameter_index = frameMethod.typarams.indexOf(tree);
} else {
  Assert.error("Could not determine position of tree " + tree +

代码示例来源:origin: org.kohsuke.sorcerer/sorcerer-javac

pos.type_index = -1;
} else if (classdecl.implementing.contains(tree.clazz)) {
  pos.type_index = classdecl.implementing.indexOf(tree.clazz);
} else {

代码示例来源:origin: konsoletyper/teavm-javac

pos.type_index = -1;
} else if (classdecl.implementing.contains(tree.clazz)) {
  pos.type_index = classdecl.implementing.indexOf(tree.clazz);
} else {

相关文章