Example usage for org.eclipse.jdt.core IJavaElement METHOD

List of usage examples for org.eclipse.jdt.core IJavaElement METHOD

Introduction

In this page you can find the example usage for org.eclipse.jdt.core IJavaElement METHOD.

Prototype

int METHOD

To view the source code for org.eclipse.jdt.core IJavaElement METHOD.

Click Source Link

Document

Constant representing a method or constructor.

Usage

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

License:Open Source License

/**
 * Evaluates if a member in the focus' element hierarchy is visible from
 * elements in a package./*from   w  w w. j ava  2  s  .c  o  m*/
 * @param member The member to test the visibility for
 * @param pack The package of the focus element focus
 * @return returns <code>true</code> if the member is visible from the package
 * @throws JavaModelException thrown when the member can not be accessed
 */
public static boolean isVisibleInHierarchy(IMember member, IPackageFragment pack) throws JavaModelException {
    int type = member.getElementType();
    if (type == IJavaElement.INITIALIZER
            || (type == IJavaElement.METHOD && member.getElementName().startsWith("<"))) { //$NON-NLS-1$
        return false;
    }

    int otherflags = member.getFlags();

    IType declaringType = member.getDeclaringType();
    if (Flags.isPublic(otherflags) || Flags.isProtected(otherflags)
            || (declaringType != null && isInterfaceOrAnnotation(declaringType))) {
        return true;
    } else if (Flags.isPrivate(otherflags)) {
        return false;
    }

    IPackageFragment otherpack = (IPackageFragment) member.getAncestor(IJavaElement.PACKAGE_FRAGMENT);
    return (pack != null && pack.equals(otherpack));
}

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

License:Open Source License

public static boolean isStatic(IMember member) throws JavaModelException {
    if (isNestedInterfaceOrAnnotation(member))
        return true;
    if (member.getElementType() != IJavaElement.METHOD && isInterfaceOrAnnotationMember(member))
        return true;
    if (isEnum(member) && (member.getElementType() == IJavaElement.FIELD || member.getDeclaringType() != null))
        return true;
    return Flags.isStatic(member.getFlags());
}

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

License:Open Source License

private static boolean isInterfaceOrAnnotationMethod(IMember member) throws JavaModelException {
    return member.getElementType() == IJavaElement.METHOD && isInterfaceOrAnnotationMember(member);
}

From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess.java

License:Open Source License

/**
 * Gets a reader for an IMember's Javadoc comment content from the source attachment.
 * The content does contain only the text from the comment without the Javadoc leading star characters.
 * Returns <code>null</code> if the member does not contain a Javadoc comment or if no source is available.
 * @param member The member to get the Javadoc of.
 * @param allowInherited For methods with no (Javadoc) comment, the comment of the overridden class
 * is returned if <code>allowInherited</code> is <code>true</code>.
 * @return Returns a reader for the Javadoc comment content or <code>null</code> if the member
 * does not contain a Javadoc comment or if no source is available
 * @throws JavaModelException is thrown when the elements javadoc can not be accessed
 *//*w  w  w  . ja v  a2 s  . c o  m*/
public static Reader getContentReader(IMember member, boolean allowInherited) throws JavaModelException {
    Reader contentReader = internalGetContentReader(member);
    if (contentReader != null || !(allowInherited && (member.getElementType() == IJavaElement.METHOD)))
        return contentReader;
    return findDocInHierarchy((IMethod) member, false, false);
}

From source file:at.bestsolution.fxide.jdt.text.javadoc.JavadocContentAccess.java

License:Open Source License

/**
 * Gets a reader for an IMember's Javadoc comment content from the source attachment.
 * and renders the tags in HTML./*from   w  w  w  .j a v a2 s.c om*/
 * Returns <code>null</code> if the member does not contain a Javadoc comment or if no source is available.
 *
 * @param member            the member to get the Javadoc of.
 * @param allowInherited      for methods with no (Javadoc) comment, the comment of the overridden
 *                            class is returned if <code>allowInherited</code> is <code>true</code>
 * @param useAttachedJavadoc   if <code>true</code> Javadoc will be extracted from attached Javadoc
 *                            if there's no source
 * @return a reader for the Javadoc comment content in HTML or <code>null</code> if the member
 *          does not contain a Javadoc comment or if no source is available
 * @throws JavaModelException is thrown when the elements Javadoc can not be accessed
 * @since 3.2
 */
