Example usage for org.eclipse.jdt.core Flags isNative

List of usage examples for org.eclipse.jdt.core Flags isNative

Introduction

In this page you can find the example usage for org.eclipse.jdt.core Flags isNative.

Prototype

public static boolean isNative(int flags) 

Source Link

Document

Returns whether the given integer includes the native modifier.

Usage

From source file:at.bestsolution.fxide.jdt.corext.util.JdtFlags.java

License:Open Source License

public static boolean isNative(IMember member) throws JavaModelException {
    return Flags.isNative(member.getFlags());
}

From source file:com.codenvy.ide.ext.java.server.SourcesFromBytecodeGenerator.java

License:Open Source License

private String getModifiers(int flags, int typeFlags) {
    StringBuilder modifiers = new StringBuilder();
    //package private modifier has no string representation

    if (Flags.isPublic(flags)) {
        modifiers.append("public ");
    }/*from   w w  w .j a v a2  s .c  om*/

    if (Flags.isProtected(flags)) {
        modifiers.append("protected ");
    }

    if (Flags.isPrivate(flags)) {
        modifiers.append("private ");
    }

    if (Flags.isStatic(flags)) {
        modifiers.append("static ");
    }

    if (Flags.isAbstract(flags) && !Flags.isInterface(typeFlags)) {
        modifiers.append("abstract ");
    }

    if (Flags.isFinal(flags)) {
        modifiers.append("final ");
    }

    if (Flags.isNative(flags)) {
        modifiers.append("native ");
    }

    if (Flags.isSynchronized(flags)) {
        modifiers.append("synchronized ");
    }

    if (Flags.isVolatile(flags)) {
        modifiers.append("volatile ");
    }

    int len = modifiers.length();
    if (len == 0)
        return "";
    modifiers.setLength(len - 1);
    return modifiers.toString();
}

From source file:com.google.gwt.eclipse.core.editors.java.JsniMethodBodyCompletionProposalComputer.java

License:Open Source License

