本文整理匯總了Java中com.sun.source.tree.ClassTree.getImplementsClause方法的典型用法代碼示例。如果您正苦於以下問題:Java ClassTree.getImplementsClause方法的具體用法?Java ClassTree.getImplementsClause怎麽用?Java ClassTree.getImplementsClause使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.sun.source.tree.ClassTree
的用法示例。
在下文中一共展示了ClassTree.getImplementsClause方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: computeClass
import com.sun.source.tree.ClassTree; //導入方法依賴的package包/類
private static List<? extends TypeMirror> computeClass(Set<ElementKind> types, CompilationInfo info, TreePath parent, Tree error, int offset) {
ClassTree ct = (ClassTree) parent.getLeaf();
if (ct.getExtendsClause() == error) {
types.add(ElementKind.CLASS);
return null;
}
for (Tree t : ct.getImplementsClause()) {
if (t == error) {
types.add(ElementKind.INTERFACE);
return null;
}
}
//XXX: annotation types...
return null;
}
示例2: visitClass
import com.sun.source.tree.ClassTree; //導入方法依賴的package包/類
@Override
public Void visitClass(ClassTree node, Map<String, Object> p) {
if (getCurrentPath().getParentPath().getLeaf().getKind() != Kind.NEW_CLASS) {
filterByAcceptedKind(node.getExtendsClause(), ElementKind.CLASS);
for (Tree intf : node.getImplementsClause()) {
filterByAcceptedKind(intf, ElementKind.INTERFACE, ElementKind.ANNOTATION_TYPE);
}
}
return super.visitClass(node, p);
}
示例3: isInHeader
import com.sun.source.tree.ClassTree; //導入方法依賴的package包/類
private static boolean isInHeader(CompilationInfo info, ClassTree tree, int offset) {
CompilationUnitTree cut = info.getCompilationUnit();
SourcePositions sp = info.getTrees().getSourcePositions();
long lastKnownOffsetInHeader = sp.getStartPosition(cut, tree);
List<? extends Tree> impls = tree.getImplementsClause();
List<? extends TypeParameterTree> typeparams;
if (impls != null && !impls.isEmpty()) {
lastKnownOffsetInHeader= sp.getEndPosition(cut, impls.get(impls.size() - 1));
} else if ((typeparams = tree.getTypeParameters()) != null && !typeparams.isEmpty()) {
lastKnownOffsetInHeader= sp.getEndPosition(cut, typeparams.get(typeparams.size() - 1));
} else if (tree.getExtendsClause() != null) {
lastKnownOffsetInHeader = sp.getEndPosition(cut, tree.getExtendsClause());
} else if (tree.getModifiers() != null) {
lastKnownOffsetInHeader = sp.getEndPosition(cut, tree.getModifiers());
}
TokenSequence<JavaTokenId> ts = info.getTreeUtilities().tokensFor(tree);
ts.move((int) lastKnownOffsetInHeader);
while (ts.moveNext()) {
if (ts.token().id() == JavaTokenId.LBRACE) {
return offset < ts.offset();
}
}
return false;
}
示例4: implementMethods
import com.sun.source.tree.ClassTree; //導入方法依賴的package包/類
@TriggerTreeKind(Kind.CLASS)
@Messages({
"# {0} - the FQN of the type whose methods will be implemented",
"ERR_ImplementMethods=Implement unimplemented abstract methods of {0}"
})
public static ErrorDescription implementMethods(HintContext ctx) {
ClassTree clazz = (ClassTree) ctx.getPath().getLeaf();
Element typeEl = ctx.getInfo().getTrees().getElement(ctx.getPath());
if (typeEl == null || !typeEl.getKind().isClass())
return null;
List<Tree> candidate = new ArrayList<Tree>(clazz.getImplementsClause());
candidate.add(clazz.getExtendsClause());
Tree found = null;
for (Tree cand : candidate) {
if ( ctx.getInfo().getTrees().getSourcePositions().getStartPosition(ctx.getInfo().getCompilationUnit(), cand) <= ctx.getCaretLocation()
&& ctx.getCaretLocation() <= ctx.getInfo().getTrees().getSourcePositions().getEndPosition(ctx.getInfo().getCompilationUnit(), cand)) {
found = cand;
break;
}
}
if (found == null) return null;
TreePath foundPath = new TreePath(ctx.getPath(), found);
Element supertype = ctx.getInfo().getTrees().getElement(foundPath);
if (supertype == null || (!supertype.getKind().isClass() && !supertype.getKind().isInterface()))
return null;
List<ExecutableElement> unimplemented = computeUnimplemented(ctx.getInfo(), typeEl, supertype);
if (!unimplemented.isEmpty()) {
return ErrorDescriptionFactory.forName(ctx, foundPath, Bundle.ERR_ImplementMethods(((TypeElement) supertype).getQualifiedName().toString()), new ImplementFix(ctx.getInfo(), ctx.getPath(), (TypeElement) typeEl, (TypeElement) supertype).toEditorFix());
}
return null;
}
示例5: visitClassDeclaration
import com.sun.source.tree.ClassTree; //導入方法依賴的package包/類
public void visitClassDeclaration(ClassTree node) {
sync(node);
List<Op> breaks =
visitModifiers(node.getModifiers(), Direction.VERTICAL, Optional.<BreakTag>absent());
boolean hasSuperclassType = node.getExtendsClause() != null;
boolean hasSuperInterfaceTypes = !node.getImplementsClause().isEmpty();
builder.addAll(breaks);
token(node.getKind() == Tree.Kind.INTERFACE ? "interface" : "class");
builder.space();
visit(node.getSimpleName());
if (!node.getTypeParameters().isEmpty()) {
token("<");
}
builder.open(plusFour);
{
if (!node.getTypeParameters().isEmpty()) {
typeParametersRest(
node.getTypeParameters(),
hasSuperclassType || hasSuperInterfaceTypes ? plusFour : ZERO);
}
if (hasSuperclassType) {
builder.breakToFill(" ");
token("extends");
builder.space();
scan(node.getExtendsClause(), null);
}
if (hasSuperInterfaceTypes) {
builder.breakToFill(" ");
builder.open(node.getImplementsClause().size() > 1 ? plusFour : ZERO);
token(node.getKind() == Tree.Kind.INTERFACE ? "extends" : "implements");
builder.space();
boolean first = true;
for (Tree superInterfaceType : node.getImplementsClause()) {
if (!first) {
token(",");
builder.breakOp(" ");
}
scan(superInterfaceType, null);
first = false;
}
builder.close();
}
}
builder.close();
if (node.getMembers() == null) {
token(";");
} else {
addBodyDeclarations(node.getMembers(), BracesOrNot.YES, FirstDeclarationsOrNot.YES);
}
dropEmptyDeclarations();
}