Search in sources :

Example 1 with IAnnotatable

use of org.eclipse.jdt.core.IAnnotatable in project che by eclipse.

the class StubCreator method appendFlags.

protected void appendFlags(final IMember member) throws JavaModelException {
    if (member instanceof IAnnotatable)
        for (IAnnotation annotation : ((IAnnotatable) member).getAnnotations()) {
            appendAnnotation(annotation);
        }
    int flags = member.getFlags();
    final int kind = member.getElementType();
    if (kind == IJavaElement.TYPE) {
        flags &= ~Flags.AccSuper;
        final IType type = (IType) member;
        if (!type.isMember())
            flags &= ~Flags.AccPrivate;
        if (Flags.isEnum(flags))
            flags &= ~Flags.AccAbstract;
    }
    if (Flags.isEnum(flags))
        flags &= ~Flags.AccFinal;
    if (kind == IJavaElement.METHOD) {
        flags &= ~Flags.AccVarargs;
        flags &= ~Flags.AccBridge;
    }
    if (flags != 0)
        fBuffer.append(Flags.toString(flags));
}
Also used : IAnnotation(org.eclipse.jdt.core.IAnnotation) IAnnotatable(org.eclipse.jdt.core.IAnnotatable) IType(org.eclipse.jdt.core.IType)

Example 2 with IAnnotatable

use of org.eclipse.jdt.core.IAnnotatable in project che by eclipse.

the class JavadocFinder method getAnnotations.

private String getAnnotations(IJavaElement element, ITypeRoot editorInputElement, IRegion hoverRegion) throws URISyntaxException, JavaModelException {
    if (!(element instanceof IPackageFragment)) {
        if (!(element instanceof IAnnotatable))
            return null;
        if (((IAnnotatable) element).getAnnotations().length == 0)
            return null;
    }
    IBinding binding = null;
    //TODO
    //getHoveredASTNode(editorInputElement, hoverRegion);
    ASTNode node = null;
    if (node == null) {
    //todo use ast ported parser,that uses our java model
    //            ASTParser p = ASTParser.newParser(ASTProvider.SHARED_AST_LEVEL);
    //            p.setProject(element.getJavaProject());
    //            p.setBindingsRecovery(true);
    //            try {
    //                binding = p.createBindings(new IJavaElement[]{element}, null)[0];
    //            } catch (OperationCanceledException e) {
    //                return null;
    //            }
    } else {
        binding = resolveBinding(node);
    }
    if (binding == null)
        return null;
    IAnnotationBinding[] annotations = binding.getAnnotations();
    if (annotations.length == 0)
        return null;
    StringBuffer buf = new StringBuffer();
    for (int i = 0; i < annotations.length; i++) {
        //TODO: skip annotations that don't have an @Documented annotation?
        addAnnotation(buf, element, annotations[i]);
        //$NON-NLS-1$
        buf.append("<br>");
    }
    return buf.toString();
}
Also used : IAnnotatable(org.eclipse.jdt.core.IAnnotatable) IPackageFragment(org.eclipse.jdt.core.IPackageFragment) IAnnotationBinding(org.eclipse.jdt.core.dom.IAnnotationBinding) IBinding(org.eclipse.jdt.core.dom.IBinding) ASTNode(org.eclipse.jdt.core.dom.ASTNode)

Aggregations

IAnnotatable (org.eclipse.jdt.core.IAnnotatable)2 IAnnotation (org.eclipse.jdt.core.IAnnotation)1 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)1 IType (org.eclipse.jdt.core.IType)1 ASTNode (org.eclipse.jdt.core.dom.ASTNode)1 IAnnotationBinding (org.eclipse.jdt.core.dom.IAnnotationBinding)1 IBinding (org.eclipse.jdt.core.dom.IBinding)1