public static Reader getHTMLContentReader(IMember member, boolean allowInherited, boolean useAttachedJavadoc)
        throws JavaModelException {
    Reader contentReader = internalGetContentReader(member);
    if (contentReader != null)
        return new JavaDoc2HTMLTextReader(contentReader);

    if (useAttachedJavadoc && member.getOpenable().getBuffer() == null) { // only if no source available
        String s = member.getAttachedJavadoc(null);
        if (s != null)
            return new StringReader(s);
    }

    if (allowInherited && (member.getElementType() == IJavaElement.METHOD))
        return findDocInHierarchy((IMethod) member, true, useAttachedJavadoc);

    return null;
}

From source file:at.bestsolution.fxide.jdt.text.viewersupport.JavaElementLabelComposer.java

License:Open Source License

/**
 * Appends the label for a Java element with the flags as defined by this class.
 *
 * @param element the element to render// ww w . j  a  v  a 2 s .c om
 * @param flags the rendering flags.
 */
public void appendElementLabel(IJavaElement element, long flags) {
    int type = element.getElementType();
    IPackageFragmentRoot root = null;

    if (type != IJavaElement.JAVA_MODEL && type != IJavaElement.JAVA_PROJECT
            && type != IJavaElement.PACKAGE_FRAGMENT_ROOT)
        root = JavaModelUtil.getPackageFragmentRoot(element);
    if (root != null && getFlag(flags, JavaElementLabels.PREPEND_ROOT_PATH)) {
        appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED);
        fBuffer.append(JavaElementLabels.CONCAT_STRING);
    }

    switch (type) {
    case IJavaElement.METHOD:
        appendMethodLabel((IMethod) element, flags);
        break;
    case IJavaElement.FIELD:
        appendFieldLabel((IField) element, flags);
        break;
    case IJavaElement.LOCAL_VARIABLE:
        appendLocalVariableLabel((ILocalVariable) element, flags);
        break;
    case IJavaElement.TYPE_PARAMETER:
        appendTypeParameterLabel((ITypeParameter) element, flags);
        break;
    case IJavaElement.INITIALIZER:
        appendInitializerLabel((IInitializer) element, flags);
        break;
    case IJavaElement.TYPE:
        appendTypeLabel((IType) element, flags);
        break;
    case IJavaElement.CLASS_FILE:
        appendClassFileLabel((IClassFile) element, flags);
        break;
    case IJavaElement.COMPILATION_UNIT:
        appendCompilationUnitLabel((ICompilationUnit) element, flags);
        break;
    case IJavaElement.PACKAGE_FRAGMENT:
        appendPackageFragmentLabel((IPackageFragment) element, flags);
        break;
    case IJavaElement.PACKAGE_FRAGMENT_ROOT:
        appendPackageFragmentRootLabel((IPackageFragmentRoot) element, flags);
        break;
    case IJavaElement.IMPORT_CONTAINER:
    case IJavaElement.IMPORT_DECLARATION:
    case IJavaElement.PACKAGE_DECLARATION:
        appendDeclarationLabel(element, flags);
        break;
    case IJavaElement.JAVA_PROJECT:
    case IJavaElement.JAVA_MODEL:
        fBuffer.append(element.getElementName());
        break;
    default:
        fBuffer.append(element.getElementName());
    }

    if (root != null && getFlag(flags, JavaElementLabels.APPEND_ROOT_PATH)) {
        int offset = fBuffer.length();
        fBuffer.append(JavaElementLabels.CONCAT_STRING);
        appendPackageFragmentRootLabel(root, JavaElementLabels.ROOT_QUALIFIED);

        //         if (getFlag(flags, JavaElementLabels.COLORIZE)) {
        //            fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
        //         }

    }
}

From source file:at.bestsolution.fxide.jdt.text.viewersupport.JavaElementLabelComposer.java

License:Open Source License