public List<ICompletionProposal> computeCompletionProposals(ContentAssistInvocationContext context,
        IProgressMonitor monitor) {//www  .j  ava2 s . c o m
    if (!(context instanceof JavaContentAssistInvocationContext)) {
        // Not in a java content assist content.
        return NO_PROPOSALS;
    }

    try {
        JavaContentAssistInvocationContext jcaic = (JavaContentAssistInvocationContext) context;
        ICompilationUnit compilationUnit = jcaic.getCompilationUnit();

        /*
         * Resolves issue 3560,
         * http://code.google.com/p/google-web-toolkit/issues/detail?id=3650. We
         * need to have a reconciled compilation unit if we are to use it, but we
         * don't want to tickle the hierarchy view bug.
         */
        compilationUnit.reconcile(ICompilationUnit.NO_AST, false, null, null);

        int invocationOffset = jcaic.getInvocationOffset();
        IJavaElement elementAt = compilationUnit.getElementAt(invocationOffset);

        if (elementAt == null) {
            // Can't determine the element at the specified offset.
            return NO_PROPOSALS;
        }

        if (IJavaElement.METHOD != elementAt.getElementType()) {
            // Not a method.
            return NO_PROPOSALS;
        }

        IMethod method = (IMethod) elementAt;

        IType thisType = method.getDeclaringType();
        if (thisType.isInterface()) {
            // Don't propose anything for interfaces.
            return NO_PROPOSALS;
        }

        ISourceRange sourceRange = method.getSourceRange();
        if (sourceRange == null) {
            // No source code.
            // TODO: Is this possible?
            return NO_PROPOSALS;
        }

        String methodSource = method.getSource();
        int invocationIdx = invocationOffset - sourceRange.getOffset();

        // Sometimes, if incomplete JSNI method has /* and is followed by any global 
        // comment of format /*..*/, compilation unit separates the code after
        // incomplete JSNI method's /* as a separate block from the incomplete method.
        // So we need to check whether the block before the invocation offset's block
        // is the incomplete JSNI method that we are interested in.

        IJavaElement prevElement = compilationUnit.getElementAt(sourceRange.getOffset() - 1);
        if (prevElement != null && IJavaElement.METHOD == prevElement.getElementType()) {

            IMethod prevMethod = (IMethod) prevElement;

            if ((prevMethod.getDeclaringType().isInterface() == false)
                    && (Flags.isNative(prevMethod.getFlags()) == true)) {

                String prevMethodSource = prevMethod.getSource();
                if (prevMethodSource.trim().endsWith(")") == true) {
                    methodSource = prevMethodSource.concat(methodSource);
                    method = prevMethod;
                    invocationIdx += prevMethodSource.length();
                }
            }
        }

        int flags = method.getFlags();
        if (!Flags.isNative(flags)) {
            // If the method is not native then no proposals.
            return NO_PROPOSALS;
        }

        // Eliminating comments that might precede native method declaration, so that
        // following code can safely assume first ')' found is that of function declaration.
        int idxMultiLineComment = methodSource.trim().indexOf("/*");
        int idxSingleLineComment = methodSource.trim().indexOf("//");
        while ((idxMultiLineComment == 0) || (idxSingleLineComment == 0)) {
            if (idxMultiLineComment == 0) {
                invocationIdx -= methodSource.indexOf("*/") + 2;
                methodSource = methodSource.substring(methodSource.indexOf("*/") + 2);
            } else {
                invocationIdx -= methodSource.indexOf('\n') + 1;
                methodSource = methodSource.substring(methodSource.indexOf('\n') + 1);
            }
            idxMultiLineComment = methodSource.trim().indexOf("/*");
            idxSingleLineComment = methodSource.trim().indexOf("//");
        }

        // Eliminating any JSNI method that might follow the JSNI method in consideration.
        int jsniMethodOpenIdx = methodSource.indexOf(JSNI_METHOD_OPEN_BRACE);
        if (jsniMethodOpenIdx != -1) {
            int jsniMethodCloseBracketIdx = methodSource.indexOf(")");
            String tempString = methodSource.substring(jsniMethodCloseBracketIdx, jsniMethodOpenIdx);
            if (tempString.trim().length() != 1) {
                methodSource = methodSource.substring(0, jsniMethodOpenIdx - 1);
            } else {
                int nextJsniMethodOpenIdx = methodSource.substring(jsniMethodOpenIdx + 4)
                        .indexOf(JSNI_METHOD_OPEN_BRACE);
                if (nextJsniMethodOpenIdx != -1) {
                    nextJsniMethodOpenIdx += jsniMethodOpenIdx + 4;
                    methodSource = methodSource.substring(0, nextJsniMethodOpenIdx - 1);
                }
            }
        }

        // Check if the JSNI method is already complete.
        if (methodSource.indexOf("}-*/;") != -1) {
            // JSNI method is complete.
            return NO_PROPOSALS;
        }

        // Check position of invocation offset.
        int numCharsFilled = 0, numCharsToOverwrite = 0;

        String tempString = "";
        if (methodSource.substring(methodSource.indexOf(")") + 1).trim().indexOf("/") != -1) {
            tempString = methodSource.substring(methodSource.indexOf(")"), methodSource.indexOf("/"));
        }

        if ((methodSource.substring(methodSource.indexOf(")") + 1).trim().indexOf("/") == 0)
                && (tempString.indexOf('\n') == -1)) {

            int jsniMethodOpenSlashIdx = methodSource.indexOf("/");

            if (jsniMethodOpenSlashIdx > invocationIdx) {
                // Invocation index is placed before JSNI open slash.
                return NO_PROPOSALS;
            }

            String jsniCompletedString = methodSource.substring(jsniMethodOpenSlashIdx, invocationIdx);

            if (jsniCompletedString.indexOf(JSNI_METHOD_OPEN_BRACE) != -1) {
                jsniCompletedString = jsniCompletedString.trim();
            }

            if (JSNI_METHOD_OPEN_BRACE.startsWith(jsniCompletedString)) {
                numCharsFilled = jsniCompletedString.length();
            } else {
                // Invocation index placement does not allow auto-completion.
                return NO_PROPOSALS;
            }
        } else {
            int jsniMethodCloseBracketIdx = methodSource.indexOf(")") + 1;

            if (jsniMethodCloseBracketIdx > invocationIdx) {
                // Invocation index is not placed after method's close bracket.
                return NO_PROPOSALS;
            }
            if (methodSource.substring(jsniMethodCloseBracketIdx, invocationIdx).trim().length() != 0) {
                // Do not auto-complete if there is anything other than space between the two indices.
                return NO_PROPOSALS;
            }
        }

        methodSource = methodSource.substring(invocationIdx);
        int endIdx = methodSource.length();
        if (methodSource.indexOf(" ") != -1) {
            endIdx = methodSource.indexOf(" ");
            if (methodSource.indexOf("\n") != -1 && (endIdx > methodSource.indexOf("\n"))) {
                endIdx = methodSource.indexOf("\n");
            }
        } else if (methodSource.indexOf("\n") != -1) {
            endIdx = methodSource.indexOf("\n");
        }

        numCharsToOverwrite = methodSource.substring(0, endIdx).trim().length();

        IDocument document = jcaic.getDocument();
        int lineOfInvocationOffset = document.getLineOfOffset(invocationOffset);
        int lineOffset = document.getLineOffset(lineOfInvocationOffset);

        IJavaProject project = jcaic.getProject();
        int indentationUnits = measureIndentationUnits(document, lineOfInvocationOffset, lineOffset, project);

        List<ICompletionProposal> proposals = new ArrayList<ICompletionProposal>();

        proposeEmptyJsniBlock(project, method, invocationOffset, indentationUnits, proposals, numCharsFilled,
                numCharsToOverwrite);

        boolean isStatic = Flags.isStatic(flags);
        if (method.getReturnType().equals(Signature.SIG_VOID)) {
            proposeSetters(project, method, invocationOffset, indentationUnits, isStatic, proposals,
                    numCharsFilled, numCharsToOverwrite);
        } else {
            proposeGetters(project, method, invocationOffset, indentationUnits, isStatic, proposals,
                    numCharsFilled, numCharsToOverwrite);
        }
        return proposals;
    } catch (JavaModelException e) {
        // Default to no proposals.
    } catch (BadLocationException e) {
        // Default to no proposals.
    }

    return NO_PROPOSALS;
}

From source file:com.redhat.ceylon.eclipse.code.explorer.JavaElementImageProvider.java

License:Open Source License

