本文整理汇总了Java中com.sun.tools.javac.code.Attribute.Compound方法的典型用法代码示例。如果您正苦于以下问题:Java Attribute.Compound方法的具体用法?Java Attribute.Compound怎么用?Java Attribute.Compound使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.code.Attribute
的用法示例。
在下文中一共展示了Attribute.Compound方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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");
}
示例2: 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;
}
示例3: createYieldPart
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/** Compose default value return if proxy do not allows call to inner instance. */
protected void createYieldPart(@NonNull final MethodSpec.Builder builder,
@NonNull final Type returnType,
@Nullable final Attribute.Compound yield) throws Exception {
// create return based on @Yield annotation values
final AutoProxy.Yield annotation = extractYield(yield);
final String value = annotation.value();
final Class<?> adapter = annotation.adapter();
final ReturnsPoet poet;
if (RetBool.class == adapter || RetBoolGenerator.class == adapter) {
poet = RetBoolGenerator.getInstance();
} else if (Returns.class == adapter && isRetBoolValue(value)) {
poet = RetBoolGenerator.getInstance();
} else if (RetNumber.class == adapter || RetNumberGenerator.class == adapter) {
poet = RetNumberGenerator.getInstance();
} else if (Returns.class == adapter && isRetNumberValue(value)) {
poet = RetNumberGenerator.getInstance();
} else if (Returns.class == adapter || ReturnsGenerator.class == adapter) {
poet = ReturnsGenerator.getInstance();
} else {
// create instance of generator by reflection info
final Constructor<?> ctr = adapter.getConstructor();
poet = (ReturnsPoet) ctr.newInstance();
}
final boolean composed = poet.compose(returnType, value, builder);
if (!composed) {
ReturnsGenerator.getInstance().compose(returnType, Returns.THROWS, builder);
}
}
示例4: annotations
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
* Get the annotations of this program element.
* Return an empty array if there are none.
*/
public AnnotationDesc[] annotations() {
if (!type.isAnnotated()) {
return new AnnotationDesc[0];
}
List<? extends TypeCompound> tas = type.getAnnotationMirrors();
AnnotationDesc res[] = new AnnotationDesc[tas.length()];
int i = 0;
for (Attribute.Compound a : tas) {
res[i++] = new AnnotationDescImpl(env, a);
}
return res;
}
示例5: annotations
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
* Get the annotations of this program element.
* Return an empty array if there are none.
*/
public AnnotationDesc[] annotations() {
AnnotationDesc res[] = new AnnotationDesc[sym.getRawAttributes().length()];
int i = 0;
for (Attribute.Compound a : sym.getRawAttributes()) {
res[i++] = new AnnotationDescImpl(env, a);
}
return res;
}
示例6: extractClass
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/** Extract reflection Class<?> information from compound. */
@NonNull
public static Class<?> extractClass(@NonNull final Attribute.Compound am) throws ClassNotFoundException {
final TypeElement te = (TypeElement) am.getAnnotationType().asElement();
return extractClass(te);
}
示例7: annotations
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
* Get the annotations of this program element.
* Return an empty array if there are none.
*/
@Override
public AnnotationDesc[] annotations() {
List<? extends TypeCompound> tas = type.getAnnotationMirrors();
if (tas == null ||
tas.isEmpty()) {
return new AnnotationDesc[0];
}
AnnotationDesc res[] = new AnnotationDesc[tas.length()];
int i = 0;
for (Attribute.Compound a : tas) {
res[i++] = new AnnotationDescImpl(env, a);
}
return res;
}
示例8: 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);
}
示例9: annotations
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
* Get the annotations of this parameter.
* Return an empty array if there are none.
*/
public AnnotationDesc[] annotations() {
AnnotationDesc res[] = new AnnotationDesc[sym.getRawAttributes().length()];
int i = 0;
for (Attribute.Compound a : sym.getRawAttributes()) {
res[i++] = new AnnotationDescImpl(env, a);
}
return res;
}
示例10: verifyExtensionInterfaces
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
private void verifyExtensionInterfaces( JCTree.JCClassDecl tree )
{
if( !hasAnnotation( tree.getModifiers().getAnnotations(), Extension.class ) )
{
return;
}
outer:
for( JCExpression iface: tree.getImplementsClause() )
{
final Symbol.TypeSymbol ifaceSym = iface.type.tsym;
if( ifaceSym == _tp.getSymtab().objectType.tsym )
{
continue;
}
for( Attribute.Compound anno: ifaceSym.getAnnotationMirrors() )
{
if( anno.type.toString().equals( Structural.class.getName() ) )
{
continue outer;
}
}
// extension interfaces must be structural
_tp.report( iface, Diagnostic.Kind.ERROR, ExtIssueMsg.MSG_ONLY_STRUCTURAL_INTERFACE_ALLOWED_HERE.get( iface.toString() ) );
}
}
示例11: annotations
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
* Get the annotations of this package.
* Return an empty array if there are none.
*/
public AnnotationDesc[] annotations() {
AnnotationDesc res[] = new AnnotationDesc[sym.getRawAttributes().length()];
int i = 0;
for (Attribute.Compound a : sym.getRawAttributes()) {
res[i++] = new AnnotationDescImpl(env, a);
}
return res;
}
示例12: getByVariable
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
public static SerializationStrategyRecord getByVariable(JCVariableDecl var) {
for (JCAnnotation annotation : var.mods.annotations) {
try {
List<Attribute.Compound> annotationAttributes = annotation.type.tsym.getMetadata().getDeclarationAttributes();
Attribute.Compound strategyCompound = null;
for (Attribute.Compound ac : annotationAttributes) {
if (ac.type.toString().endsWith("AutoSerializationStrategy")) {
strategyCompound = ac;
}
}
if (strategyCompound == null)
continue;
SerializationStrategyRecord result = new SerializationStrategyRecord();
for (Pair<com.sun.tools.javac.code.Symbol.MethodSymbol, Attribute> pair : strategyCompound.values) {
String annotationArgument = pair.fst.toString();
if (annotationArgument.startsWith("targetStrategy")) {
result.targetStrategy = ((Attribute.Constant) pair.snd).value.toString();
} else if (annotationArgument.startsWith("toTarget")) {
result.toTarget = ((Attribute.Constant) pair.snd).value.toString();
} else if (annotationArgument.startsWith("fromTarget")) {
result.fromTarget = ((Attribute.Constant) pair.snd).value.toString();
}
}
return result;
} catch (NullPointerException | ClassCastException | IndexOutOfBoundsException ignored) {
}
}
return null;
}
示例13: createCompoundFromAnnotationMirror
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
* Returns a newly created Attribute.Compound corresponding to an
* argument AnnotationMirror.
*
* @param am an AnnotationMirror, which may be part of an AST or an internally
* created subclass.
* @return a new Attribute.Compound corresponding to the AnnotationMirror
*/
public static Attribute.Compound createCompoundFromAnnotationMirror(ProcessingEnvironment env,
AnnotationMirror am) {
// 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.Compound((Type.ClassType)am.getAnnotationType(), values);
}
示例14: annotations
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
* Get the annotations of this program element.
* Return an empty array if there are none.
*/
public AnnotationDesc[] annotations() {
AnnotationDesc res[] = new AnnotationDesc[sym.getAnnotationMirrors().length()];
int i = 0;
for (Attribute.Compound a : sym.getAnnotationMirrors()) {
res[i++] = new AnnotationDescImpl(env, a);
}
return res;
}
示例15: createCompoundFromAnnotationMirror
import com.sun.tools.javac.code.Attribute; //导入方法依赖的package包/类
/**
* Returns a newly created Attribute.Compound corresponding to an argument AnnotationMirror.
*
* @param am an AnnotationMirror, which may be part of an AST or an internally created subclass
* @return a new Attribute.Compound corresponding to the AnnotationMirror
*/
public static Attribute.Compound createCompoundFromAnnotationMirror(
ProcessingEnvironment env, AnnotationMirror am) {
// 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.Compound((Type.ClassType) am.getAnnotationType(), values);
}