本文整理汇总了Java中com.sun.tools.javac.code.Attribute.TypeCompound类的典型用法代码示例。如果您正苦于以下问题:Java TypeCompound类的具体用法?Java TypeCompound怎么用?Java TypeCompound使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TypeCompound类属于com.sun.tools.javac.code.Attribute包,在下文中一共展示了TypeCompound类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: getAndRemoveNonFieldTAs
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的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();
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:Gen.java
示例2: catchTypesWithAnnotationsFromMulticatch
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
List<Pair<List<Attribute.TypeCompound>, JCExpression>> catchTypesWithAnnotationsFromMulticatch(JCTypeUnion tree, List<TypeCompound> first) {
List<JCExpression> alts = tree.alternatives;
List<Pair<List<TypeCompound>, JCExpression>> res = List.of(new Pair<>(first, alts.head));
alts = alts.tail;
while(alts != null && alts.head != null) {
JCExpression alt = alts.head;
if (alt instanceof JCAnnotatedType) {
JCAnnotatedType a = (JCAnnotatedType)alt;
res = res.prepend(new Pair<>(annotate.fromAnnotations(a.annotations), alt));
} else {
res = res.prepend(new Pair<>(List.nil(), alt));
}
alts = alts.tail;
}
return res.reverse();
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:18,代码来源:Gen.java
示例3: setAttributes
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
public void setAttributes(SymbolMetadata other) {
if (other == null) {
throw new NullPointerException();
}
setDeclarationAttributes(other.getDeclarationAttributes());
if ((sym.flags() & Flags.BRIDGE) != 0) {
Assert.check(other.sym.kind == Kind.MTH);
ListBuffer<TypeCompound> typeAttributes = new ListBuffer<>();
for (TypeCompound tc : other.getTypeAttributes()) {
// Carry over only contractual type annotations: i.e nothing interior to method body.
if (!tc.position.type.isLocal())
typeAttributes.append(tc);
}
setTypeAttributes(typeAttributes.toList());
} else {
setTypeAttributes(other.getTypeAttributes());
}
if (sym.kind == Kind.TYP) {
setInitTypeAttributes(other.getInitTypeAttributes());
setClassInitTypeAttributes(other.getClassInitTypeAttributes());
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:23,代码来源:SymbolMetadata.java
示例4: attributeTypeAnnotation
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
/** Attribute and store a semantic representation of the type annotation tree {@code tree} into
* the tree.attribute field.
*
* @param a the tree representing an annotation
* @param expectedAnnotationType the expected (super)type of the annotation
* @param env the the current env in where the annotation instance is found
*/
public Attribute.TypeCompound attributeTypeAnnotation(JCAnnotation a, Type expectedAnnotationType,
Env<AttrContext> env)
{
// The attribute might have been entered if it is Target or Repetable
// Because TreeCopier does not copy type, redo this if type is null
if (a.attribute == null || a.type == null || !(a.attribute instanceof Attribute.TypeCompound)) {
// Create a new TypeCompound
List<Pair<MethodSymbol,Attribute>> elems =
attributeAnnotationValues(a, expectedAnnotationType, env);
Attribute.TypeCompound tc =
new Attribute.TypeCompound(a.type, elems, TypeAnnotationPosition.unknown);
a.attribute = tc;
return tc;
} else {
// Use an existing TypeCompound
return (Attribute.TypeCompound)a.attribute;
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:27,代码来源:Annotate.java
示例5: setAttributes
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
public void setAttributes(SymbolMetadata other) {
if (other == null) {
throw new NullPointerException();
}
setDeclarationAttributes(other.getDeclarationAttributes());
if ((sym.flags() & Flags.BRIDGE) != 0) {
Assert.check(other.sym.kind == MTH);
ListBuffer<TypeCompound> typeAttributes = new ListBuffer<>();
for (TypeCompound tc : other.getTypeAttributes()) {
// Carry over only contractual type annotations: i.e nothing interior to method body.
if (!tc.position.type.isLocal())
typeAttributes.append(tc);
}
setTypeAttributes(typeAttributes.toList());
} else {
setTypeAttributes(other.getTypeAttributes());
}
if (sym.kind == TYP) {
setInitTypeAttributes(other.getInitTypeAttributes());
setClassInitTypeAttributes(other.getClassInitTypeAttributes());
}
}
开发者ID:wmdietl,项目名称:jsr308-langtools,代码行数:23,代码来源:SymbolMetadata.java
示例6: isTypeCompoundContained
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的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
示例7: storeVariable
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的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
示例8: store
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的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
示例9: isTypeCompoundContained
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的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
示例10: annotations
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的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;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:19,代码来源:AnnotatedTypeImpl.java
示例11: annotations
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的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;
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:17,代码来源:TypeVariableImpl.java
示例12: normalizeMethod
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
/** Insert instance initializer code into initial constructor.
* @param md The tree potentially representing a
* constructor's definition.
* @param initCode The list of instance initializer statements.
* @param initTAs Type annotations from the initializer expression.
*/
void normalizeMethod(JCMethodDecl md, List<JCStatement> initCode, List<TypeCompound> initTAs) {
if (md.name == names.init && TreeInfo.isInitialConstructor(md)) {
// We are seeing a constructor that does not call another
// constructor of the same class.
List<JCStatement> stats = md.body.stats;
ListBuffer<JCStatement> newstats = new ListBuffer<JCStatement>();
if (stats.nonEmpty()) {
// Copy initializers of synthetic variables generated in
// the translation of inner classes.
while (TreeInfo.isSyntheticInit(stats.head)) {
newstats.append(stats.head);
stats = stats.tail;
}
// Copy superclass constructor call
newstats.append(stats.head);
stats = stats.tail;
// Copy remaining synthetic initializers.
while (stats.nonEmpty() &&
TreeInfo.isSyntheticInit(stats.head)) {
newstats.append(stats.head);
stats = stats.tail;
}
// Now insert the initializer code.
newstats.appendList(initCode);
// And copy all remaining statements.
while (stats.nonEmpty()) {
newstats.append(stats.head);
stats = stats.tail;
}
}
md.body.stats = newstats.toList();
if (md.body.endpos == Position.NOPOS)
md.body.endpos = TreeInfo.endPos(md.body.stats.last());
md.sym.appendUniqueTypeAttributes(initTAs);
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:45,代码来源:Gen.java
示例13: copyNewClassAnnotationsToOwner
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
private void copyNewClassAnnotationsToOwner(JCNewClass tree) {
Symbol sym = tree.def.sym;
TypeAnnotationPosition pos = new TypeAnnotationPosition();
ListBuffer<Attribute.TypeCompound> newattrs =
new ListBuffer<Attribute.TypeCompound>();
for (Attribute.TypeCompound old : sym.getRawTypeAttributes()) {
newattrs.append(new Attribute.TypeCompound(old.type, old.values,
pos));
}
pos.type = TargetType.NEW;
pos.pos = tree.pos;
sym.owner.appendUniqueTypeAttributes(newattrs.toList());
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:16,代码来源:TypeAnnotations.java
示例14: setTypeAnnotationPos
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
private void setTypeAnnotationPos(List<JCAnnotation> annotations,
TypeAnnotationPosition position) {
for (JCAnnotation anno : annotations) {
// attribute might be null during DeferredAttr;
// we will be back later.
if (anno.attribute != null) {
((Attribute.TypeCompound) anno.attribute).position = position;
}
}
}
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:11,代码来源:TypeAnnotations.java
示例15: getAndRemoveNonFieldTAs
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的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();
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:Gen.java
示例16: normalizeMethod
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
/** Insert instance initializer code into initial constructor.
* @param md The tree potentially representing a
* constructor's definition.
* @param initCode The list of instance initializer statements.
* @param initTAs Type annotations from the initializer expression.
*/
void normalizeMethod(JCMethodDecl md, List<JCStatement> initCode, List<TypeCompound> initTAs) {
if (md.name == names.init && TreeInfo.isInitialConstructor(md)) {
// We are seeing a constructor that does not call another
// constructor of the same class.
List<JCStatement> stats = md.body.stats;
ListBuffer<JCStatement> newstats = new ListBuffer<>();
if (stats.nonEmpty()) {
// Copy initializers of synthetic variables generated in
// the translation of inner classes.
while (TreeInfo.isSyntheticInit(stats.head)) {
newstats.append(stats.head);
stats = stats.tail;
}
// Copy superclass constructor call
newstats.append(stats.head);
stats = stats.tail;
// Copy remaining synthetic initializers.
while (stats.nonEmpty() &&
TreeInfo.isSyntheticInit(stats.head)) {
newstats.append(stats.head);
stats = stats.tail;
}
// Now insert the initializer code.
newstats.appendList(initCode);
// And copy all remaining statements.
while (stats.nonEmpty()) {
newstats.append(stats.head);
stats = stats.tail;
}
}
md.body.stats = newstats.toList();
if (md.body.endpos == Position.NOPOS)
md.body.endpos = TreeInfo.endPos(md.body.stats.last());
md.sym.appendUniqueTypeAttributes(initTAs);
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:45,代码来源:Gen.java
示例17: copyNewClassAnnotationsToOwner
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
private void copyNewClassAnnotationsToOwner(JCNewClass tree) {
Symbol sym = tree.def.sym;
final TypeAnnotationPosition pos =
TypeAnnotationPosition.newObj(tree.pos);
ListBuffer<Attribute.TypeCompound> newattrs = new ListBuffer<>();
for (Attribute.TypeCompound old : sym.getRawTypeAttributes()) {
newattrs.append(new Attribute.TypeCompound(old.type, old.values,
pos));
}
sym.owner.appendUniqueTypeAttributes(newattrs.toList());
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:14,代码来源:TypeAnnotations.java
示例18: findTypeCompoundPosition
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
private void findTypeCompoundPosition(JCTree tree, JCTree frame, List<Attribute.TypeCompound> annotations) {
if (!annotations.isEmpty()) {
final TypeAnnotationPosition p =
resolveFrame(tree, frame, frames, currentLambda, 0, new ListBuffer<>());
for (TypeCompound tc : annotations)
tc.position = p;
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:TypeAnnotations.java
示例19: setTypeAnnotationPos
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
private void setTypeAnnotationPos(List<JCAnnotation> annotations, TypeAnnotationPosition position)
{
// attribute might be null during DeferredAttr;
// we will be back later.
for (JCAnnotation anno : annotations) {
if (anno.attribute != null)
((Attribute.TypeCompound) anno.attribute).position = position;
}
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:TypeAnnotations.java
示例20: appendUniqueTypes
import com.sun.tools.javac.code.Attribute.TypeCompound; //导入依赖的package包/类
public SymbolMetadata appendUniqueTypes(List<Attribute.TypeCompound> l) {
if (l.isEmpty()) {
// no-op
} else if (type_attributes.isEmpty()) {
type_attributes = l;
} else {
// TODO: in case we expect a large number of annotations, this
// might be inefficient.
for (Attribute.TypeCompound tc : l) {
if (!type_attributes.contains(tc))
type_attributes = type_attributes.append(tc);
}
}
return this;
}
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:SymbolMetadata.java
注:本文中的com.sun.tools.javac.code.Attribute.TypeCompound类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论