/**
 * Appends the label for a type. Considers the T_* flags.
 *
 * @param type the element to render/*from   www  . j a v a2s  .co  m*/
 * @param flags the rendering flags. Flags with names starting with 'T_' are considered.
 */
public void appendTypeLabel(IType type, long flags) {

    if (getFlag(flags, JavaElementLabels.T_FULLY_QUALIFIED)) {
        IPackageFragment pack = type.getPackageFragment();
        if (!pack.isDefaultPackage()) {
            appendPackageFragmentLabel(pack, (flags & QUALIFIER_FLAGS));
            fBuffer.append('.');
        }
    }
    IJavaElement parent = type.getParent();
    if (getFlag(flags, JavaElementLabels.T_FULLY_QUALIFIED | JavaElementLabels.T_CONTAINER_QUALIFIED)) {
        IType declaringType = type.getDeclaringType();
        if (declaringType != null) {
            appendTypeLabel(declaringType, JavaElementLabels.T_CONTAINER_QUALIFIED | (flags & QUALIFIER_FLAGS));
            fBuffer.append('.');
        }
        int parentType = parent.getElementType();
        if (parentType == IJavaElement.METHOD || parentType == IJavaElement.FIELD
                || parentType == IJavaElement.INITIALIZER) { // anonymous or local
            appendElementLabel(parent, 0);
            fBuffer.append('.');
        }
    }

    String typeName;
    boolean isAnonymous = false;
    if (type.isLambda()) {
        typeName = "() -> {...}"; //$NON-NLS-1$
        try {
            String[] superInterfaceSignatures = type.getSuperInterfaceTypeSignatures();
            if (superInterfaceSignatures.length > 0) {
                typeName = typeName + ' ' + getSimpleTypeName(type, superInterfaceSignatures[0]);
            }
        } catch (JavaModelException e) {
            //ignore
        }

    } else {
        typeName = getElementName(type);
        try {
            isAnonymous = type.isAnonymous();
        } catch (JavaModelException e1) {
            // should not happen, but let's play safe:
            isAnonymous = typeName.length() == 0;
        }
        if (isAnonymous) {
            try {
                if (parent instanceof IField && type.isEnum()) {
                    typeName = '{' + JavaElementLabels.ELLIPSIS_STRING + '}';
                } else {
                    String supertypeName = null;
                    String[] superInterfaceSignatures = type.getSuperInterfaceTypeSignatures();
                    if (superInterfaceSignatures.length > 0) {
                        supertypeName = getSimpleTypeName(type, superInterfaceSignatures[0]);
                    } else {
                        String supertypeSignature = type.getSuperclassTypeSignature();
                        if (supertypeSignature != null) {
                            supertypeName = getSimpleTypeName(type, supertypeSignature);
                        }
                    }
                    if (supertypeName == null) {
                        typeName = JavaUIMessages.JavaElementLabels_anonym;
                    } else {
                        typeName = Messages.format(JavaUIMessages.JavaElementLabels_anonym_type, supertypeName);
                    }
                }
            } catch (JavaModelException e) {
                //ignore
                typeName = JavaUIMessages.JavaElementLabels_anonym;
            }
        }
    }
    fBuffer.append(typeName);

    if (getFlag(flags, JavaElementLabels.T_TYPE_PARAMETERS)) {
        if (getFlag(flags, JavaElementLabels.USE_RESOLVED) && type.isResolved()) {
            BindingKey key = new BindingKey(type.getKey());
            if (key.isParameterizedType()) {
                String[] typeArguments = key.getTypeArguments();
                appendTypeArgumentSignaturesLabel(type, typeArguments, flags);
            } else {
                String[] typeParameters = Signature.getTypeParameters(key.toSignature());
                appendTypeParameterSignaturesLabel(typeParameters, flags);
            }
        } else if (type.exists()) {
            try {
                appendTypeParametersLabels(type.getTypeParameters(), flags);
            } catch (JavaModelException e) {
                // ignore
            }
        }
    }

    // category
    if (getFlag(flags, JavaElementLabels.T_CATEGORY) && type.exists()) {
        try {
            appendCategoryLabel(type, flags);
        } catch (JavaModelException e) {
            // ignore
        }
    }

    // post qualification
    if (getFlag(flags, JavaElementLabels.T_POST_QUALIFIED)) {
        int offset = fBuffer.length();
        fBuffer.append(JavaElementLabels.CONCAT_STRING);
        IType declaringType = type.getDeclaringType();
        if (declaringType == null && type.isBinary() && isAnonymous) {
            // workaround for Bug 87165: [model] IType#getDeclaringType() does not work for anonymous binary type
            String tqn = type.getTypeQualifiedName();
            int lastDollar = tqn.lastIndexOf('$');
            if (lastDollar != 1) {
                String declaringTypeCF = tqn.substring(0, lastDollar) + ".class"; //$NON-NLS-1$
                declaringType = type.getPackageFragment().getClassFile(declaringTypeCF).getType();
                try {
                    ISourceRange typeSourceRange = type.getSourceRange();
                    if (declaringType.exists() && SourceRange.isAvailable(typeSourceRange)) {
                        IJavaElement realParent = declaringType.getTypeRoot()
                                .getElementAt(typeSourceRange.getOffset() - 1);
                        if (realParent != null) {
                            parent = realParent;
                        }
                    }
                } catch (JavaModelException e) {
                    // ignore
                }
            }
        }
        if (declaringType != null) {
            appendTypeLabel(declaringType, JavaElementLabels.T_FULLY_QUALIFIED | (flags & QUALIFIER_FLAGS));
            int parentType = parent.getElementType();
            if (parentType == IJavaElement.METHOD || parentType == IJavaElement.FIELD
                    || parentType == IJavaElement.INITIALIZER) { // anonymous or local
                fBuffer.append('.');
                appendElementLabel(parent, 0);
            }
        } else {
            appendPackageFragmentLabel(type.getPackageFragment(), flags & QUALIFIER_FLAGS);
        }
        //         if (getFlag(flags, JavaElementLabels.COLORIZE)) {
        //            fBuffer.setStyle(offset, fBuffer.length() - offset, QUALIFIER_STYLE);
        //         }
    }
}

