Example usage for org.eclipse.jdt.core.search SearchMatch isExact

List of usage examples for org.eclipse.jdt.core.search SearchMatch isExact

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.search SearchMatch isExact.

Prototype

public final boolean isExact() 

Source Link

Document

Returns whether element matches exactly searched pattern or not.

Usage

From source file:edu.brown.cs.bubbles.bedrock.BedrockUtil.java

License:Open Source License

/********************************************************************************/

static void outputSearchMatch(SearchMatch mat, IvyXmlWriter xw) {
    xw.begin("MATCH");
    xw.field("OFFSET", mat.getOffset());
    xw.field("LENGTH", mat.getLength());
    xw.field("STARTOFFSET", mat.getOffset());
    xw.field("ENDOFFSET", mat.getOffset() + mat.getLength());
    IResource irc = mat.getResource();//from  w w w. ja v  a2 s.  co m
    if (irc != null) {
        File f = mat.getResource().getLocation().toFile();
        switch (irc.getType()) {
        case IResource.FILE:
            xw.field("FILE", f.toString());
            break;
        case IResource.PROJECT:
            xw.field("PROJECT", f.toString());
            break;
        case IResource.FOLDER:
            xw.field("FOLDER", f.toString());
            break;
        case IResource.ROOT:
            xw.field("ROOT", f.toString());
            break;
        }
    }
    xw.field("ACCURACY", mat.getAccuracy());
    xw.field("EQUIV", mat.isEquivalent());
    xw.field("ERASURE", mat.isErasure());
    xw.field("EXACT", mat.isExact());
    xw.field("IMPLICIT", mat.isImplicit());
    xw.field("INDOCCMMT", mat.isInsideDocComment());
    xw.field("RAW", mat.isRaw());
    Object o = mat.getElement();
    BedrockPlugin.logD("MATCH ELEMENT " + o);
    if (o instanceof IJavaElement) {
        IJavaElement nelt = (IJavaElement) o;
        outputJavaElement(nelt, false, xw);
    }
    xw.end("MATCH");
}

From source file:org.eclipse.jdt.internal.core.search.matching.MatchLocator.java

License:Open Source License

protected void report(SearchMatch match) throws CoreException {
    if (match == null) {
        if (BasicSearchEngine.VERBOSE) {
            System.out.println("Cannot report a null match!!!"); //$NON-NLS-1$
        }//from   w  ww.ja va  2s.c  om
        return;
    }
    if (filterEnum(match)) {
        if (BasicSearchEngine.VERBOSE) {
            System.out.println("Filtered package with name enum"); //$NON-NLS-1$
        }
        return;
    }
    long start = -1;
    if (BasicSearchEngine.VERBOSE) {
        start = System.currentTimeMillis();
        System.out.println("Reporting match"); //$NON-NLS-1$
        System.out.println("\tResource: " + match.getResource());//$NON-NLS-1$
        System.out.println("\tPositions: [offset=" + match.getOffset() + ", length=" + match.getLength() + "]"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
        try {
            if (this.parser != null && match.getOffset() > 0 && match.getLength() > 0
                    && !(match.getElement() instanceof BinaryMember)) {
                String selection = new String(this.parser.scanner.source, match.getOffset(), match.getLength());
                System.out.println("\tSelection: -->" + selection + "<--"); //$NON-NLS-1$ //$NON-NLS-2$
            }
        } catch (Exception e) {
            // it's just for debug purposes... ignore all exceptions in this area
        }
        try {
            JavaElement javaElement = (JavaElement) match.getElement();
            System.out.println("\tJava element: " + javaElement.toStringWithAncestors()); //$NON-NLS-1$
            if (!javaElement.exists()) {
                System.out.println("\t\tWARNING: this element does NOT exist!"); //$NON-NLS-1$
            }
        } catch (Exception e) {
            // it's just for debug purposes... ignore all exceptions in this area
        }
        if (match instanceof ReferenceMatch) {
            try {
                ReferenceMatch refMatch = (ReferenceMatch) match;
                JavaElement local = (JavaElement) refMatch.getLocalElement();
                if (local != null) {
                    System.out.println("\tLocal element: " + local.toStringWithAncestors()); //$NON-NLS-1$
                }
                if (match instanceof TypeReferenceMatch) {
                    IJavaElement[] others = ((TypeReferenceMatch) refMatch).getOtherElements();
                    if (others != null) {
                        int length = others.length;
                        if (length > 0) {
                            System.out.println("\tOther elements:"); //$NON-NLS-1$
                            for (int i = 0; i < length; i++) {
                                JavaElement other = (JavaElement) others[i];
                                System.out.println("\t\t- " + other.toStringWithAncestors()); //$NON-NLS-1$
                            }
                        }
                    }
                }
            } catch (Exception e) {
                // it's just for debug purposes... ignore all exceptions in this area
            }
        }
        System.out.println(match.getAccuracy() == SearchMatch.A_ACCURATE ? "\tAccuracy: EXACT_MATCH" //$NON-NLS-1$
                : "\tAccuracy: POTENTIAL_MATCH"); //$NON-NLS-1$
        System.out.print("\tRule: "); //$NON-NLS-1$
        if (match.isExact()) {
            System.out.print("EXACT"); //$NON-NLS-1$
        } else if (match.isEquivalent()) {
            System.out.print("EQUIVALENT"); //$NON-NLS-1$
        } else if (match.isErasure()) {
            System.out.print("ERASURE"); //$NON-NLS-1$
        } else {
            System.out.print("INVALID RULE"); //$NON-NLS-1$
        }
        if (match instanceof MethodReferenceMatch) {
            MethodReferenceMatch methodReferenceMatch = (MethodReferenceMatch) match;
            if (methodReferenceMatch.isSuperInvocation()) {
                System.out.print("+SUPER INVOCATION"); //$NON-NLS-1$
            }
            if (methodReferenceMatch.isImplicit()) {
                System.out.print("+IMPLICIT"); //$NON-NLS-1$
            }
            if (methodReferenceMatch.isSynthetic()) {
                System.out.print("+SYNTHETIC"); //$NON-NLS-1$
            }
        }
        System.out.println("\n\tRaw: " + match.isRaw()); //$NON-NLS-1$
    }
    this.requestor.acceptSearchMatch(match);
    if (BasicSearchEngine.VERBOSE)
        this.resultCollectorTime += System.currentTimeMillis() - start;
}