当前位置: 首页>>代码示例>>Java>>正文


Java ClassTree.getImplementsClause方法代码示例

本文整理汇总了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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:CreateElementUtilities.java

示例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);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:11,代码来源:ComputeImports.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:JavadocUtilities.java

示例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;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:43,代码来源:ImplementMethods.java

示例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();
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:52,代码来源:JavaInputAstVisitor.java


注:本文中的com.sun.source.tree.ClassTree.getImplementsClause方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。