From source file:ca.ecliptical.pde.ds.search.DescriptorQueryParticipant.java

License:Open Source License

public void search(ISearchRequestor requestor, QuerySpecification query, IProgressMonitor monitor)
        throws CoreException {
    if (debug.isDebugging())
        debug.trace(String.format("Query: %s", query)); //$NON-NLS-1$

    // we only look for straight references
    switch (query.getLimitTo()) {
    case IJavaSearchConstants.REFERENCES:
    case IJavaSearchConstants.ALL_OCCURRENCES:
        break;//from   w ww  . j  a  va  2 s . co  m
    default:
        return;
    }

    // we only look for types and methods
    if (query instanceof ElementQuerySpecification) {
        searchElement = ((ElementQuerySpecification) query).getElement();
        switch (searchElement.getElementType()) {
        case IJavaElement.TYPE:
        case IJavaElement.METHOD:
            break;
        default:
            return;
        }
    } else {
        String pattern = ((PatternQuerySpecification) query).getPattern();
        boolean ignoreMethodParams = false;
        searchFor = ((PatternQuerySpecification) query).getSearchFor();
        switch (searchFor) {
        case IJavaSearchConstants.UNKNOWN:
        case IJavaSearchConstants.METHOD:
            int leftParen = pattern.lastIndexOf('(');
            int rightParen = pattern.indexOf(')');
            ignoreMethodParams = leftParen == -1 || rightParen == -1 || leftParen >= rightParen;
            // no break
        case IJavaSearchConstants.TYPE:
        case IJavaSearchConstants.CLASS:
        case IJavaSearchConstants.CLASS_AND_INTERFACE:
        case IJavaSearchConstants.CLASS_AND_ENUM:
        case IJavaSearchConstants.INTERFACE:
        case IJavaSearchConstants.INTERFACE_AND_ANNOTATION:
            break;
        default:
            return;
        }

        // searchPattern = PatternConstructor.createPattern(pattern, ((PatternQuerySpecification) query).isCaseSensitive());
        int matchMode = getMatchMode(pattern) | SearchPattern.R_ERASURE_MATCH;
        if (((PatternQuerySpecification) query).isCaseSensitive())
            matchMode |= SearchPattern.R_CASE_SENSITIVE;

        searchPattern = new SearchPatternDescriptor(pattern, matchMode, ignoreMethodParams);
    }

    HashSet<IPath> scope = new HashSet<IPath>();
    for (IPath path : query.getScope().enclosingProjectsAndJars()) {
        scope.add(path);
    }

    if (scope.isEmpty())
        return;

    this.requestor = requestor;

    // look through all active bundles
    IPluginModelBase[] wsModels = PluginRegistry.getWorkspaceModels();
    IPluginModelBase[] exModels = PluginRegistry.getExternalModels();
    monitor.beginTask(Messages.DescriptorQueryParticipant_taskName, wsModels.length + exModels.length);
    try {
        // workspace models
        for (IPluginModelBase model : wsModels) {
            if (monitor.isCanceled())
                throw new OperationCanceledException();

            if (!model.isEnabled() || !(model instanceof IBundlePluginModelBase)) {
                monitor.worked(1);
                if (debug.isDebugging())
                    debug.trace(String.format("Non-bundle model: %s", model)); //$NON-NLS-1$

                continue;
            }

            IProject project = model.getUnderlyingResource().getProject();
            if (!scope.contains(project.getFullPath())) {
                monitor.worked(1);
                if (debug.isDebugging())
                    debug.trace(String.format("Project out of scope: %s", project.getName())); //$NON-NLS-1$

                continue;
            }

            // we can only search in Java bundle projects (for now)
            if (!project.hasNature(JavaCore.NATURE_ID)) {
                monitor.worked(1);
                if (debug.isDebugging())
                    debug.trace(String.format("Non-Java project: %s", project.getName())); //$NON-NLS-1$

                continue;
            }

            PDEModelUtility.modifyModel(new ModelModification(project) {
                @Override
                protected void modifyModel(IBaseModel model, IProgressMonitor monitor) throws CoreException {
                    if (model instanceof IBundlePluginModelBase)
                        searchBundle((IBundlePluginModelBase) model, monitor);
                }
            }, new SubProgressMonitor(monitor, 1));
        }

        // external models
        SearchablePluginsManager spm = PDECore.getDefault().getSearchablePluginsManager();
        IJavaProject javaProject = spm.getProxyProject();
        if (javaProject == null || !javaProject.exists() || !javaProject.isOpen()) {
            monitor.worked(exModels.length);
            if (debug.isDebugging())
                debug.trace("External Plug-in Search project inaccessible!"); //$NON-NLS-1$

            return;
        }

        for (IPluginModelBase model : exModels) {
            if (monitor.isCanceled())
                throw new OperationCanceledException();

            BundleDescription bd;
            if (!model.isEnabled() || (bd = model.getBundleDescription()) == null) {
                monitor.worked(1);
                if (debug.isDebugging())
                    debug.trace(String.format("Non-bundle model: %s", model)); //$NON-NLS-1$

                continue;
            }

            // check scope
            ArrayList<IClasspathEntry> cpEntries = new ArrayList<IClasspathEntry>();
            ClasspathUtilCore.addLibraries(model, cpEntries);
            ArrayList<IPath> cpEntryPaths = new ArrayList<IPath>(cpEntries.size());
            for (IClasspathEntry cpEntry : cpEntries) {
                cpEntryPaths.add(cpEntry.getPath());
            }

            cpEntryPaths.retainAll(scope);
            if (cpEntryPaths.isEmpty()) {
                monitor.worked(1);
                if (debug.isDebugging())
                    debug.trace(String.format("External bundle out of scope: %s", model.getInstallLocation())); //$NON-NLS-1$

                continue;
            }

            if (!spm.isInJavaSearch(bd.getSymbolicName())) {
                monitor.worked(1);
                if (debug.isDebugging())
                    debug.trace(String.format("Non-searchable external model: %s", bd.getSymbolicName())); //$NON-NLS-1$

                continue;
            }

            searchBundle(model, javaProject, new SubProgressMonitor(monitor, 1));
        }
    } finally {
        monitor.done();
    }
}

