Example usage for org.eclipse.jdt.internal.core.search.matching PossibleMatch getFileName

List of usage examples for org.eclipse.jdt.internal.core.search.matching PossibleMatch getFileName

Introduction

In this page you can find the example usage for org.eclipse.jdt.internal.core.search.matching PossibleMatch getFileName.

Prototype

@Override
public char[] getFileName() 

Source Link

Document

The exact openable file name.

Usage

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

License:Open Source License

protected void process(PossibleMatch possibleMatch, boolean bindingsWereCreated) throws CoreException {
    // GROOVY Start
    // Do not process non-Java files.  They use a separate delegated search
    if (LanguageSupportFactory.isInterestingSourceFile(new String(possibleMatch.getFileName()))) {
        try {/*from  w ww . jav a2 s  .  c o  m*/
            this.lookupEnvironment.buildTypeBindings(possibleMatch.parsedUnit, null /*no access restriction*/);
        } catch (Throwable t) {
            t.printStackTrace();
        }
        possibleMatch.parsedUnit.resolve();
        return;
    }
    // GROOVY End

    this.currentPossibleMatch = possibleMatch;
    CompilationUnitDeclaration unit = possibleMatch.parsedUnit;
    try {
        if (unit.isEmpty()) {
            if (this.currentPossibleMatch.openable instanceof ClassFile) {
                ClassFile classFile = (ClassFile) this.currentPossibleMatch.openable;
                IBinaryType info = null;
                try {
                    info = getBinaryInfo(classFile, classFile.resource());
                } catch (CoreException ce) {
                    // Do nothing
                }
                if (info != null) {
                    boolean mayBeGeneric = this.patternLocator.mayBeGeneric;
                    this.patternLocator.mayBeGeneric = false; // there's no longer generic in class files
                    try {
                        new ClassFileMatchLocator().locateMatches(this, classFile, info);
                    } finally {
                        this.patternLocator.mayBeGeneric = mayBeGeneric;
                    }
                }
            }
            return;
        }
        if (hasAlreadyDefinedType(unit))
            return; // skip type has it is hidden so not visible

        // Move getMethodBodies to #parseAndBuildings(...) method to allow possible match resolution management
        //getMethodBodies(unit);

        boolean mustResolve = (this.pattern.mustResolve || possibleMatch.nodeSet.mustResolve);
        if (bindingsWereCreated && mustResolve) {
            if (unit.types != null) {
                if (BasicSearchEngine.VERBOSE)
                    System.out
                            .println("Resolving " + this.currentPossibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$

                this.lookupEnvironment.unitBeingCompleted = unit;
                reduceParseTree(unit);

                if (unit.scope != null) {
                    // fault in fields & methods
                    unit.scope.faultInTypes();
                }
                unit.resolve();
            } else if (unit.isPackageInfo()) {
                if (BasicSearchEngine.VERBOSE)
                    System.out
                            .println("Resolving " + this.currentPossibleMatch.openable.toStringWithAncestors()); //$NON-NLS-1$
                unit.resolve();
            }
        }
        reportMatching(unit, mustResolve);
    } catch (AbortCompilation e) {
        // could not resolve: report inaccurate matches
        reportMatching(unit, false); // do not resolve when cu has errors
        if (!(e instanceof AbortCompilationUnit)) {
            // problem with class path
            throw e;
        }
    } finally {
        this.lookupEnvironment.unitBeingCompleted = null;
        this.currentPossibleMatch = null;
    }
}