Lines 1-5
Link Here
|
1 |
/******************************************************************************* |
1 |
/******************************************************************************* |
2 |
* Copyright (c) 2000, 2009 IBM Corporation and others. |
2 |
* Copyright (c) 2000, 2010 IBM Corporation and others. |
3 |
* All rights reserved. This program and the accompanying materials |
3 |
* All rights reserved. This program and the accompanying materials |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
5 |
* which accompanies this distribution, and is available at |
5 |
* which accompanies this distribution, and is available at |
Lines 10-15
Link Here
|
10 |
*******************************************************************************/ |
10 |
*******************************************************************************/ |
11 |
package org.eclipse.jdt.core.dom; |
11 |
package org.eclipse.jdt.core.dom; |
12 |
|
12 |
|
|
|
13 |
import java.io.PrintWriter; |
13 |
import java.util.ArrayList; |
14 |
import java.util.ArrayList; |
14 |
import java.util.HashMap; |
15 |
import java.util.HashMap; |
15 |
import java.util.Iterator; |
16 |
import java.util.Iterator; |
Lines 32-37
Link Here
|
32 |
import org.eclipse.jdt.internal.compiler.IProblemFactory; |
33 |
import org.eclipse.jdt.internal.compiler.IProblemFactory; |
33 |
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; |
34 |
import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration; |
34 |
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; |
35 |
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration; |
|
|
36 |
import org.eclipse.jdt.internal.compiler.batch.Main; |
37 |
import org.eclipse.jdt.internal.compiler.batch.FileSystem.Classpath; |
35 |
import org.eclipse.jdt.internal.compiler.env.AccessRestriction; |
38 |
import org.eclipse.jdt.internal.compiler.env.AccessRestriction; |
36 |
import org.eclipse.jdt.internal.compiler.env.INameEnvironment; |
39 |
import org.eclipse.jdt.internal.compiler.env.INameEnvironment; |
37 |
import org.eclipse.jdt.internal.compiler.env.ISourceType; |
40 |
import org.eclipse.jdt.internal.compiler.env.ISourceType; |
Lines 50-55
Link Here
|
50 |
import org.eclipse.jdt.internal.core.BinaryMember; |
53 |
import org.eclipse.jdt.internal.core.BinaryMember; |
51 |
import org.eclipse.jdt.internal.core.CancelableNameEnvironment; |
54 |
import org.eclipse.jdt.internal.core.CancelableNameEnvironment; |
52 |
import org.eclipse.jdt.internal.core.CancelableProblemFactory; |
55 |
import org.eclipse.jdt.internal.core.CancelableProblemFactory; |
|
|
56 |
import org.eclipse.jdt.internal.core.INameEnviromentWithProgress; |
53 |
import org.eclipse.jdt.internal.core.JavaProject; |
57 |
import org.eclipse.jdt.internal.core.JavaProject; |
54 |
import org.eclipse.jdt.internal.core.NameLookup; |
58 |
import org.eclipse.jdt.internal.core.NameLookup; |
55 |
import org.eclipse.jdt.internal.core.SourceRefElement; |
59 |
import org.eclipse.jdt.internal.core.SourceRefElement; |
Lines 491-497
Link Here
|
491 |
} finally { |
495 |
} finally { |
492 |
if (monitor != null) monitor.done(); |
496 |
if (monitor != null) monitor.done(); |
493 |
if (environment != null) { |
497 |
if (environment != null) { |
494 |
environment.monitor = null; // don't hold a reference to this external object |
498 |
environment.setMonitor(null); // don't hold a reference to this external object |
495 |
} |
499 |
} |
496 |
if (problemFactory != null) { |
500 |
if (problemFactory != null) { |
497 |
problemFactory.monitor = null; // don't hold a reference to this external object |
501 |
problemFactory.monitor = null; // don't hold a reference to this external object |
Lines 501-506
Link Here
|
501 |
public static CompilationUnitDeclaration resolve( |
505 |
public static CompilationUnitDeclaration resolve( |
502 |
org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, |
506 |
org.eclipse.jdt.internal.compiler.env.ICompilationUnit sourceUnit, |
503 |
IJavaProject javaProject, |
507 |
IJavaProject javaProject, |
|
|
508 |
String[] classpaths, |
509 |
String[] sourcepaths, |
504 |
NodeSearcher nodeSearcher, |
510 |
NodeSearcher nodeSearcher, |
505 |
Map options, |
511 |
Map options, |
506 |
WorkingCopyOwner owner, |
512 |
WorkingCopyOwner owner, |
Lines 508-518
Link Here
|
508 |
IProgressMonitor monitor) throws JavaModelException { |
514 |
IProgressMonitor monitor) throws JavaModelException { |
509 |
|
515 |
|
510 |
CompilationUnitDeclaration unit = null; |
516 |
CompilationUnitDeclaration unit = null; |
511 |
CancelableNameEnvironment environment = null; |
517 |
INameEnviromentWithProgress environment = null; |
512 |
CancelableProblemFactory problemFactory = null; |
518 |
CancelableProblemFactory problemFactory = null; |
513 |
CompilationUnitResolver resolver = null; |
519 |
CompilationUnitResolver resolver = null; |
514 |
try { |
520 |
try { |
515 |
environment = new CancelableNameEnvironment(((JavaProject)javaProject), owner, monitor); |
521 |
if (javaProject == null) { |
|
|
522 |
Main main = new Main(new PrintWriter(System.out), new PrintWriter(System.err), false/*systemExit*/, null/*options*/, null/*progress*/); |
523 |
ArrayList allClasspaths = new ArrayList(); |
524 |
try { |
525 |
if (sourcepaths != null) { |
526 |
for (int i = 0, max = classpaths.length; i < max; i++) { |
527 |
main.processPathEntries( |
528 |
Main.DEFAULT_SIZE_CLASSPATH, |
529 |
allClasspaths, classpaths[i], null, true, false); |
530 |
} |
531 |
} |
532 |
if (classpaths != null) { |
533 |
for (int i = 0, max = classpaths.length; i < max; i++) { |
534 |
main.processPathEntries( |
535 |
Main.DEFAULT_SIZE_CLASSPATH, |
536 |
allClasspaths, classpaths[i], null, false, false); |
537 |
} |
538 |
} |
539 |
ArrayList pendingErrors = main.pendingErrors; |
540 |
if (pendingErrors != null && pendingErrors.size() != 0) { |
541 |
throw new IllegalStateException("invalid environment settings"); //$NON-NLS-1$ |
542 |
} |
543 |
} catch (IllegalArgumentException e) { |
544 |
throw new IllegalStateException("invalid environment settings"); //$NON-NLS-1$ |
545 |
} |
546 |
Classpath[] allEntries = new Classpath[allClasspaths.size()]; |
547 |
allClasspaths.toArray(allEntries); |
548 |
environment = new NameEnviromentWithProgress(allEntries, null, monitor); |
549 |
} else { |
550 |
environment = new CancelableNameEnvironment((JavaProject) javaProject, owner, monitor); |
551 |
} |
516 |
problemFactory = new CancelableProblemFactory(monitor); |
552 |
problemFactory = new CancelableProblemFactory(monitor); |
517 |
CompilerOptions compilerOptions = getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0); |
553 |
CompilerOptions compilerOptions = getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0); |
518 |
boolean ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0; |
554 |
boolean ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0; |
Lines 547-572
Link Here
|
547 |
return unitDeclaration; |
583 |
return unitDeclaration; |
548 |
} |
584 |
} |
549 |
if (NameLookup.VERBOSE) { |
585 |
if (NameLookup.VERBOSE) { |
550 |
System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + environment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ |
586 |
if (environment instanceof CancelableNameEnvironment) { |
551 |
System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + environment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ |
587 |
CancelableNameEnvironment cancelableNameEnvironment = (CancelableNameEnvironment) environment; |
|
|
588 |
System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInSourcePackage: " + cancelableNameEnvironment.nameLookup.timeSpentInSeekTypesInSourcePackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ |
589 |
System.out.println(Thread.currentThread() + " TIME SPENT in NameLoopkup#seekTypesInBinaryPackage: " + cancelableNameEnvironment.nameLookup.timeSpentInSeekTypesInBinaryPackage + "ms"); //$NON-NLS-1$ //$NON-NLS-2$ |
590 |
} |
552 |
} |
591 |
} |
553 |
return unit; |
592 |
return unit; |
554 |
} finally { |
593 |
} finally { |
555 |
if (environment != null) { |
594 |
if (environment != null) { |
556 |
environment.monitor = null; // don't hold a reference to this external object |
595 |
// don't hold a reference to this external object |
|
|
596 |
environment.setMonitor(null); |
557 |
} |
597 |
} |
558 |
if (problemFactory != null) { |
598 |
if (problemFactory != null) { |
559 |
problemFactory.monitor = null; // don't hold a reference to this external object |
599 |
problemFactory.monitor = null; // don't hold a reference to this external object |
560 |
} |
600 |
} |
561 |
// first unit cleanup is done by caller, but cleanup all enqueued requested units (not processed) |
|
|
562 |
// if (resolver != null) { |
563 |
// for (int i = 1; i < resolver.totalUnits; i++) { // could be more requested units |
564 |
// CompilationUnitDeclaration parsedUnit = resolver.unitsToProcess[i]; |
565 |
// if (parsedUnit.scope != null) |
566 |
// parsedUnit.scope.faultInTypes(); // force resolution of signatures, so clients can query DOM AST |
567 |
// parsedUnit.cleanUp(); |
568 |
// } |
569 |
// } |
570 |
} |
601 |
} |
571 |
} |
602 |
} |
572 |
public static IBinding[] resolve( |
603 |
public static IBinding[] resolve( |
Lines 680-686
Link Here
|
680 |
} |
711 |
} |
681 |
} |
712 |
} |
682 |
|
713 |
|
683 |
private void resolve(ICompilationUnit[] compilationUnits, String[] bindingKeys, ASTRequestor astRequestor, int apiLevel, Map compilerOptions, WorkingCopyOwner owner, int flags) { |
714 |
private void resolve( |
|
|
715 |
ICompilationUnit[] compilationUnits, |
716 |
String[] bindingKeys, |
717 |
ASTRequestor astRequestor, |
718 |
int apiLevel, |
719 |
Map compilerOptions, |
720 |
WorkingCopyOwner owner, |
721 |
int flags) { |
684 |
|
722 |
|
685 |
// temporarily connect ourselves to the ASTResolver - must disconnect when done |
723 |
// temporarily connect ourselves to the ASTResolver - must disconnect when done |
686 |
astRequestor.compilationUnitResolver = this; |
724 |
astRequestor.compilationUnitResolver = this; |