From source file:ca.ecliptical.pde.ds.search.DescriptorQueryParticipant.java

License:Open Source License

private void searchModel(DSModel dsModel, IJavaProject javaProject, Object matchElement,
        IProgressMonitor monitor) throws CoreException {
    IDSComponent component = dsModel.getDSComponent();
    if (component == null) {
        if (debug.isDebugging())
            debug.trace(String.format("No component definition found in file: %s", //$NON-NLS-1$
                    dsModel.getUnderlyingResource() == null ? dsModel.getInstallLocation()
                            : dsModel.getUnderlyingResource().getFullPath())); // TODO de-uglify!

        return;//from   ww  w. j  a v  a 2s  . co  m
    }

    IDSImplementation impl = component.getImplementation();
    if (impl == null) {
        if (debug.isDebugging())
            debug.trace(String.format("No component implementation found in file: %s", //$NON-NLS-1$
                    dsModel.getUnderlyingResource() == null ? dsModel.getInstallLocation()
                            : dsModel.getUnderlyingResource().getFullPath())); // TODO de-uglify!

        return;
    }

    IType implClassType = null;
    String implClassName = impl.getClassName();
    if (implClassName != null)
        implClassType = javaProject.findType(implClassName, monitor);

    if ((searchElement != null && searchElement.getElementType() == IJavaElement.TYPE)
            || searchFor == IJavaSearchConstants.TYPE || searchFor == IJavaSearchConstants.CLASS
            || searchFor == IJavaSearchConstants.CLASS_AND_INTERFACE
            || searchFor == IJavaSearchConstants.CLASS_AND_ENUM || searchFor == IJavaSearchConstants.UNKNOWN) {
        // match specific type references
        if (matches(searchElement, searchPattern, implClassType))
            reportMatch(requestor, impl.getDocumentAttribute(IDSConstants.ATTRIBUTE_IMPLEMENTATION_CLASS),
                    matchElement);
    }

    if ((searchElement != null && searchElement.getElementType() == IJavaElement.TYPE)
            || searchFor == IJavaSearchConstants.TYPE || searchFor == IJavaSearchConstants.CLASS
            || searchFor == IJavaSearchConstants.CLASS_AND_INTERFACE
            || searchFor == IJavaSearchConstants.CLASS_AND_ENUM || searchFor == IJavaSearchConstants.INTERFACE
            || searchFor == IJavaSearchConstants.INTERFACE_AND_ANNOTATION
            || searchFor == IJavaSearchConstants.UNKNOWN) {
        IDSService service = component.getService();
        if (service != null) {
            IDSProvide[] provides = service.getProvidedServices();
            if (provides != null) {
                for (IDSProvide provide : provides) {
                    String ifaceName = provide.getInterface();
                    IType ifaceType = javaProject.findType(ifaceName, monitor);
                    if (matches(searchElement, searchPattern, ifaceType))
                        reportMatch(requestor,
                                provide.getDocumentAttribute(IDSConstants.ATTRIBUTE_PROVIDE_INTERFACE),
                                matchElement);
                }
            }
        }

        IDSReference[] references = component.getReferences();
        if (references != null) {
            for (IDSReference reference : references) {
                String ifaceName = reference.getReferenceInterface();
                IType ifaceType = javaProject.findType(ifaceName, monitor);
                if (matches(searchElement, searchPattern, ifaceType))
                    reportMatch(requestor,
                            reference.getDocumentAttribute(IDSConstants.ATTRIBUTE_REFERENCE_INTERFACE),
                            matchElement);
            }
        }
    }

    if ((searchElement != null && searchElement.getElementType() == IJavaElement.METHOD)
            || searchFor == IJavaSearchConstants.METHOD || searchFor == IJavaSearchConstants.UNKNOWN) {
        // match specific method references
        String activate = component.getActivateMethod();
        if (activate == null)
            activate = "activate"; //$NON-NLS-1$

        IMethod activateMethod = findActivateMethod(implClassType, activate, monitor);
        if (matches(searchElement, searchPattern, activateMethod)) {
            if (component.getActivateMethod() == null)
                reportMatch(requestor, component, matchElement);
            else
                reportMatch(requestor,
                        component.getDocumentAttribute(IDSConstants.ATTRIBUTE_COMPONENT_ACTIVATE),
                        matchElement);
        }

        String modified = component.getModifiedMethod();
        if (modified != null) {
            IMethod modifiedMethod = findActivateMethod(implClassType, modified, monitor);
            if (matches(searchElement, searchPattern, modifiedMethod))
                reportMatch(requestor,
                        component.getDocumentAttribute(IDSConstants.ATTRIBUTE_COMPONENT_MODIFIED),
                        matchElement);
        }

        String deactivate = component.getDeactivateMethod();
        if (deactivate == null)
            deactivate = "deactivate"; //$NON-NLS-1$

        IMethod deactivateMethod = findDeactivateMethod(implClassType, deactivate, monitor);
        if (matches(searchElement, searchPattern, deactivateMethod)) {
            if (component.getDeactivateMethod() == null)
                reportMatch(requestor, component, matchElement);
            else
                reportMatch(requestor,
                        component.getDocumentAttribute(IDSConstants.ATTRIBUTE_COMPONENT_DEACTIVATE),
                        matchElement);
        }

        IDSReference[] references = component.getReferences();
        if (references != null) {
            for (IDSReference reference : references) {
                String refIface = reference.getReferenceInterface();
                if (refIface == null) {
                    if (debug.isDebugging())
                        debug.trace(String.format("No reference interface specified: %s", reference)); //$NON-NLS-1$

                    continue;
                }

                String bind = reference.getReferenceBind();
                if (bind != null) {
                    IMethod bindMethod = findBindMethod(implClassType, bind, refIface, monitor);
                    if (matches(searchElement, searchPattern, bindMethod))
                        reportMatch(requestor,
                                reference.getDocumentAttribute(IDSConstants.ATTRIBUTE_REFERENCE_BIND),
                                matchElement);
                }

                String unbind = reference.getReferenceUnbind();
                if (unbind != null) {
                    IMethod unbindMethod = findBindMethod(implClassType, unbind, refIface, monitor);
                    if (matches(searchElement, searchPattern, unbindMethod))
                        reportMatch(requestor,
                                reference.getDocumentAttribute(IDSConstants.ATTRIBUTE_REFERENCE_UNBIND),
                                matchElement);
                }

                String updated = reference.getXMLAttributeValue("updated"); //$NON-NLS-1$
                if (updated != null) {
                    IMethod updatedMethod = findUpdatedMethod(implClassType, updated, monitor);
                    if (matches(searchElement, searchPattern, updatedMethod))
                        reportMatch(requestor, reference.getDocumentAttribute("updated"), matchElement); //$NON-NLS-1$
                }
            }
        }
    }
}