private int computeJavaAdornmentFlags(IJavaElement element, int renderFlags) {
    int flags = 0;
    if (showOverlayIcons(renderFlags)) {
        try {//  w  ww  . j ava  2s  .  c o  m
            if (element instanceof IMember) {
                IMember member = (IMember) element;

                int modifiers = member.getFlags();
                if (Flags.isAbstract(modifiers) && confirmAbstract(member))
                    flags |= JavaElementImageDescriptor.ABSTRACT;
                if (Flags.isFinal(modifiers) || isInterfaceOrAnnotationField(member)
                        || isEnumConstant(member, modifiers))
                    flags |= JavaElementImageDescriptor.FINAL;
                if (Flags.isStatic(modifiers) || isInterfaceOrAnnotationFieldOrType(member)
                        || isEnumConstant(member, modifiers))
                    flags |= JavaElementImageDescriptor.STATIC;

                if (Flags.isDeprecated(modifiers))
                    flags |= JavaElementImageDescriptor.DEPRECATED;

                int elementType = element.getElementType();
                if (elementType == IJavaElement.METHOD) {
                    if (((IMethod) element).isConstructor())
                        flags |= JavaElementImageDescriptor.CONSTRUCTOR;
                    if (Flags.isSynchronized(modifiers)) // collides with 'super' flag
                        flags |= JavaElementImageDescriptor.SYNCHRONIZED;
                    if (Flags.isNative(modifiers))
                        flags |= JavaElementImageDescriptor.NATIVE;
                }

                if (member.getElementType() == IJavaElement.TYPE) {
                    if (JavaModelUtil.hasMainMethod((IType) member)) {
                        flags |= JavaElementImageDescriptor.RUNNABLE;
                    }
                }

                if (member.getElementType() == IJavaElement.FIELD) {
                    if (Flags.isVolatile(modifiers))
                        flags |= JavaElementImageDescriptor.VOLATILE;
                    if (Flags.isTransient(modifiers))
                        flags |= JavaElementImageDescriptor.TRANSIENT;
                }
            } else if (element instanceof ILocalVariable
                    && Flags.isFinal(((ILocalVariable) element).getFlags())) {
                flags |= JavaElementImageDescriptor.FINAL;
            }
        } catch (JavaModelException e) {
            // do nothing. Can't compute runnable adornment or get flags
        }
    }
    return flags;
}

From source file:org.eclim.plugin.jdt.command.src.ClassPrototypeCommand.java

License:Open Source License

/**
 * Prototypes the given member's flags./*from  w w  w  .j  a va2  s . c o  m*/
 *
 * @param buffer The buffer to append to.
 * @param member The member instance.
 */
protected void prototypeFlags(StringBuffer buffer, IMember member) throws Exception {
    int flags = member.getFlags();

    if (Flags.isPublic(flags)) {
        buffer.append("public ");
    } else if (Flags.isProtected(flags)) {
        buffer.append("protected ");
    } else if (Flags.isPrivate(flags)) {
        buffer.append("private ");
    }

    if (Flags.isStatic(flags)) {
        buffer.append("static ");
    }
    if (Flags.isFinal(flags)) {
        buffer.append("final ");
    }
    if (Flags.isAbstract(flags)) {
        buffer.append("abstract ");
    }
    if (Flags.isNative(flags)) {
        buffer.append("native ");
    }
    if (Flags.isTransient(flags)) {
        buffer.append("transient ");
    }
    if (Flags.isVolatile(flags)) {
        buffer.append("volatile ");
    }
    if (Flags.isSynchronized(flags)) {
        buffer.append("synchronized ");
    }
}

From source file:org.eclipse.jem.internal.adapters.jdom.JavaMethodJDOMAdaptor.java

License:Open Source License

/**
 * setModifiers - set the attribute values related to modifiers here
 *//*  w  w  w .ja v  a 2  s . c o m*/
protected void setModifiers() {
    Method methodTarget = (Method) getTarget();
    try {
        methodTarget.setFinal(Flags.isFinal(getSourceMethod().getFlags()));
        methodTarget.setNative(Flags.isNative(getSourceMethod().getFlags()));
        methodTarget.setStatic(Flags.isStatic(getSourceMethod().getFlags()));
        methodTarget.setSynchronized(Flags.isSynchronized(getSourceMethod().getFlags()));
        methodTarget.setConstructor(getSourceMethod().isConstructor());

        JavaClass javaClass = getContainingJavaClass();
        //Set abstract
        if (javaClass.getKind().getValue() == TypeKind.INTERFACE)
            methodTarget.setAbstract(true);
        else
            methodTarget.setAbstract(Flags.isAbstract(getSourceMethod().getFlags()));
        // Set visibility
        if (javaClass.getKind().getValue() == TypeKind.INTERFACE
                || Flags.isPublic(getSourceMethod().getFlags()))
            methodTarget.setJavaVisibility(JavaVisibilityKind.PUBLIC_LITERAL);
        else if (Flags.isPrivate(getSourceMethod().getFlags()))
            methodTarget.setJavaVisibility(JavaVisibilityKind.PRIVATE_LITERAL);
        else if (Flags.isProtected(getSourceMethod().getFlags()))
            methodTarget.setJavaVisibility(JavaVisibilityKind.PROTECTED_LITERAL);
        else
            //Visibility must be package
            methodTarget.setJavaVisibility(JavaVisibilityKind.PACKAGE_LITERAL);
    } catch (JavaModelException npe) {
        System.out.println(ResourceHandler.getString("Error_Introspecting_Flags_ERROR_", (new Object[] { //$NON-NLS-1$
                ((XMIResource) methodTarget.eResource()).getID(methodTarget), npe.getMessage() }))); //= "error introspecting flags on {0}, exception: {1}"
    }
}

