Search in sources :

Example 1 with IAnnotation

use of org.eclipse.jdt.core.IAnnotation 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 IAnnotation

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

the class JavaElementLabelComposer method appendAnnotationLabels.

protected void appendAnnotationLabels(IAnnotation[] annotations, long flags) throws JavaModelException {
    for (int j = 0; j < annotations.length; j++) {
        IAnnotation annotation = annotations[j];
        appendAnnotationLabel(annotation, flags);
        fBuffer.append(' ');
    }
}
Also used : IAnnotation(org.eclipse.jdt.core.IAnnotation)

Example 3 with IAnnotation

use of org.eclipse.jdt.core.IAnnotation in project xtext-eclipse by eclipse.

the class JavaElementDelegateJunitLaunch method containsElementsSearchedFor.

@Override
protected boolean containsElementsSearchedFor(IFile file) {
    IJavaElement element = JavaCore.create(file);
    if (element == null || !element.exists() || !(element instanceof ICompilationUnit)) {
        return false;
    }
    try {
        ICompilationUnit cu = (ICompilationUnit) element;
        for (IType type : cu.getAllTypes()) {
            for (IMethod method : type.getMethods()) {
                int flags = method.getFlags();
                if (Modifier.isPublic(flags) && !Modifier.isStatic(flags) && method.getNumberOfParameters() == 0 && Signature.SIG_VOID.equals(method.getReturnType()) && method.getElementName().startsWith("test")) {
                    // $NON-NLS-1$
                    return true;
                }
                // $NON-NLS-1$
                IAnnotation annotation = method.getAnnotation("Test");
                if (annotation.exists())
                    return true;
            }
        }
    } catch (JavaModelException e) {
        log.error(e.getMessage(), e);
    }
    return super.containsElementsSearchedFor(file);
}
Also used : IAnnotation(org.eclipse.jdt.core.IAnnotation) IJavaElement(org.eclipse.jdt.core.IJavaElement) ICompilationUnit(org.eclipse.jdt.core.ICompilationUnit) JavaModelException(org.eclipse.jdt.core.JavaModelException) IMethod(org.eclipse.jdt.core.IMethod) IType(org.eclipse.jdt.core.IType)

Example 4 with IAnnotation

use of org.eclipse.jdt.core.IAnnotation in project eclipse.jdt.ls by eclipse.

the class JavaElementLabelComposer method appendAnnotationLabels.

protected void appendAnnotationLabels(IAnnotation[] annotations, long flags) throws JavaModelException {
    for (int j = 0; j < annotations.length; j++) {
        IAnnotation annotation = annotations[j];
        appendAnnotationLabel(annotation, flags);
        fBuilder.append(' ');
    }
}
Also used : IAnnotation(org.eclipse.jdt.core.IAnnotation)

Example 5 with IAnnotation

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

the class SourcesFromBytecodeGenerator method appendAnnotationLabels.

protected void appendAnnotationLabels(IAnnotation[] annotations, long flags, StringBuilder builder, String indent) throws JavaModelException {
    for (IAnnotation annotation : annotations) {
        builder.append(indent);
        appendAnnotationLabel(annotation, flags, builder);
        builder.append('\n');
    }
}
Also used : IAnnotation(org.eclipse.jdt.core.IAnnotation)

Aggregations

IAnnotation (org.eclipse.jdt.core.IAnnotation)10 IType (org.eclipse.jdt.core.IType)4 ICompilationUnit (org.eclipse.jdt.core.ICompilationUnit)2 IJavaElement (org.eclipse.jdt.core.IJavaElement)2 IMethod (org.eclipse.jdt.core.IMethod)2 ISourceRange (org.eclipse.jdt.core.ISourceRange)2 JavaModelException (org.eclipse.jdt.core.JavaModelException)2 MemberValuePairLocationRetriever (org.bndtools.builder.utils.MemberValuePairLocationRetriever)1 IMarker (org.eclipse.core.resources.IMarker)1 IAnnotatable (org.eclipse.jdt.core.IAnnotatable)1 IField (org.eclipse.jdt.core.IField)1 IJavaProject (org.eclipse.jdt.core.IJavaProject)1 ILocalVariable (org.eclipse.jdt.core.ILocalVariable)1 IMember (org.eclipse.jdt.core.IMember)1 IMemberValuePair (org.eclipse.jdt.core.IMemberValuePair)1 IPackageDeclaration (org.eclipse.jdt.core.IPackageDeclaration)1 IPackageFragment (org.eclipse.jdt.core.IPackageFragment)1 ITypeParameter (org.eclipse.jdt.core.ITypeParameter)1 ASTParser (org.eclipse.jdt.core.dom.ASTParser)1 CompilationUnit (org.eclipse.jdt.core.dom.CompilationUnit)1