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


Java Attribute类代码示例

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


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

示例1: TypeProcessor

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
/** Main constructor. */
public TypeProcessor(@NonNull final Element element, @NonNull final Messager logger) {
    this.element = element;
    this.logger = logger;

    elementName = element.getSimpleName();
    flatClassName = flatName(element);

    final Symbol.PackageSymbol packageInfo = (Symbol.PackageSymbol) findPackage(element);
    packageName = packageInfo.getQualifiedName();
    elementType = element.asType();

    final Attribute.Compound ap = findAutoProxy(element.getAnnotationMirrors());
    this.annotation = extractAnnotation(ap);
    methods = new ArrayList<>();
}
 
开发者ID:OleksandrKucherenko,项目名称:autoproxy,代码行数:17,代码来源:TypeProcessor.java

示例2: findAutoProxy

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
@NonNull
private Attribute.Compound findAutoProxy(@NonNull final List<? extends AnnotationMirror> mirrors) {
    for (final AnnotationMirror mirror : mirrors) {
        final TypeElement element = (TypeElement) mirror.getAnnotationType().asElement();

        try {
            final Class<?> aClass = CommonClassGenerator.extractClass(element);

            if (AutoProxy.class == aClass) {
                return (Attribute.Compound) mirror;
            }
        } catch (Throwable ignored) {
            // do nothing
        }
    }

    throw new RuntimeException("AutoProxy annotation not found");
}
 
开发者ID:OleksandrKucherenko,项目名称:autoproxy,代码行数:19,代码来源:TypeProcessor.java

示例3: getAllReflectedValues

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
/**
 * Returns a map from element names to their values in "dynamic
 * proxy return form".  Includes all elements, whether explicit or
 * defaulted.
 */