From source file:org.eclipse.modisco.java.discoverer.internal.io.library.ClassFileParser.java

License:Open Source License

/**
 * Complete the MoDisco modifier with the informations of the flags.
 * //from w  w w. ja v  a 2  s.  c  om
 * @param flags
 *            the flags
 * @param modiscoModifier
 *            the MoDisco Modifier
 * @see Flags
 */
private static void manageModifier(final Modifier modiscoModifier, final int flags,
        final IJavaElement element) {
    int kind = element.getElementType();
    // static is applicable on types, methods, fields, and initializers.
    if (!modiscoModifier.isStatic()) {
        if (kind == IJavaElement.TYPE || kind == IJavaElement.METHOD || kind == IJavaElement.FIELD) {
            modiscoModifier.setStatic(Flags.isStatic(flags));
        }
    }
    // native is applicable to methods
    if (!modiscoModifier.isNative()) {
        if (kind == IJavaElement.METHOD) {
            modiscoModifier.setNative(Flags.isNative(flags));
        }
    }
    // strictfp is applicable to types and methods
    if (!modiscoModifier.isStrictfp()) {
        if (kind == IJavaElement.TYPE || kind == IJavaElement.METHOD) {
            modiscoModifier.setStrictfp(Flags.isStrictfp(flags));
        }
    }
    // synchronized is applicable only to methods
    if (!modiscoModifier.isSynchronized()) {
        if (kind == IJavaElement.METHOD) {
            modiscoModifier.setSynchronized(Flags.isSynchronized(flags));
        }
    }
    // transient is applicable only to fields
    if (!modiscoModifier.isTransient()) {
        if (kind == IJavaElement.FIELD) {
            modiscoModifier.setTransient(Flags.isTransient(flags));
        }
    }
    // volatile is applicable only to fields
    if (!modiscoModifier.isVolatile()) {
        if (kind == IJavaElement.FIELD) {
            modiscoModifier.setVolatile(Flags.isVolatile(flags));
        }
    }

    // visibility modifiers are applicable to types, methods, constructors,
    // and fields.
    if (kind == IJavaElement.TYPE || kind == IJavaElement.METHOD || kind == IJavaElement.FIELD) {
        if (Flags.isPrivate(flags)) {
            modiscoModifier.setVisibility(VisibilityKind.PRIVATE);
        } else if (Flags.isProtected(flags)) {
            modiscoModifier.setVisibility(VisibilityKind.PROTECTED);
        } else if (Flags.isPublic(flags)) {
            modiscoModifier.setVisibility(VisibilityKind.PUBLIC);
        }
    }

    // abstract is applicable to types and methods
    // final is applicable to types, methods and variables
    if (kind == IJavaElement.TYPE || kind == IJavaElement.METHOD) {
        if (Flags.isAbstract(flags)) {
            modiscoModifier.setInheritance(InheritanceKind.ABSTRACT);
        } else if (Flags.isFinal(flags)) {
            modiscoModifier.setInheritance(InheritanceKind.FINAL);
        }
    }
}

From source file:org.eclipse.pde.api.tools.internal.comparator.ClassFileComparator.java

License:Open Source License