From source file:ca.uvic.chisel.diver.mylyn.logger.logging.PageSelectionListener.java

License:Open Source License

/**
 * @param je//from w  w w.  j  a  va  2 s  .  c o m
 * @return
 */
private String getElementType(IJavaElement je) {
    switch (je.getElementType()) {
    case IJavaElement.ANNOTATION:
        return "annotation";
    case IJavaElement.CLASS_FILE:
        return "classfile";
    case IJavaElement.COMPILATION_UNIT:
        return "compilationunit";
    case IJavaElement.FIELD:
        return "field";
    case IJavaElement.IMPORT_CONTAINER:
        return "importcontainer";
    case IJavaElement.IMPORT_DECLARATION:
        return "importdeclaration";
    case IJavaElement.INITIALIZER:
        return "initializer";
    case IJavaElement.JAVA_MODEL:
        return "javamodel";
    case IJavaElement.JAVA_PROJECT:
        return "javaproject";
    case IJavaElement.LOCAL_VARIABLE:
        return "localvariable";
    case IJavaElement.METHOD:
        return "method";
    case IJavaElement.PACKAGE_DECLARATION:
        return "packagedeclaration";
    case IJavaElement.PACKAGE_FRAGMENT:
        return "packagefragment";
    case IJavaElement.TYPE:
        return "type";
    case IJavaElement.TYPE_PARAMETER:
        return "typeparameter";
    }
    return "null";
}