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


Java Attribute.TypeCompound方法代码示例

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


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

示例1: apportionTypeAnnotations

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
private void apportionTypeAnnotations(JCLambda tree,
                                      Supplier<List<Attribute.TypeCompound>> source,
                                      Consumer<List<Attribute.TypeCompound>> owner,
                                      Consumer<List<Attribute.TypeCompound>> lambda) {

    ListBuffer<Attribute.TypeCompound> ownerTypeAnnos = new ListBuffer<>();
    ListBuffer<Attribute.TypeCompound> lambdaTypeAnnos = new ListBuffer<>();

    for (Attribute.TypeCompound tc : source.get()) {
        if (tc.position.onLambda == tree) {
            lambdaTypeAnnos.append(tc);
        } else {
            ownerTypeAnnos.append(tc);
        }
    }
    if (lambdaTypeAnnos.nonEmpty()) {
        owner.accept(ownerTypeAnnos.toList());
        lambda.accept(lambdaTypeAnnos.toList());
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:LambdaToMethod.java

示例2: isTypeCompoundContained

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * Check whether a TypeCompound is contained in a list of TypeCompounds.
 *
 * @param list The input list of TypeCompounds.
 * @param tc The TypeCompound to find.
 * @return true, iff a TypeCompound equal to tc is contained in list.
 */
public static boolean isTypeCompoundContained(Types types, List<TypeCompound> list, TypeCompound tc) {
    for (Attribute.TypeCompound rawat : list) {
        if (rawat.type.tsym.name.contentEquals(tc.type.tsym.name) &&
                // TODO: in previous line, it would be nicer to use reference equality:
                //   rawat.type == tc.type &&
                // or at least "isSameType":
                //   types.isSameType(rawat.type, tc.type) &&
                // but each fails in some cases.
                rawat.values.equals(tc.values) &&
                isSameTAPosition(rawat.position, tc.position)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:23,代码来源:TypeAnnotationUtils.java

示例3: storeVariable

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
private static void storeVariable(ProcessingEnvironment processingEnv, Types types,
        AnnotatedTypeFactory atypeFactory, VariableTree var){
    VarSymbol sym = (VarSymbol) TreeUtils.elementFromDeclaration(var);
    AnnotatedTypeMirror type;
    if (atypeFactory instanceof GenericAnnotatedTypeFactory) {
        // TODO: this is rather ugly: we do not want refinement from the
        // initializer of the field. We need a general way to get
        // the "defaulted" type of a variable.
        type = ((GenericAnnotatedTypeFactory<?, ?, ?, ?>)atypeFactory).getDefaultedAnnotatedType(var, var.getInitializer());
    } else {
        type = atypeFactory.getAnnotatedType(var);
    }

    TypeAnnotationPosition tapos = TypeAnnotationUtils.fieldTAPosition(processingEnv.getSourceVersion(), ((JCTree)var).pos);

    List<Attribute.TypeCompound> tcs;
    tcs = generateTypeCompounds(processingEnv, type, tapos);
    addUniqueTypeCompounds(types, sym, tcs);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:20,代码来源:TypesIntoElements.java

示例4: store

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
@SuppressWarnings("unused") // TODO: use from store().
private static void storeClassExtends(ProcessingEnvironment processingEnv, Types types,
        AnnotatedTypeFactory atypeFactory, Tree ext, Symbol.ClassSymbol csym,
        int implidx){

    AnnotatedTypeMirror type;
    int pos;
    if (ext == null) {
        // The implicit superclass is always java.lang.Object.
        // TODO: is this a good way to get the type?
        type = atypeFactory.fromElement(csym.getSuperclass().asElement());
        pos = -1;
    } else {
        type = atypeFactory.getAnnotatedType(ext);
        pos = ((JCTree) ext).pos;
    }

    TypeAnnotationPosition tapos = TypeAnnotationUtils.classExtendsTAPosition(processingEnv.getSourceVersion(), implidx, pos);

    List<Attribute.TypeCompound> tcs;
    tcs = generateTypeCompounds(processingEnv, type, tapos);
    addUniqueTypeCompounds(types, csym, tcs);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:24,代码来源:TypesIntoElements.java

示例5: isTypeCompoundContained

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * Check whether a TypeCompound is contained in a list of TypeCompounds.
 *
 * @param list the input list of TypeCompounds
 * @param tc the TypeCompound to find
 * @return true, iff a TypeCompound equal to tc is contained in list
 */
public static boolean isTypeCompoundContained(
        Types types, List<TypeCompound> list, TypeCompound tc) {
    for (Attribute.TypeCompound rawat : list) {
        if (contentEquals(rawat.type.tsym.name, tc.type.tsym.name)
                // TODO: in previous line, it would be nicer to use reference equality:
                //   rawat.type == tc.type &&
                // or at least "isSameType":
                //   types.isSameType(rawat.type, tc.type) &&
                // but each fails in some cases.
                && rawat.values.equals(tc.values)
                && isSameTAPositionExceptTreePos(rawat.position, tc.position)) {
            return true;
        }
    }
    return false;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:24,代码来源:TypeAnnotationUtils.java

示例6: visitCompound

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
public void visitCompound(Attribute.Compound a) {
    if (a instanceof Attribute.TypeCompound) {
        Attribute.TypeCompound ta = (Attribute.TypeCompound) a;
        // consider a custom printer?
        printObject("position", ta.position, Details.SUMMARY);
    }
    printObject("synthesized", a.isSynthesized(), Details.SUMMARY);
    printList("values", a.values);
    visitAttribute(a);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:DPrinter.java

示例7: createTypeCompoundFromAnnotationMirror

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * Returns a newly created Attribute.TypeCompound corresponding to an
 * argument AnnotationMirror.
 *
 * @param am  an AnnotationMirror, which may be part of an AST or an internally
 *            created subclass.
 * @param tapos  the type annotation position to use.
 * @return  a new Attribute.TypeCompound corresponding to the AnnotationMirror
 */
public static Attribute.TypeCompound createTypeCompoundFromAnnotationMirror(ProcessingEnvironment env,
        AnnotationMirror am, TypeAnnotationPosition tapos) {
    // Create a new Attribute to match the AnnotationMirror.
    List<Pair<Symbol.MethodSymbol, Attribute>> values = List.nil();
    for (Map.Entry<? extends ExecutableElement, ? extends AnnotationValue> entry :
             am.getElementValues().entrySet()) {
        Attribute attribute = attributeFromAnnotationValue(env, entry.getKey(), entry.getValue());
        values = values.append(new Pair<>((Symbol.MethodSymbol)entry.getKey(),
                                          attribute));
    }
    return new Attribute.TypeCompound((Type.ClassType)am.getAnnotationType(), values, tapos);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:22,代码来源:TypeAnnotationUtils.java

示例8: addUniqueTypeCompounds

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
private static void addUniqueTypeCompounds(Types types, Symbol sym, List<TypeCompound> tcs) {
    List<TypeCompound> raw = sym.getRawTypeAttributes();
    List<Attribute.TypeCompound> res = List.nil();

    for (Attribute.TypeCompound tc : tcs) {
        if (!TypeAnnotationUtils.isTypeCompoundContained(types, raw, tc)) {
            res = res.append(tc);
        }
    }
    // That method only uses reference equality. isTypeCompoundContained does a deep comparison.
    sym.appendUniqueTypeAttributes(res);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:13,代码来源:TypesIntoElements.java

示例9: directAnnotations

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
List<TypeCompound> directAnnotations(AnnotatedTypeMirror type, TypeAnnotationPosition tapos) {
    List<Attribute.TypeCompound> res = List.nil();

    for (AnnotationMirror am : type.getAnnotations()) {
        if (am instanceof Attribute.TypeCompound) {
            // If it is a TypeCompound it was already present in source (right?),
            // so there is nothing to do.
            // System.out.println("  found TypeComound: " + am + " pos: " + ((Attribute.TypeCompound)am).position);
        } else {
            Attribute.TypeCompound tc = TypeAnnotationUtils.createTypeCompoundFromAnnotationMirror(processingEnv, am, tapos);
            res = res.prepend(tc);
        }
    }
    return res;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:16,代码来源:TypesIntoElements.java

示例10: visitArray

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
@Override
public List<TypeCompound> visitArray(AnnotatedArrayType type,
        TypeAnnotationPosition tapos) {
    List<Attribute.TypeCompound> res;
    res = directAnnotations(type, tapos);

    TypeAnnotationPosition newpos = TypeAnnotationUtils.copyTAPosition(processingEnv.getSourceVersion(), tapos);
    newpos.location = tapos.location.append(TypePathEntry.ARRAY);

    return reduce(super.visitArray(type, newpos), res);
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:12,代码来源:TypesIntoElements.java

示例11: visitPrimitive

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
@Override
public List<TypeCompound> visitPrimitive(AnnotatedPrimitiveType type,
        TypeAnnotationPosition tapos) {
    List<Attribute.TypeCompound> res;
    res = directAnnotations(type, tapos);
    return res;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:8,代码来源:TypesIntoElements.java

示例12: visitTypeVariable

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
@Override
public List<TypeCompound> visitTypeVariable(AnnotatedTypeVariable type, TypeAnnotationPosition tapos) {
    List<Attribute.TypeCompound> res;
    res = directAnnotations(type, tapos);
    // Do not call super. The bound will be visited separately.
    return res;
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:8,代码来源:TypesIntoElements.java

示例13: annotateField

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
 * Extracts type annotations from the element and inserts them into the
 * type of the element.
 *
 * The element needs to be that of a field.
 *
 * @param type  the type of the field
 * @param element the element of a field
 */
private static void annotateField(AnnotatedTypeMirror type, VariableElement element) {
    if (!element.getKind().isField()) {
        ErrorReporter.errorAbort("TypeFromElement.annotateField: " +
                "invalid non-field element " + element + " [" + element.getKind() + "]");
    }

    VarSymbol symbol = (VarSymbol) element;

    // Add declaration annotations to the field type
    addAnnotationsToElt(type, symbol.getAnnotationMirrors());

    for (Attribute.TypeCompound anno : symbol.getRawTypeAttributes()) {
        TypeAnnotationPosition pos = anno.position;
        switch (pos.type) {
        case FIELD:
            annotate(type, anno);
            break;
        case NEW:
        case CAST:
        case INSTANCEOF:
        case METHOD_INVOCATION_TYPE_ARGUMENT:
        case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT:
        case METHOD_REFERENCE:
        case CONSTRUCTOR_REFERENCE:
        case METHOD_REFERENCE_TYPE_ARGUMENT:
        case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT:
            // Valid in this location, but handled elsewhere.
            break;
        default: if (strict) {
            ErrorReporter.errorAbort("TypeFromElement.annotateField: " +
                    "invalid position " + pos.type +
                    " for annotation: " + anno +
                    " for element: " + ElementUtils.getVerboseName(element));
        }
        }
    }
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:47,代码来源:TypeFromElement.java

示例14: annotateSupers

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
public static void annotateSupers(List<AnnotatedDeclaredType> supertypes, TypeElement element) {
    final ClassSymbol symbol = (ClassSymbol)element;
    // Add the ones in the extends clauses
    final boolean hasSuperClass = element.getSuperclass().getKind() != TypeKind.NONE;

    AnnotatedDeclaredType superClassType = hasSuperClass ? supertypes.get(0) : null;
    List<AnnotatedDeclaredType> superInterfaces = hasSuperClass ? tail(supertypes) : supertypes;
    for (Attribute.TypeCompound anno : symbol.getRawTypeAttributes()) {
        TypeAnnotationPosition pos = anno.position;
        switch(pos.type) {
        case CLASS_EXTENDS:
            if (pos.type_index == -1 && superClassType != null) {
                annotate(superClassType, anno);
            } else if (pos.type_index >= 0 && pos.type_index < superInterfaces.size()) {
                annotate(superInterfaces.get(pos.type_index), anno);
            } else if (strict) {
                ErrorReporter.errorAbort("TypeFromElement.annotateSupers: " +
                        "invalid type index " + pos.type_index +
                        " for annotation: " + anno +
                        " for element: " + ElementUtils.getVerboseName(element));
            }
            break;
        case CLASS_TYPE_PARAMETER:
        case CLASS_TYPE_PARAMETER_BOUND:
            // Valid in this location, but handled elsewhere.
            break;
        default: if (strict) {
            ErrorReporter.errorAbort("TypeFromElement.annotateSupers: " +
                    "invalid position " + pos.type +
                    " for annotation: " + anno +
                    " for element: " + ElementUtils.getVerboseName(element));
        }
        }
    }
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:36,代码来源:TypeFromElement.java

示例15: annotate

import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
private static void annotate(AnnotatedTypeMirror type, Attribute.TypeCompound anno) {
    TypeAnnotationPosition pos = anno.position;
    if (pos.location.isEmpty()) {
        // This check prevents that annotations on the declaration of
        // the type variable are also added to the type variable use.
        if (type.getKind() == TypeKind.TYPEVAR) {
            type.removeAnnotationInHierarchy(anno);
        }
        type.addAnnotation(anno);
    } else {
        annotate(type, pos.location, Collections.singletonList(anno));
    }
}
 
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:14,代码来源:TypeFromElement.java


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