private Map<String, Object> getAllReflectedValues() {
    Map<String, Object> res = new LinkedHashMap<String, Object>();

    for (Map.Entry<MethodSymbol, Attribute> entry :
                                              getAllValues().entrySet()) {
        MethodSymbol meth = entry.getKey();
        Object value = generateValue(meth, entry.getValue());
        if (value != null) {
            res.put(meth.name.toString(), value);
        } else {
            // Ignore this element.  May (properly) lead to
            // IncompleteAnnotationException somewhere down the line.
        }
    }
    return res;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:22,代码来源:AnnotationProxyMaker.java

示例4: getAllValues

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
/**
 * Returns a map from element symbols to their values.
 * Includes all elements, whether explicit or defaulted.
 */
private Map<MethodSymbol, Attribute> getAllValues() {
    Map<MethodSymbol, Attribute> res =
        new LinkedHashMap<MethodSymbol, Attribute>();

    // First find the default values.
    ClassSymbol sym = (ClassSymbol) anno.type.tsym;
    for (Scope.Entry e = sym.members().elems; e != null; e = e.sibling) {
        if (e.sym.kind == Kinds.MTH) {
            MethodSymbol m = (MethodSymbol) e.sym;
            Attribute def = m.getDefaultValue();
            if (def != null)
                res.put(m, def);
        }
    }
    // Next find the explicit values, possibly overriding defaults.
    for (Pair<MethodSymbol, Attribute> p : anno.values)
        res.put(p.fst, p.snd);
    return res;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:24,代码来源:AnnotationProxyMaker.java

示例5: getValue

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
Object getValue(Attribute attr) {
    Method method;              // runtime method of annotation element
    try {
        method = annoType.getMethod(meth.name.toString());
    } catch (NoSuchMethodException e) {
        return null;
    }
    returnClass = method.getReturnType();
    attr.accept(this);
    if (!(value instanceof ExceptionProxy) &&
        !AnnotationType.invocationHandlerReturnType(returnClass)
                                                .isInstance(value)) {
        typeMismatch(method, attr);
    }
    return value;
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:17,代码来源:AnnotationProxyMaker.java

示例6: visitArray

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
public void visitArray(Attribute.Array a) {
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('{');

    boolean first = true;
    for (Attribute elem : a.values) {
        if (first) {
            first = false;
        } else {
            sb.append(", ");
        }
        elem.accept(this);
    }
    // Omit braces from singleton.
    if (a.values.length != 1) sb.append('}');
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:AnnotationValueImpl.java

示例7: needsHeader

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
private boolean needsHeader(ClassSymbol c, boolean checkNestedClasses) {
    if (c.isLocal() || (c.flags() & Flags.SYNTHETIC) != 0)
        return false;

    for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) {
        if (i.sym.kind == Kinds.MTH && (i.sym.flags() & Flags.NATIVE) != 0)
            return true;
        for (Attribute.Compound a: i.sym.getDeclarationAttributes()) {
            if (a.type.tsym == syms.nativeHeaderType.tsym)
                return true;
        }
    }
    if (checkNestedClasses) {
        for (Scope.Entry i = c.members_field.elems; i != null; i = i.sibling) {
            if ((i.sym.kind == Kinds.TYP) && needsHeader(((ClassSymbol) i.sym), true))
                return true;
        }
    }
    return false;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:21,代码来源:JNIWriter.java

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

示例9: getAnnotations

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
static List<AnnotationMirror> getAnnotations(Element e, String name) {
    Name valueName = ((Symbol)e).getSimpleName().table.names.value;
    List<AnnotationMirror> res = new ArrayList<>();

    for (AnnotationMirror m : e.getAnnotationMirrors()) {
        TypeElement te = (TypeElement) m.getAnnotationType().asElement();
        if (te.getQualifiedName().contentEquals(name)) {
            Compound theAnno = (Compound)m;
            Array valueArray = (Array)theAnno.member(valueName);
            for (Attribute a : valueArray.getValue()) {
                AnnotationMirror theMirror = (AnnotationMirror) a;

                res.add(theMirror);
            }
        }
    }
    return res;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:19,代码来源:BasicAnnoTests.java

示例10: printObject

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
protected void printObject(String label, Object item, Details details) {
    if (item == null) {
        printNull(label);
    } else if (item instanceof Attribute) {
        printAttribute(label, (Attribute) item);
    } else if (item instanceof Symbol) {
        printSymbol(label, (Symbol) item, details);
    } else if (item instanceof Type) {
        printType(label, (Type) item, details);
    } else if (item instanceof JCTree) {
        printTree(label, (JCTree) item);
    } else if (item instanceof DocTree) {
        printDocTree(label, (DocTree) item);
    } else if (item instanceof List) {
        printList(label, (List) item);
    } else if (item instanceof Name) {
        printName(label, (Name) item);
    } else if (item instanceof Scope) {
        printScope(label, (Scope) item);
    } else {
        printString(label, String.valueOf(item));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:24,代码来源:DPrinter.java

示例11: isStructuralInterface

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
public static boolean isStructuralInterface( TypeProcessor tp, Symbol sym )
{
  if( sym == null || !sym.isInterface() || !sym.hasAnnotations() )
  {
    return false;
  }

  // use the raw type
  Type type = tp.getTypes().erasure( sym.type );
  sym = type.tsym;

  for( Attribute.Compound annotation : sym.getAnnotationMirrors() )
  {
    if( annotation.type.toString().equals( Structural.class.getName() ) )
    {
      return true;
    }
  }
  return false;
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:21,代码来源:TypeUtil.java

示例12: printObject

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
protected void printObject(String label, Object item, Details details) {
    if (item == null) {
        printNull(label);
    } else if (item instanceof Attribute) {
        printAttribute(label, (Attribute) item);
    } else if (item instanceof Symbol) {
        printSymbol(label, (Symbol) item, details);
    } else if (item instanceof Type) {
        printType(label, (Type) item, details);
    } else if (item instanceof JCTree) {
        printTree(label, (JCTree) item);
    } else if (item instanceof List) {
        printList(label, (List) item);
    } else if (item instanceof Name) {
        printName(label, (Name) item);
    } else {
        printString(label, String.valueOf(item));
    }
}
 
开发者ID:ojdkbuild,项目名称:lookaside_java-1.8.0-openjdk,代码行数:20,代码来源:DPrinter.java

示例13: getIncompatibleModifiers

import com.sun.tools.javac.code.Attribute; //导入依赖的package包/类
private static Set<Modifier> getIncompatibleModifiers(AnnotationTree tree, VisitorState state) {
  for (Attribute.Compound c : ASTHelpers.getSymbol(tree).getAnnotationMirrors()) {
    if (((TypeElement) c.getAnnotationType().asElement())
        .getQualifiedName()
        .contentEquals(GUAVA_ANNOTATION)) {
      @SuppressWarnings("unchecked")
      List<Attribute.Enum> modifiers =
          (List<Attribute.Enum>) c.member(state.getName("value")).getValue();
      return ImmutableSet.copyOf(Iterables.transform(modifiers, TO_MODIFIER));
    }
  }

  IncompatibleModifiers annotation = ASTHelpers.getAnnotation(tree, IncompatibleModifiers.class);
  if (annotation != null) {
    return ImmutableSet.copyOf(annotation.value());
  }

  return ImmutableSet.of();
}
 
开发者ID:google,项目名称:error-prone,代码行数:20,代码来源:IncompatibleModifiersChecker.java

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

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


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