Example usage for org.eclipse.jdt.core.dom CompilationUnitResolver resolve

List of usage examples for org.eclipse.jdt.core.dom CompilationUnitResolver resolve

Introduction

In this page you can find the example usage for org.eclipse.jdt.core.dom CompilationUnitResolver resolve.

Prototype

private void resolve(String[] sourceCompilationUnits, String[] encodings, String[] bindingKeys,
            FileASTRequestor astRequestor, int apiLevel, Map compilerOptions, int flags) 

Source Link

Usage

From source file:org.eclipse.jdt.core.dom.CompilationUnitResolver.java

License:Open Source License

public static void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, ASTRequestor requestor,
        int apiLevel, Map options, IJavaProject javaProject, WorkingCopyOwner owner, int flags,
        IProgressMonitor monitor) {/*w  w w  .  j a  va  2s. c om*/

    CancelableNameEnvironment environment = null;
    CancelableProblemFactory problemFactory = null;
    try {
        if (monitor != null) {
            int amountOfWork = (compilationUnits.length + bindingKeys.length) * 2; // 1 for beginToCompile, 1 for resolve
            monitor.beginTask("", amountOfWork); //$NON-NLS-1$
        }
        environment = new CancelableNameEnvironment(((JavaProject) javaProject), owner, monitor);
        problemFactory = new CancelableProblemFactory(monitor);
        CompilerOptions compilerOptions = getCompilerOptions(options,
                (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
        compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
        // GROOVY start
        CompilerUtils.configureOptionsBasedOnNature(compilerOptions, javaProject);
        // GROOVY end
        CompilationUnitResolver resolver = new CompilationUnitResolver(environment, getHandlingPolicy(),
                compilerOptions, getRequestor(), problemFactory, monitor, javaProject != null);
        resolver.resolve(compilationUnits, bindingKeys, requestor, apiLevel, options, owner, flags);
        if (NameLookup.VERBOSE) {
            System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " //$NON-NLS-1$
                    + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$
            System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " //$NON-NLS-1$
                    + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$
        }
    } catch (JavaModelException e) {
        // project doesn't exist -> simple parse without resolving
        parse(compilationUnits, requestor, apiLevel, options, flags, monitor);
    } finally {
        if (monitor != null)
            monitor.done();
        if (environment != null) {
            environment.setMonitor(null); // don't hold a reference to this external object
        }
        if (problemFactory != null) {
            problemFactory.monitor = null; // don't hold a reference to this external object
        }
    }
}

From source file:org.eclipse.jdt.core.dom.CompilationUnitResolver.java

License:Open Source License

public static void resolve(String[] sourceUnits, String[] encodings, String[] bindingKeys,
        FileASTRequestor requestor, int apiLevel, Map options, List classpaths, int flags,
        IProgressMonitor monitor) {//from  w  w w .  j  a v  a  2s . c o m

    INameEnvironmentWithProgress environment = null;
    CancelableProblemFactory problemFactory = null;
    try {
        if (monitor != null) {
            int amountOfWork = (sourceUnits.length + bindingKeys.length) * 2; // 1 for beginToCompile, 1 for resolve
            monitor.beginTask("", amountOfWork); //$NON-NLS-1$
        }
        Classpath[] allEntries = new Classpath[classpaths.size()];
        classpaths.toArray(allEntries);
        environment = new NameEnvironmentWithProgress(allEntries, null, monitor);
        problemFactory = new CancelableProblemFactory(monitor);
        CompilerOptions compilerOptions = getCompilerOptions(options,
                (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
        compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
        CompilationUnitResolver resolver = new CompilationUnitResolver(environment, getHandlingPolicy(),
                compilerOptions, getRequestor(), problemFactory, monitor, false);
        resolver.resolve(sourceUnits, encodings, bindingKeys, requestor, apiLevel, options, flags);
        if (NameLookup.VERBOSE && (environment instanceof CancelableNameEnvironment)) {
            CancelableNameEnvironment cancelableNameEnvironment = (CancelableNameEnvironment) environment;
            System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " //$NON-NLS-1$
                    + cancelableNameEnvironment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$
            System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " //$NON-NLS-1$
                    + cancelableNameEnvironment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$
        }
    } finally {
        if (monitor != null)
            monitor.done();
        if (environment != null) {
            environment.setMonitor(null); // don't hold a reference to this external object
        }
        if (problemFactory != null) {
            problemFactory.monitor = null; // don't hold a reference to this external object
        }
    }
}