本文整理汇总了Java中com.sun.tools.javac.code.Symbol.VarSymbol.getRawTypeAttributes方法的典型用法代码示例。如果您正苦于以下问题:Java VarSymbol.getRawTypeAttributes方法的具体用法?Java VarSymbol.getRawTypeAttributes怎么用?Java VarSymbol.getRawTypeAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.sun.tools.javac.code.Symbol.VarSymbol
的用法示例。
在下文中一共展示了VarSymbol.getRawTypeAttributes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAndRemoveNonFieldTAs
import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
private List<Attribute.TypeCompound> getAndRemoveNonFieldTAs(VarSymbol sym) {
List<TypeCompound> tas = sym.getRawTypeAttributes();
ListBuffer<Attribute.TypeCompound> fieldTAs = new ListBuffer<Attribute.TypeCompound>();
ListBuffer<Attribute.TypeCompound> nonfieldTAs = new ListBuffer<Attribute.TypeCompound>();
for (TypeCompound ta : tas) {
if (ta.getPosition().type == TargetType.FIELD) {
fieldTAs.add(ta);
} else {
if (typeAnnoAsserts) {
Assert.error("Type annotation does not have a valid positior");
}
nonfieldTAs.add(ta);
}
}
sym.setTypeAttributes(fieldTAs.toList());
return nonfieldTAs.toList();
}
示例2: getAndRemoveNonFieldTAs
import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
private List<Attribute.TypeCompound> getAndRemoveNonFieldTAs(VarSymbol sym) {
List<TypeCompound> tas = sym.getRawTypeAttributes();
ListBuffer<Attribute.TypeCompound> fieldTAs = new ListBuffer<>();
ListBuffer<Attribute.TypeCompound> nonfieldTAs = new ListBuffer<>();
for (TypeCompound ta : tas) {
Assert.check(ta.getPosition().type != TargetType.UNKNOWN);
if (ta.getPosition().type == TargetType.FIELD) {
fieldTAs.add(ta);
} else {
nonfieldTAs.add(ta);
}
}
sym.setTypeAttributes(fieldTAs.toList());
return nonfieldTAs.toList();
}
示例3: annotateField
import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的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));
}
}
}
}
示例4: annotateLocal
import com.sun.tools.javac.code.Symbol.VarSymbol; //导入方法依赖的package包/类
/**
* Extracts type annotations from the element and inserts them into the
* type of the element.
*
* The element needs to be that of a local variable.
*
* @param type the type of the field
* @param element the element of a field
*/
private static void annotateLocal(AnnotatedTypeMirror type, VariableElement element) {
if (element.getKind() != ElementKind.LOCAL_VARIABLE &&
element.getKind() != ElementKind.RESOURCE_VARIABLE &&
element.getKind() != ElementKind.EXCEPTION_PARAMETER) {
ErrorReporter.errorAbort("TypeFromElement.annotateLocal: " +
"invalid non-local-variable element " + element + " [" + element.getKind() + "]");
}
VarSymbol symbol = (VarSymbol) element;
// Add declaration annotations to the local variable type
addAnnotationsToElt(type, symbol.getAnnotationMirrors());
for (Attribute.TypeCompound anno : symbol.getRawTypeAttributes()) {
TypeAnnotationPosition pos = anno.position;
switch (pos.type) {
case LOCAL_VARIABLE:
case RESOURCE_VARIABLE:
case EXCEPTION_PARAMETER:
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.annotateLocal: " +
"invalid position " + pos.type +
" for annotation: " + anno +
" for element: " + ElementUtils.getVerboseName(element));
}
}
}
}