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


Java TypePathEntry类代码示例

本文整理汇总了Java中com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry的典型用法代码示例。如果您正苦于以下问题:Java TypePathEntry类的具体用法?Java TypePathEntry怎么用?Java TypePathEntry使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: locateNestedTypes

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
private void locateNestedTypes(Type type, TypeAnnotationPosition p) {
    // The number of "steps" to get from the full type to the
    // left-most outer type.
    ListBuffer<TypePathEntry> depth = new ListBuffer<>();

    Type encl = type.getEnclosingType();
    while (encl != null &&
            encl.getKind() != TypeKind.NONE &&
            encl.getKind() != TypeKind.ERROR) {
        depth = depth.append(TypePathEntry.INNER_TYPE);
        encl = encl.getEnclosingType();
    }
    if (depth.nonEmpty()) {
        p.location = p.location.prependList(depth.toList());
    }
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:TypeAnnotations.java

示例2: printInnerTypes

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
private void printInnerTypes(String indentation, ATypeElement e) {
  for (Map. Entry<InnerTypeLocation,
          ATypeElement> ite : e.innerTypes.entrySet()) {
      InnerTypeLocation loc = ite.getKey();
      AElement it = ite.getValue();
      pw.print(indentation + "inner-type");
      char sep = ' ';
      for (TypePathEntry l : loc.location) {
          pw.print(sep);
          pw.print(typePathEntryToString(l));
          sep = ',';
      }
      pw.print(':');
      printAnnotations(it);
      pw.println();
  }
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:18,代码来源:IndexFileWriter.java

示例3: SafeTypeAnnotationVisitor

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
/**
 * Constructs a new <code> SafeTypeAnnotationVisitor </code> that
 *  delegates all calls to the given visitor.
 *
 * @param xav the visitor to delegate all method calls to
 */
public SafeTypeAnnotationVisitor(TypeAnnotationVisitor xav) {
  this.xav = xav;
  // Start most of these with a capacity of one, since for legal annotations
  // they should not contain more than one element.
  xIndexArgs = new ArrayList<Integer>(1);
  xLengthArgs = new ArrayList<Integer>(1);
  xLocationArgs = new ArrayList<TypePathEntry>();
  xLocationLengthArgs = new ArrayList<Integer>(1);
  xOffsetArgs = new ArrayList<Integer>(1);
  xStartPcArgs = new ArrayList<Integer>(1);
  xTargetTypeArgs = new ArrayList<Integer>(1);
  xParamIndexArgs = new ArrayList<Integer>(1);
  xBoundIndexArgs = new ArrayList<Integer>(1);
  xTypeIndexArgs = new ArrayList<Integer>(1);
  xNameAndArgsCount = 0;
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:23,代码来源:SafeTypeAnnotationVisitor.java

示例4: getLocationTypeATM

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
private static AnnotatedTypeMirror getLocationTypeATM(AnnotatedTypeMirror type, List<TypePathEntry> location) {
    if (debug) {
        System.out.println("getLocationTypeATM type: " + type + " location: " + location);
    }
    if (location.isEmpty()) {
        return type;
    } else if (type.getKind() == TypeKind.DECLARED) {
        return getLocationTypeADT((AnnotatedDeclaredType)type, location);
    } else if (type.getKind() == TypeKind.WILDCARD) {
        return getLocationTypeAWT((AnnotatedWildcardType)type, location);
    } else if (type.getKind() == TypeKind.ARRAY) {
        return getLocationTypeAAT((AnnotatedArrayType)type, location);
    } else {
        ErrorReporter.errorAbort("TypeFromElement.getLocationTypeATM: only declared types and arrays can have annotations with location; " +
                "found type: " + type + " location: " + location);
        return null; // dead code
    }
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:19,代码来源:TypeFromElement.java

示例5: getLocationTypeAWT

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
private static AnnotatedTypeMirror getLocationTypeAWT(AnnotatedWildcardType type,  List<TypePathEntry> location) {
    if (debug) {
        System.out.println("getLocationTypeAWT type: " + type + " location: " + location);
    }
    if (location.isEmpty()) {
        return type;
    } else if (location.get(0).tag.equals(TypePathEntryKind.WILDCARD)) {
        List<AnnotatedTypeMirror> bounds = getBounds(type);
        // TODO: what should happen if bounds is empty or has more than one entry?
        return getLocationTypeATM(bounds.get(0), tail(location));
    } else {
        if (strict) {
            System.out.println("TypeFromElement.getLocationTypeAWT: type not handled.\n" +
                    "    Found location: " + location + " for type: " + type);
        }
        return type;
    }
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:19,代码来源:TypeFromElement.java

示例6: locateNestedTypes

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
private ListBuffer<TypePathEntry>
    locateNestedTypes(Type type,
                      ListBuffer<TypePathEntry> depth) {
    Type encl = type.getEnclosingType();
    while (encl != null &&
            encl.getKind() != TypeKind.NONE &&
            encl.getKind() != TypeKind.ERROR) {
        depth = depth.prepend(TypePathEntry.INNER_TYPE);
        encl = encl.getEnclosingType();
    }
    return depth;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:13,代码来源:TypeAnnotations.java

示例7: containsOnlyArray

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
/**
 * Determines if the given list holds only {@link TypePathEntry}s with the tag
 * {@link TypePathEntryKind#ARRAY}.
 *
 * @param location the list to check
 * @return {@code true} if the list only contains
 *         {@link TypePathEntryKind#ARRAY}, {@code false} otherwise.
 */
private boolean containsOnlyArray(List<TypePathEntry> location) {
  for (TypePathEntry tpe : location) {
    if (tpe.tag != TypePathEntryKind.ARRAY) {
      return false;
    }
  }
  return true;
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:17,代码来源:GenericArrayLocationCriterion.java

示例8: extendToInnerType

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
/**
 * Find an {@link ASTRecord} for the tree corresponding to a nested
 * type of the type (use) to which the given record corresponds.
 *
 * @param rec record of (outer) type AST to be annotated
 * @param loc inner type path
 * @return record that locates the (nested) type in the source
 */
private ASTRecord extendToInnerType(ASTRecord rec, List<TypePathEntry> loc) {
  ASTRecord r = rec;
  Iterator<TypePathEntry> iter = loc.iterator();
  int depth = 0;

  while (iter.hasNext()) {
    TypePathEntry tpe = iter.next();
    switch (tpe.tag) {
    case ARRAY:
      while (depth-- > 0) {
        r = r.extend(Tree.Kind.MEMBER_SELECT, ASTPath.EXPRESSION);
      }
      r = r.extend(Tree.Kind.ARRAY_TYPE, ASTPath.TYPE);
      break;
    case INNER_TYPE:
      ++depth;
      break;
    case TYPE_ARGUMENT:
      depth = 0;
      r = r.extend(Tree.Kind.PARAMETERIZED_TYPE, ASTPath.TYPE_ARGUMENT,
          tpe.arg);
      break;
    case WILDCARD:
      while (depth-- > 0) {
        r = r.extend(Tree.Kind.MEMBER_SELECT, ASTPath.EXPRESSION);
      }
      r = r.extend(Tree.Kind.UNBOUNDED_WILDCARD, ASTPath.BOUND);
      break;
    default:
      throw new RuntimeException();
    }
  }
  while (depth-- > 0) {
    r = r.extend(Tree.Kind.MEMBER_SELECT, ASTPath.EXPRESSION);
  }
  return r;
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:46,代码来源:Insertions.java

示例9: visitXLocation

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
public void visitXLocation(TypePathEntry location) {
    buf.setLength(0);
    buf.append("xav").append(id).append(".visitXLocation(");
    buf.append(location.toString());
    buf.append(");\n");
    text.add(buf.toString());
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:8,代码来源:ASMifierTypeAnnotationVisitor.java

示例10: visitXLocationLength

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
public void visitXLocationLength(int location_length) {
  this.xlocation_length = location_length;
  this.xlocations = new TypePathEntry[this.xlocation_length];
  this.xlocations_index = 0;
  if(xav != null) {
    xav.visitXLocationLength(location_length);
  }
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:9,代码来源:TraceTypeAnnotationVisitor.java

示例11: visitXLocation

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
public void visitXLocation(TypePathEntry location) {
  this.xlocations[xlocations_index] = location;
  this.xlocations_index++;
  if(xav != null) {
    xav.visitXLocation(location);
  }
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:8,代码来源:TraceTypeAnnotationVisitor.java

示例12: getInnerType

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
private static ATypeElement getInnerType(ATypeElement te,
                                         List<TypePathEntry> ls) {
    if (ls.isEmpty()) {
        return te;
    } else {
        return te.innerTypes.vivify(new InnerTypeLocation(ls));
    }
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:9,代码来源:TypeASTMapper.java

示例13: printAmbElementAndInnerTypes

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
private void printAmbElementAndInnerTypes(String indentation,
        String desc,
        AElement e) {
    printElement(indentation, desc, e);
    if (e.type.tlAnnotationsHere.isEmpty() && e.type.innerTypes.isEmpty()) {
        return;
    }
    printElement(indentation + INDENT, "type", e.type);
    for (Map. Entry<InnerTypeLocation, ATypeElement> ite
            : e.type.innerTypes.entrySet()) {
        InnerTypeLocation loc = ite.getKey();
        AElement it = ite.getValue();
        pw.print(indentation + INDENT + INDENT + "inner-type");
        boolean first = true;
        for (TypePathEntry l : loc.location) {
            if (first) {
                pw.print(' ');
            } else {
                pw.print(',');
            }
            pw.print(typePathEntryToString(l));
            first = false;
        }
        pw.print(':');
        printAnnotations(it);
        pw.println();
    }
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:29,代码来源:IndexFileWriter.java

示例14: AnnotationSceneReader

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
/**
 * Constructs a new AnnotationScene reader with the given description and
 * visibility.  Calling visitEnd() will ensure that this writes out the
 * annotation it visits into aElement.
 * @param desc JVML format for the field being read, or ClassAnnotationSceneReader.dummyDesc
 */
public AnnotationSceneReader(String desc, boolean visible, AElement aElement) {
  if (trace) { System.out.printf("AnnotationSceneReader(%s, %s, %s)%n", desc, visible, aElement); }
  this.visible = visible;
  this.aElement = aElement;
  if (desc != dummyDesc) {    // interned
    AnnotationDef ad = getAnnotationDef(desc);

    AnnotationBuilder ab = AnnotationFactory.saf.beginAnnotation(ad);
    if (ab == null) {
      throw new IllegalArgumentException("bad description: " + desc);
    } else {
      this.annotationBuilder = ab;
    }
  }

  // For legal annotations, and except for xLocationsArgs, these should
  //  contain at most one element.
  this.xTargetTypeArgs = new ArrayList<Integer>(1);
  this.xIndexArgs = new ArrayList<Integer>(1);
  this.xLengthArgs = new ArrayList<Integer>(1);
  this.xLocationLengthArgs = new ArrayList<Integer>(1);
  this.xOffsetArgs = new ArrayList<Integer>(1);
  this.xStartPcArgs = new ArrayList<Integer>(1);
  this.xLocationsArgs = new ArrayList<TypePathEntry>();
  this.xParamIndexArgs = new ArrayList<Integer>(1);
  this.xBoundIndexArgs = new ArrayList<Integer>(1);
  this.xExceptionIndexArgs = new ArrayList<Integer>(1);
  this.xTypeIndexArgs = new ArrayList<Integer>(1);
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:36,代码来源:ClassAnnotationSceneReader.java

示例15: visitLocations

import com.sun.tools.javac.code.TypeAnnotationPosition.TypePathEntry; //导入依赖的package包/类
/**
 * Have xav visit the location length  and all locations in loc.
 */
private void visitLocations(TypeAnnotationVisitor xav, InnerTypeLocation loc) {
  List<TypePathEntry> location = loc.location;
  xav.visitXLocationLength(location.size());
  for (TypePathEntry l : location) {
    xav.visitXLocation(l);
  }
}
 
开发者ID:typetools,项目名称:annotation-tools,代码行数:11,代码来源:ClassAnnotationSceneWriter.java


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