private void getDeltaForMethod(IApiMethod method) {
    int access = method.getModifiers();
    if (Flags.isSynthetic(access)) {
        // we ignore synthetic methods
        return;/*from  w w  w.j  a v a2  s. co  m*/
    }
    String name = method.getName();
    String descriptor = method.getSignature();
    String key = getKeyForMethod(method, this.type1);
    IApiMethod method2 = this.type2.getMethod(name, descriptor);
    String methodDisplayName = getMethodDisplayName(method, this.type1);
    if (method2 == null) {
        if (method.isClassInitializer()) {
            // report delta: removal of a clinit method
            this.addDelta(getElementType(this.type1), IDelta.REMOVED, IDelta.CLINIT,
                    this.currentDescriptorRestrictions, access, 0, this.type1, this.type1.getName(),
                    Util.getDescriptorName(type1));
            return;
        } else if (Flags.isPrivate(access) || Util.isDefault(access)) {
            this.addDelta(getElementType(this.type1), IDelta.REMOVED, getTargetType(method),
                    Flags.isAbstract(this.type2.getModifiers())
                            ? this.currentDescriptorRestrictions | RestrictionModifiers.NO_INSTANTIATE
                            : this.currentDescriptorRestrictions,
                    access, 0, this.type1, getKeyForMethod(method, this.type1),
                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
            return;
        }
        // if null we need to walk the hierarchy of descriptor2
        boolean found = false;
        if (this.component2 != null && !method.isConstructor()) {
            if (this.type1.isInterface()) {
                Set<?> interfacesSet = getInterfacesSet(this.type2);
                if (interfacesSet != null && isStatusOk()) {
                    for (Iterator<?> iterator = interfacesSet.iterator(); iterator.hasNext();) {
                        IApiType superTypeDescriptor = (IApiType) iterator.next();
                        IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor);
                        if (method3 == null) {
                            continue;
                        } else {
                            // interface method can only be public
                            // method has been move up in the hierarchy -
                            // report the delta and abort loop
                            this.addDelta(getElementType(this.type1), IDelta.REMOVED, IDelta.METHOD_MOVED_UP,
                                    this.currentDescriptorRestrictions, access, method3.getModifiers(),
                                    this.type1, getKeyForMethod(method3, this.type1),
                                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
                            found = true;
                            break;
                        }
                    }
                }
            } else {
                List<?> superclassList = getSuperclassList(this.type2, true);
                if (superclassList != null && isStatusOk()) {
                    loop: for (Iterator<?> iterator = superclassList.iterator(); iterator.hasNext();) {
                        IApiType superTypeDescriptor = (IApiType) iterator.next();
                        IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor);
                        if (method3 == null) {
                            continue;
                        } else {
                            int access3 = method3.getModifiers();
                            if (Flags.isPublic(access3) || Flags.isProtected(access3)) {
                                // method has been move up in the hierarchy
                                // - report the delta and abort loop
                                // TODO need to make the distinction between
                                // methods that need to be re-implemented
                                // and methods that don't
                                this.addDelta(getElementType(this.type1), IDelta.REMOVED,
                                        IDelta.METHOD_MOVED_UP, this.currentDescriptorRestrictions, access,
                                        access3, this.type1, getKeyForMethod(method3, this.type1),
                                        new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
                                found = true;
                                break loop;
                            }
                        }
                    }
                }
            }
        }
        if (!found) {
            if ((this.visibilityModifiers == VisibilityModifiers.API) && component.hasApiDescription()) {
                // check if this method should be removed because it is
                // tagged as @noreference
                IApiDescription apiDescription = null;
                try {
                    apiDescription = this.component.getApiDescription();
                } catch (CoreException e) {
                    reportStatus(e);
                }
                if (apiDescription != null) {
                    IApiAnnotations apiAnnotations = apiDescription.resolveAnnotations(method.getHandle());
                    if (apiAnnotations != null) {
                        int restrictions = apiAnnotations.getRestrictions();
                        if (RestrictionModifiers.isReferenceRestriction(restrictions)) {
                            // if not found, but tagged as @noreference in
                            // reference we don't need to report
                            // a removed method
                            return;
                        }
                    }
                }
            }
            if (this.type1.isAnnotation()) {
                this.addDelta(getElementType(this.type1), IDelta.REMOVED,
                        method.getDefaultValue() != null ? IDelta.METHOD_WITH_DEFAULT_VALUE
                                : IDelta.METHOD_WITHOUT_DEFAULT_VALUE,
                        this.currentDescriptorRestrictions, access, 0, this.type1,
                        getKeyForMethod(method, this.type1),
                        new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
            } else {
                int restrictions = this.currentDescriptorRestrictions;
                if (RestrictionModifiers.isExtendRestriction(this.initialDescriptorRestrictions)
                        && !RestrictionModifiers.isExtendRestriction(this.currentDescriptorRestrictions)) {
                    restrictions = this.initialDescriptorRestrictions;
                }
                this.addDelta(getElementType(this.type1), IDelta.REMOVED, getTargetType(method),
                        Flags.isAbstract(this.type2.getModifiers())
                                ? restrictions | RestrictionModifiers.NO_INSTANTIATE
                                : restrictions,
                        access, 0, this.type1, getKeyForMethod(method, this.type1),
                        new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
            }
        }
        return;
    }
    int restrictions = this.currentDescriptorRestrictions;
    if (component2.hasApiDescription()) {
        try {
            IApiDescription apiDescription = this.component2.getApiDescription();
            IApiAnnotations resolvedAPIDescription = apiDescription.resolveAnnotations(method2.getHandle());
            if (resolvedAPIDescription != null) {
                restrictions |= resolvedAPIDescription.getRestrictions();
            }
        } catch (CoreException e) {
            // ignore
        }
    }
    int referenceRestrictions = this.initialDescriptorRestrictions;
    int access2 = method2.getModifiers();
    if (this.component.hasApiDescription()) {
        // check if this method should be removed because it is tagged as
        // @noreference
        IApiDescription apiDescription = null;
        try {
            apiDescription = this.component.getApiDescription();
        } catch (CoreException e) {
            reportStatus(e);
        }
        if (apiDescription != null) {
            IApiAnnotations apiAnnotations = apiDescription.resolveAnnotations(method.getHandle());
            if (apiAnnotations != null) {
                referenceRestrictions |= apiAnnotations.getRestrictions();
            }
        }
    }
    if ((this.visibilityModifiers == VisibilityModifiers.API) && this.component.hasApiDescription()) {
        if (RestrictionModifiers.isReferenceRestriction(referenceRestrictions)) {
            // tagged as @noreference in the reference component
            if (!RestrictionModifiers.isReferenceRestriction(restrictions)) {
                // no longer tagged as @noreference
                // report a method addition
                if (method.isConstructor()) {
                    this.addDelta(getElementType(this.type2), IDelta.ADDED, IDelta.CONSTRUCTOR,
                            this.currentDescriptorRestrictions, access, access2, this.type1,
                            getKeyForMethod(method, this.type2),
                            new String[] { Util.getDescriptorName(this.type2), methodDisplayName });
                } else if (this.type2.isAnnotation()) {
                    if (method.getDefaultValue() != null) {
                        this.addDelta(getElementType(this.type2), IDelta.ADDED,
                                IDelta.METHOD_WITH_DEFAULT_VALUE, this.currentDescriptorRestrictions, access,
                                access2, this.type1, getKeyForMethod(method, this.type2),
                                new String[] { Util.getDescriptorName(this.type2), methodDisplayName });
                    } else {
                        this.addDelta(getElementType(this.type2), IDelta.ADDED,
                                IDelta.METHOD_WITHOUT_DEFAULT_VALUE, this.currentDescriptorRestrictions, access,
                                access2, this.type1, getKeyForMethod(method, this.type2),
                                new String[] { Util.getDescriptorName(this.type2), methodDisplayName });
                    }
                } else {
                    // check superclass
                    // if null we need to walk the hierarchy of descriptor2
                    boolean found = false;
                    if (this.component2 != null) {
                        if (this.type1.isInterface()) {
                            Set<?> interfacesSet = getInterfacesSet(this.type2);
                            if (interfacesSet != null && isStatusOk()) {
                                for (Iterator<?> iterator = interfacesSet.iterator(); iterator.hasNext();) {
                                    IApiType superTypeDescriptor = (IApiType) iterator.next();
                                    IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor);
                                    if (method3 == null) {
                                        continue;
                                    } else {
                                        // interface method can only be
                                        // public
                                        // method has been move up in the
                                        // hierarchy - report the delta and
                                        // abort loop
                                        found = true;
                                        break;
                                    }
                                }
                            }
                        } else {
                            List<IApiType> superclassList = getSuperclassList(this.type2, true);
                            if (superclassList != null) {
                                loop: for (Iterator<IApiType> iterator = superclassList.iterator(); iterator
                                        .hasNext();) {
                                    IApiType superTypeDescriptor = iterator.next();
                                    IApiMethod method3 = superTypeDescriptor.getMethod(name, descriptor);
                                    if (method3 == null) {
                                        continue;
                                    } else {
                                        int access3 = method3.getModifiers();
                                        if (Flags.isPublic(access3) || Flags.isProtected(access3)) {
                                            // method has been move up in
                                            // the hierarchy - report the
                                            // delta and abort loop
                                            // TODO need to make the
                                            // distinction between methods
                                            // that need to be
                                            // re-implemented and methods
                                            // that don't
                                            found = true;
                                            break loop;
                                        }
                                    }
                                }
                            }
                        }
                    }
                    this.addDelta(getElementType(this.type2), IDelta.ADDED,
                            found ? IDelta.OVERRIDEN_METHOD : IDelta.METHOD, this.currentDescriptorRestrictions,
                            access, access2, this.type1, getKeyForMethod(method, this.type2),
                            new String[] { Util.getDescriptorName(this.type2), methodDisplayName });
                }
                return;
            }
        } else if (RestrictionModifiers.isReferenceRestriction(restrictions)) {
            if (Flags.isPublic(access2) || Flags.isProtected(access2)) {
                // report that it is no longer an API method
                if (this.type2.isAnnotation()) {
                    this.addDelta(getElementType(this.type2), IDelta.REMOVED,
                            method.getDefaultValue() != null ? IDelta.API_METHOD_WITH_DEFAULT_VALUE
                                    : IDelta.API_METHOD_WITHOUT_DEFAULT_VALUE,
                            this.currentDescriptorRestrictions, access, access2, this.type1,
                            getKeyForMethod(method2, this.type2),
                            new String[] { Util.getDescriptorName(this.type2), methodDisplayName });
                } else if (Flags.isPublic(access) || Flags.isProtected(access)) {
                    this.addDelta(getElementType(this.type2), IDelta.REMOVED,
                            method.isConstructor() ? IDelta.API_CONSTRUCTOR : IDelta.API_METHOD,
                            Flags.isAbstract(this.type2.getModifiers())
                                    ? this.currentDescriptorRestrictions | RestrictionModifiers.NO_INSTANTIATE
                                    : this.currentDescriptorRestrictions,
                            access, access2, this.type1, getKeyForMethod(method2, this.type2),
                            new String[] { Util.getDescriptorName(this.type2), methodDisplayName });
                }
                return;
            }
        }
    }
    if (this.component.hasApiDescription() && !method.isConstructor() && !method.isClassInitializer()
            && !(type1.isInterface() || type1.isAnnotation())) {
        if (restrictions != referenceRestrictions) {
            if (!Flags.isFinal(access2)) {
                if (RestrictionModifiers.isOverrideRestriction(restrictions)
                        && !RestrictionModifiers.isOverrideRestriction(referenceRestrictions)) {
                    this.addDelta(getElementType(method), IDelta.ADDED, IDelta.RESTRICTIONS, restrictions,
                            referenceRestrictions, access, access2, this.type1,
                            getKeyForMethod(method2, this.type2),
                            new String[] { Util.getDescriptorName(this.type2), methodDisplayName });
                }
            }
        }
    }
    String[] names1 = method.getExceptionNames();
    List<String> list1 = null;
    if (names1 != null) {
        list1 = new ArrayList<String>(names1.length);
        for (int i = 0; i < names1.length; i++) {
            list1.add(names1[i]);
        }
    }
    String[] names2 = method2.getExceptionNames();
    List<String> list2 = null;
    if (names2 != null) {
        list2 = new ArrayList<String>(names2.length);
        for (int i = 0; i < names2.length; i++) {
            list2.add(names2[i]);
        }
    }
    if (names1 != null) {
        if (names2 == null) {
            // check all exception in method descriptor to see if they are
            // checked or unchecked exceptions
            loop: for (Iterator<String> iterator = list1.iterator(); iterator.hasNext();) {
                String exceptionName = iterator.next().replace('/', '.');
                if (isCheckedException(this.apiBaseline1, this.component, exceptionName)) {
                    // report delta - removal of checked exception
                    // TODO should we continue the loop for all remaining
                    // exceptions
                    this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.CHECKED_EXCEPTION,
                            restrictions, access, access2, this.type1, key, new String[] {
                                    Util.getDescriptorName(this.type1), methodDisplayName, exceptionName });
                    break loop;
                } else {
                    // report delta - removal of unchecked exception
                    this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.UNCHECKED_EXCEPTION,
                            restrictions, access, access2, this.type1, key, new String[] {
                                    Util.getDescriptorName(this.type1), methodDisplayName, exceptionName });
                }
            }
        } else {
            // check if the exceptions are consistent for both descriptors
            List<String> removedExceptions = new ArrayList<String>();
            for (Iterator<String> iterator = list1.iterator(); iterator.hasNext();) {
                String exceptionName = iterator.next().replace('/', '.');
                if (!list2.remove(exceptionName)) {
                    // this means that the exceptionName was not found
                    // inside the new set of exceptions
                    // so it has been removed
                    removedExceptions.add(exceptionName);
                }
            }
            if (removedExceptions.size() != 0) {
                loop: for (Iterator<String> iterator = removedExceptions.iterator(); iterator.hasNext();) {
                    String exceptionName = iterator.next().replace('/', '.');
                    if (isCheckedException(this.apiBaseline1, this.component, exceptionName)) {
                        // report delta - removal of checked exception
                        // TODO should we continue the loop for all
                        // remaining exceptions
                        this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.CHECKED_EXCEPTION,
                                restrictions, access, access2, this.type1, key, new String[] {
                                        Util.getDescriptorName(this.type1), methodDisplayName, exceptionName });
                        break loop;
                    } else {
                        // report delta - removal of unchecked exception
                        this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.UNCHECKED_EXCEPTION,
                                restrictions, access, access2, this.type1, key, new String[] {
                                        Util.getDescriptorName(this.type1), methodDisplayName, exceptionName });
                    }
                }
            }
            loop: for (Iterator<String> iterator = list2.iterator(); iterator.hasNext();) {
                String exceptionName = iterator.next().replace('/', '.');
                if (isCheckedException(this.apiBaseline2, this.component2, exceptionName)) {
                    // report delta - addition of checked exception
                    // TODO should we continue the loop for all remaining
                    // exceptions
                    this.addDelta(getElementType(method), IDelta.ADDED, IDelta.CHECKED_EXCEPTION, restrictions,
                            access, access2, this.type1, key, new String[] { Util.getDescriptorName(this.type1),
                                    methodDisplayName, exceptionName });
                    break loop;
                } else {
                    // report delta - addition of unchecked exception
                    this.addDelta(getElementType(method), IDelta.ADDED, IDelta.UNCHECKED_EXCEPTION,
                            restrictions, access, access2, this.type1, key, new String[] {
                                    Util.getDescriptorName(this.type1), methodDisplayName, exceptionName });
                }
            }
        }
    } else if (names2 != null) {
        // check all exception in method descriptor to see if they are
        // checked or unchecked exceptions
        loop: for (Iterator<String> iterator = list2.iterator(); iterator.hasNext();) {
            String exceptionName = iterator.next().replace('/', '.');
            if (isCheckedException(this.apiBaseline2, this.component2, exceptionName)) {
                // report delta - addition of checked exception
                this.addDelta(getElementType(method), IDelta.ADDED, IDelta.CHECKED_EXCEPTION, restrictions,
                        access, access2, this.type1, key,
                        new String[] { Util.getDescriptorName(this.type1), methodDisplayName, exceptionName });
                // TODO should we continue the loop for all remaining
                // exceptions
                break loop;
            } else {
                // report delta - addition of unchecked exception
                this.addDelta(getElementType(method), IDelta.ADDED, IDelta.UNCHECKED_EXCEPTION, restrictions,
                        access, access2, this.type1, key,
                        new String[] { Util.getDescriptorName(this.type1), methodDisplayName, exceptionName });
            }
        }
    }
    if (Flags.isVarargs(access)) {
        if (!Flags.isVarargs(access2)) {
            // report delta: conversion from T... to T[] - break
            // compatibility
            this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.VARARGS_TO_ARRAY, restrictions, access,
                    access2, this.type1, key,
                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
        }
    } else if (Flags.isVarargs(access2)) {
        // report delta: conversion from T[] to T... compatible
        this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.ARRAY_TO_VARARGS, restrictions, access,
                access2, this.type1, key,
                new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
    }
    if (Flags.isProtected(access)) {
        if (Flags.isPrivate(access2) || Util.isDefault(access2)) {
            // report delta - decrease access: protected to default or
            // private
            this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.DECREASE_ACCESS, restrictions, access,
                    access2, this.type1, key,
                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
        } else if (Flags.isPublic(access2)) {
            // report delta - increase access: protected to public
            this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.INCREASE_ACCESS, restrictions, access,
                    access2, this.type1, key,
                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
        }
    } else if (Flags.isPublic(access)
            && (Flags.isProtected(access2) || Flags.isPrivate(access2) || Util.isDefault(access2))) {
        // report delta - decrease access: public to protected, default or
        // private
        this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.DECREASE_ACCESS, restrictions, access,
                access2, this.type1, key,
                new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
    } else if (Util.isDefault(access) && (Flags.isPublic(access2) || Flags.isProtected(access2))) {
        this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.INCREASE_ACCESS, restrictions, access,
                access2, this.type1, key,
                new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
    } else if (Flags.isPrivate(access)
            && (Util.isDefault(access2) || Flags.isPublic(access2) || Flags.isProtected(access2))) {
        this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.INCREASE_ACCESS, restrictions, access,
                access2, this.type1, key,
                new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
    }
    if (Flags.isAbstract(access)) {
        if (!Flags.isAbstract(access2)) {
            // report delta - changed from abstract to non-abstract
            this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.ABSTRACT_TO_NON_ABSTRACT, restrictions,
                    access, access2, this.type1, key,
                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
        }
    } else if (Flags.isAbstract(access2)) {
        // report delta - changed from non-abstract to abstract
        this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.NON_ABSTRACT_TO_ABSTRACT, restrictions,
                access, access2, this.type1, key,
                new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
    }
    if (Flags.isFinal(access)) {
        if (!Flags.isFinal(access2)) {
            // report delta - changed from final to non-final
            this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.FINAL_TO_NON_FINAL, restrictions,
                    access, access2, this.type1, key,
                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
        }
    } else if (Flags.isFinal(access2)) {
        int res = restrictions;
        if (!RestrictionModifiers.isOverrideRestriction(res)) {
            if (RestrictionModifiers.isExtendRestriction(this.currentDescriptorRestrictions)) {
                res = this.currentDescriptorRestrictions;
            } else if (RestrictionModifiers.isExtendRestriction(this.initialDescriptorRestrictions)) {
                res = this.initialDescriptorRestrictions;
            }
            if (RestrictionModifiers.isOverrideRestriction(referenceRestrictions)) {
                // it is ok to remove @nooverride and add final at the same
                // time
                res = referenceRestrictions;
            }
        }
        // only report this delta is the method was visible
        this.addDelta(getElementType(method2), IDelta.CHANGED, IDelta.NON_FINAL_TO_FINAL, res, access, access2,
                this.type1, key,
                new String[] { Util.getDescriptorName(this.type2), getMethodDisplayName(method2, this.type2) });
    }
    if (Flags.isStatic(access)) {
        if (!Flags.isStatic(access2)) {
            // report delta: change from static to non-static
            this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.STATIC_TO_NON_STATIC, restrictions,
                    access, access2, this.type1, key,
                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
        }
    } else if (Flags.isStatic(access2)) {
        // report delta: change from non-static to static
        this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.NON_STATIC_TO_STATIC, restrictions, access,
                access2, this.type1, key,
                new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
    }
    if (Flags.isNative(access)) {
        if (!Flags.isNative(access2)) {
            // report delta: change from native to non-native
            this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.NATIVE_TO_NON_NATIVE, restrictions,
                    access, access2, this.type1, key,
                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
        }
    } else if (Flags.isNative(access2)) {
        // report delta: change from non-native to native
        this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.NON_NATIVE_TO_NATIVE, restrictions, access,
                access2, this.type1, key,
                new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
    }
    if (Flags.isSynchronized(access)) {
        if (!Flags.isSynchronized(access2)) {
            // report delta: change from synchronized to non-synchronized
            this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.SYNCHRONIZED_TO_NON_SYNCHRONIZED,
                    restrictions, access, access2, this.type1, key,
                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
        }
    } else if (Flags.isSynchronized(access2)) {
        // report delta: change from non-synchronized to synchronized
        this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.NON_SYNCHRONIZED_TO_SYNCHRONIZED,
                restrictions, access, access2, this.type1, key,
                new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
    }
    if (Flags.isDeprecated(access)) {
        if (!Flags.isDeprecated(access2)) {
            this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.DEPRECATION, restrictions, access,
                    access2, this.type1, key,
                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
        }
    } else if (Flags.isDeprecated(access2)) {
        // report delta - non-volatile to volatile
        this.addDelta(getElementType(method), IDelta.ADDED, IDelta.DEPRECATION, restrictions, access, access2,
                this.type1, key, new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
    }
    // check type parameters
    String signature1 = method.getGenericSignature();
    String signature2 = method2.getGenericSignature();
    checkGenericSignature(signature1, signature2, method, method2);

    if (method.getDefaultValue() == null) {
        if (method2.getDefaultValue() != null) {
            // report delta : default value has been added - compatible
            this.addDelta(getElementType(method), IDelta.ADDED, IDelta.ANNOTATION_DEFAULT_VALUE, restrictions,
                    access, access2, this.type1, key,
                    new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
        }
    } else if (method2.getDefaultValue() == null) {
        // report delta : default value has been removed - incompatible
        this.addDelta(getElementType(method), IDelta.REMOVED, IDelta.ANNOTATION_DEFAULT_VALUE, restrictions,
                access, access2, this.type1, key,
                new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
    } else if (!method.getDefaultValue().equals(method2.getDefaultValue())) {
        // report delta: default value has changed
        this.addDelta(getElementType(method), IDelta.CHANGED, IDelta.ANNOTATION_DEFAULT_VALUE, restrictions,
                access, access2, this.type1, key,
                new String[] { Util.getDescriptorName(this.type1), methodDisplayName });
    }
}