本文整理汇总了Java中com.sun.source.tree.AnnotatedTypeTree类的典型用法代码示例。如果您正苦于以下问题:Java AnnotatedTypeTree类的具体用法?Java AnnotatedTypeTree怎么用?Java AnnotatedTypeTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AnnotatedTypeTree类属于com.sun.source.tree包,在下文中一共展示了AnnotatedTypeTree类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: visitAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public AnnotatedTypeMirror visitAnnotatedType(AnnotatedTypeTree node,
AnnotatedTypeFactory f) {
AnnotatedTypeMirror type = visit(node.getUnderlyingType(), f);
if (type == null) // e.g., for receiver type
type = f.toAnnotatedType(f.types.getNoType(TypeKind.NONE));
assert AnnotatedTypeFactory.validAnnotatedType(type);
List<? extends AnnotationMirror> annos = InternalUtils.annotationsFromTree(node);
type.addAnnotations(annos);
if (type.getKind() == TypeKind.TYPEVAR) {
((AnnotatedTypeVariable)type).getUpperBound().addMissingAnnotations(annos);
}
if (type.getKind() == TypeKind.WILDCARD) {
((AnnotatedWildcardType)type).getExtendsBound().addMissingAnnotations(annos);
}
return type;
}
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:21,代码来源:TypeFromTree.java
示例2: visitAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public Tree visitAnnotatedType(AnnotatedTypeTree tree, Void p) {
AnnotatedTypeTree n = make.AnnotatedType(tree.getAnnotations(), tree.getUnderlyingType());
comments.copyComments(tree, n);
model.setPos(n, model.getPos(tree));
return n;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:8,代码来源:TreeDuplicator.java
示例3: createHighlightImpl
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
private static Token<JavaTokenId> createHighlightImpl(CompilationInfo info, Document doc, TreePath tree) {
Tree leaf = tree.getLeaf();
SourcePositions positions = info.getTrees().getSourcePositions();
CompilationUnitTree cu = info.getCompilationUnit();
//XXX: do not use instanceof:
if (leaf instanceof MethodTree || leaf instanceof VariableTree || leaf instanceof ClassTree
|| leaf instanceof MemberSelectTree || leaf instanceof AnnotatedTypeTree || leaf instanceof MemberReferenceTree) {
return findIdentifierSpan(info, doc, tree);
}
int start = (int) positions.getStartPosition(cu, leaf);
int end = (int) positions.getEndPosition(cu, leaf);
if (start == Diagnostic.NOPOS || end == Diagnostic.NOPOS) {
return null;
}
TokenHierarchy<?> th = info.getTokenHierarchy();
TokenSequence<JavaTokenId> ts = th.tokenSequence(JavaTokenId.language());
if (ts.move(start) == Integer.MAX_VALUE) {
return null;
}
if (ts.moveNext()) {
Token<JavaTokenId> token = ts.token();
if (ts.offset() == start && token != null) {
final JavaTokenId id = token.id();
if (id == JavaTokenId.IDENTIFIER) {
return token;
}
if (id == JavaTokenId.THIS || id == JavaTokenId.SUPER) {
return ts.offsetToken();
}
}
}
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:41,代码来源:Utilities.java
示例4: visitAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public Void visitAnnotatedType(AnnotatedTypeTree tree, List<Node> d) {
List<Node> below = new ArrayList<Node>();
addCorrespondingElement(below);
addCorrespondingType(below);
addCorrespondingComments(below);
super.visitAnnotatedType(tree, below);
d.add(new TreeNode(info, getCurrentPath(), below));
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:14,代码来源:TreeNode.java
示例5: isGenericOrArray
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
private boolean isGenericOrArray(Tree t) {
return ((t.getKind() == Tree.Kind.PARAMETERIZED_TYPE)
|| (t.getKind() == Tree.Kind.ARRAY_TYPE)
|| (t.getKind() == Tree.Kind.EXTENDS_WILDCARD)
|| (t.getKind() == Tree.Kind.SUPER_WILDCARD)
|| (t.getKind() == Tree.Kind.ANNOTATED_TYPE &&
isGenericOrArray(((AnnotatedTypeTree)t).getUnderlyingType()))
// Monolithic: one node for entire "new". So, handle specially.
// || (t.getKind() == Tree.Kind.NEW_ARRAY)
);
}
开发者ID:typetools,项目名称:annotation-tools,代码行数:12,代码来源:GenericArrayLocationCriterion.java
示例6: checkTypePath
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
private boolean checkTypePath(int i, Tree typeTree) {
try {
loop: while (typeTree != null && i < astPath.size()) {
ASTPath.ASTEntry entry = astPath.get(i);
Tree.Kind kind = entry.getTreeKind();
switch (kind) {
case ANNOTATED_TYPE:
typeTree = ((AnnotatedTypeTree) typeTree)
.getUnderlyingType();
continue;
case ARRAY_TYPE:
typeTree = ((ArrayTypeTree) typeTree).getType();
break;
case MEMBER_SELECT:
typeTree = ((MemberSelectTree) typeTree).getExpression();
break;
case PARAMETERIZED_TYPE:
if (entry.childSelectorIs(ASTPath.TYPE_ARGUMENT)) {
int arg = entry.getArgument();
typeTree = ((ParameterizedTypeTree) typeTree)
.getTypeArguments().get(arg);
} else { // TYPE
typeTree = ((ParameterizedTypeTree) typeTree).getType();
}
break;
default:
if (isWildcard(kind)) {
return ++i == astPath.size(); // ???
}
break loop;
}
++i;
}
} catch (RuntimeException ex) {}
return false;
}
开发者ID:typetools,项目名称:annotation-tools,代码行数:37,代码来源:ASTPathCriterion.java
示例7: localDepth
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
/**
* Returns the depth of type nesting of the innermost nested type of a type AST.
* For example, both {@code A.B.C} and {@code A.B<D.E.F.G>.C} have depth 3.
*/
private int localDepth(Tree node) {
Tree t = node;
int result = 0;
loop:
while (t != null) {
switch (t.getKind()) {
case ANNOTATED_TYPE:
t = ((AnnotatedTypeTree) t).getUnderlyingType();
break;
case MEMBER_SELECT:
if (t instanceof JCTree.JCFieldAccess) {
JCTree.JCFieldAccess jfa = (JCTree.JCFieldAccess) t;
if (jfa.sym.kind == Kinds.PCK) {
t = jfa.getExpression();
continue;
}
}
t = ((MemberSelectTree) t).getExpression();
++result;
break;
default:
break loop;
}
}
return result;
}
开发者ID:typetools,项目名称:annotation-tools,代码行数:31,代码来源:Insertions.java
示例8: visitAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public Void visitAnnotatedType(AnnotatedTypeTree tree, VisitorState visitorState) {
VisitorState state = visitorState.withPath(getCurrentPath());
for (AnnotatedTypeTreeMatcher matcher : annotatedTypeMatchers) {
if (!isSuppressed(matcher, state)) {
try {
reportMatch(matcher.matchAnnotatedType(tree, state), tree, state);
} catch (Throwable t) {
handleError(matcher, t);
}
}
}
return super.visitAnnotatedType(tree, state);
}
开发者ID:google,项目名称:error-prone,代码行数:15,代码来源:ErrorProneScanner.java
示例9: isDiamondTree
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
/**
* Returns true if the tree is of a diamond type.
* In contrast to the implementation in TreeInfo, this version
* works on Trees.
*
* @see com.sun.tools.javac.tree.TreeInfo#isDiamond(JCTree)
*/
public static final boolean isDiamondTree(Tree tree) {
switch (tree.getKind()) {
case ANNOTATED_TYPE: return isDiamondTree(((AnnotatedTypeTree)tree).getUnderlyingType());
case PARAMETERIZED_TYPE: return ((ParameterizedTypeTree)tree).getTypeArguments().isEmpty();
case NEW_CLASS: return isDiamondTree(((NewClassTree)tree).getIdentifier());
default: return false;
}
}
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:16,代码来源:TreeUtils.java
示例10: visitNewClass
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public Void visitNewClass(NewClassTree node, Void p) {
AnnotatedDeclaredType type = atypeFactory.getAnnotatedType(node);
ExpressionTree identifier = node.getIdentifier();
if (identifier instanceof AnnotatedTypeTree) {
AnnotatedTypeTree t = (AnnotatedTypeTree) identifier;
for (AnnotationMirror a : atypeFactory.getAnnotatedType(t).getAnnotations()) {
// is this an annotation of the nullness checker?
boolean nullnessCheckerAnno = containsSameIgnoringValues(
atypeFactory.getNullnessAnnotations(), a);
if (nullnessCheckerAnno && !AnnotationUtils.areSame(NONNULL, a)) {
// The type is not non-null => warning
checker.report(
Result.warning("new.class.type.invalid",
type.getAnnotations()), node);
// Note that other consistency checks are made by isValid.
}
}
if (t.toString().contains("@PolyNull")) {
// TODO: this is a hack, but PolyNull gets substituted
// afterwards
checker.report(
Result.warning("new.class.type.invalid",
type.getAnnotations()), node);
}
}
// TODO: It might be nicer to introduce a framework-level
// isValidNewClassType or some such.
return super.visitNewClass(node, p);
}
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:31,代码来源:NullnessVisitor.java
示例11: isDiamondTree
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
/**
* Returns true if the tree is of a diamond type. In contrast to the implementation in TreeInfo,
* this version works on Trees.
*
* @see com.sun.tools.javac.tree.TreeInfo#isDiamond(JCTree)
*/
public static final boolean isDiamondTree(Tree tree) {
switch (tree.getKind()) {
case ANNOTATED_TYPE:
return isDiamondTree(((AnnotatedTypeTree) tree).getUnderlyingType());
case PARAMETERIZED_TYPE:
return ((ParameterizedTypeTree) tree).getTypeArguments().isEmpty();
case NEW_CLASS:
return isDiamondTree(((NewClassTree) tree).getIdentifier());
default:
return false;
}
}
开发者ID:bazelbuild,项目名称:bazel,代码行数:19,代码来源:TreeUtils.java
示例12: visitAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public List<? extends TypeMirror> visitAnnotatedType(AnnotatedTypeTree node, Object p) {
return null;
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:5,代码来源:ExpectedTypeResolver.java
示例13: visitAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public Mirror visitAnnotatedType(AnnotatedTypeTree node, EvaluationContext p) {
// Annotations are ignored and super delegates to the underlying type
return super.visitAnnotatedType(node, p);
}
开发者ID:apache,项目名称:incubator-netbeans,代码行数:6,代码来源:EvaluatorVisitor.java
示例14: visitAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public R visitAnnotatedType(AnnotatedTypeTree att, P p) {
return null;
}
开发者ID:fundacionjala,项目名称:oblivion-netbeans-plugin,代码行数:5,代码来源:ApexTreeVisitorAdapter.java
示例15: visitAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public List<T> visitAnnotatedType(AnnotatedTypeTree node, T p) {
return checkForCriteria(node);
}
开发者ID:fundacionjala,项目名称:oblivion-netbeans-plugin,代码行数:5,代码来源:TreeFinder.java
示例16: visitAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public UAnnotatedType visitAnnotatedType(AnnotatedTypeTree tree, Void v) {
return UAnnotatedType.create(
cast(templateExpressions(tree.getAnnotations()), UAnnotation.class),
template(tree.getUnderlyingType()));
}
开发者ID:google,项目名称:error-prone,代码行数:7,代码来源:UTemplater.java
示例17: visitAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public Choice<Unifier> visitAnnotatedType(AnnotatedTypeTree node, Unifier unifier) {
return unifyList(unifier, getAnnotations(), node.getAnnotations())
.thenChoose(unifications(getUnderlyingType(), node.getUnderlyingType()));
}
开发者ID:google,项目名称:error-prone,代码行数:6,代码来源:UAnnotatedType.java
示例18: matchAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public Description matchAnnotatedType(AnnotatedTypeTree tree, VisitorState state) {
Type type = ASTHelpers.getType(tree);
return check(type, tree.getAnnotations());
}
开发者ID:google,项目名称:error-prone,代码行数:6,代码来源:NullablePrimitive.java
示例19: annotationsFromTree
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
public final static List<? extends AnnotationMirror> annotationsFromTree(AnnotatedTypeTree node) {
return annotationsFromTypeAnnotationTrees(((JCAnnotatedType)node).annotations);
}
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:4,代码来源:InternalUtils.java
示例20: visitAnnotatedType
import com.sun.source.tree.AnnotatedTypeTree; //导入依赖的package包/类
@Override
public Node visitAnnotatedType(AnnotatedTypeTree tree, Void p) {
return scan(tree.getUnderlyingType(), p);
}
开发者ID:reprogrammer,项目名称:checker-framework,代码行数:5,代码来源:CFGBuilder.java
注:本文中的com.sun.source.tree.AnnotatedTypeTree类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论