View | Details | Raw Unified | Return to bug 314898
Collapse All | Expand All

(-)dom/org/eclipse/jdt/core/dom/CompilationUnitResolver.java (-5 / +5 lines)
Lines 55-61 Link Here
55
import org.eclipse.jdt.internal.core.BinaryMember;
55
import org.eclipse.jdt.internal.core.BinaryMember;
56
import org.eclipse.jdt.internal.core.CancelableNameEnvironment;
56
import org.eclipse.jdt.internal.core.CancelableNameEnvironment;
57
import org.eclipse.jdt.internal.core.CancelableProblemFactory;
57
import org.eclipse.jdt.internal.core.CancelableProblemFactory;
58
import org.eclipse.jdt.internal.core.INameEnviromentWithProgress;
58
import org.eclipse.jdt.internal.core.INameEnvironmentWithProgress;
59
import org.eclipse.jdt.internal.core.JavaProject;
59
import org.eclipse.jdt.internal.core.JavaProject;
60
import org.eclipse.jdt.internal.core.NameLookup;
60
import org.eclipse.jdt.internal.core.NameLookup;
61
import org.eclipse.jdt.internal.core.SourceRefElement;
61
import org.eclipse.jdt.internal.core.SourceRefElement;
Lines 603-609 Link Here
603
			int flags,
603
			int flags,
604
			IProgressMonitor monitor) {
604
			IProgressMonitor monitor) {
605
605
606
			INameEnviromentWithProgress environment = null;
606
			INameEnvironmentWithProgress environment = null;
607
			CancelableProblemFactory problemFactory = null;
607
			CancelableProblemFactory problemFactory = null;
608
			try {
608
			try {
609
				if (monitor != null) {
609
				if (monitor != null) {
Lines 612-618 Link Here
612
				}
612
				}
613
				Classpath[] allEntries = new Classpath[classpaths.size()];
613
				Classpath[] allEntries = new Classpath[classpaths.size()];
614
				classpaths.toArray(allEntries);
614
				classpaths.toArray(allEntries);
615
				environment = new NameEnviromentWithProgress(allEntries, null, monitor);
615
				environment = new NameEnvironmentWithProgress(allEntries, null, monitor);
616
				problemFactory = new CancelableProblemFactory(monitor);
616
				problemFactory = new CancelableProblemFactory(monitor);
617
				CompilerOptions compilerOptions = getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
617
				CompilerOptions compilerOptions = getCompilerOptions(options, (flags & ICompilationUnit.ENABLE_STATEMENTS_RECOVERY) != 0);
618
				compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
618
				compilerOptions.ignoreMethodBodies = (flags & ICompilationUnit.IGNORE_METHOD_BODIES) != 0;
Lines 652-665 Link Here
652
			IProgressMonitor monitor) throws JavaModelException {
652
			IProgressMonitor monitor) throws JavaModelException {
653
653
654
		CompilationUnitDeclaration unit = null;
654
		CompilationUnitDeclaration unit = null;
655
		INameEnviromentWithProgress environment = null;
655
		INameEnvironmentWithProgress environment = null;
656
		CancelableProblemFactory problemFactory = null;
656
		CancelableProblemFactory problemFactory = null;
657
		CompilationUnitResolver resolver = null;
657
		CompilationUnitResolver resolver = null;
658
		try {
658
		try {
659
			if (javaProject == null) {
659
			if (javaProject == null) {
660
				Classpath[] allEntries = new Classpath[classpaths.size()];
660
				Classpath[] allEntries = new Classpath[classpaths.size()];
661
				classpaths.toArray(allEntries);
661
				classpaths.toArray(allEntries);
662
				environment = new NameEnviromentWithProgress(allEntries, null, monitor);
662
				environment = new NameEnvironmentWithProgress(allEntries, null, monitor);
663
			} else {
663
			} else {
664
				environment = new CancelableNameEnvironment((JavaProject) javaProject, owner, monitor);
664
				environment = new CancelableNameEnvironment((JavaProject) javaProject, owner, monitor);
665
			}
665
			}
(-)dom/org/eclipse/jdt/core/dom/NameEnviromentWithProgress.java (-56 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.dom;
12
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.core.runtime.OperationCanceledException;
15
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
16
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
17
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
18
import org.eclipse.jdt.internal.core.INameEnviromentWithProgress;
19
import org.eclipse.jdt.internal.core.NameLookup;
20
21
/**
22
 * Batch name environment that is cancelable using a monitor.
23
 * @since 3.6
24
 */
25
class NameEnviromentWithProgress extends FileSystem implements INameEnviromentWithProgress {
26
	IProgressMonitor monitor;
27
	
28
	public NameEnviromentWithProgress(Classpath[] paths, String[] initialFileNames, IProgressMonitor monitor) {
29
		super(paths, initialFileNames);
30
		setMonitor(monitor);
31
	}
32
	private void checkCanceled() {
33
		if (this.monitor != null && this.monitor.isCanceled()) {
34
			if (NameLookup.VERBOSE) {
35
				System.out.println(Thread.currentThread() + " CANCELLING LOOKUP "); //$NON-NLS-1$
36
			}
37
			throw new AbortCompilation(true/*silent*/, new OperationCanceledException());
38
		}
39
	}
40
	public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
41
		checkCanceled();
42
		return super.findType(typeName, packageName);
43
	}
44
	public NameEnvironmentAnswer findType(char[][] compoundName) {
45
		checkCanceled();
46
		return super.findType(compoundName);
47
	}
48
	public boolean isPackage(char[][] compoundName, char[] packageName) {
49
		checkCanceled();
50
		return super.isPackage(compoundName, packageName);
51
	}
52
	
53
	public void setMonitor(IProgressMonitor monitor) {
54
		this.monitor = monitor;
55
	}
56
}
(-)dom/org/eclipse/jdt/core/dom/NameEnvironmentWithProgress.java (+56 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.core.dom;
12
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.core.runtime.OperationCanceledException;
15
import org.eclipse.jdt.internal.compiler.batch.FileSystem;
16
import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
17
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
18
import org.eclipse.jdt.internal.core.INameEnvironmentWithProgress;
19
import org.eclipse.jdt.internal.core.NameLookup;
20
21
/**
22
 * Batch name environment that can be canceled using a monitor.
23
 * @since 3.6
24
 */
25
class NameEnvironmentWithProgress extends FileSystem implements INameEnvironmentWithProgress {
26
	IProgressMonitor monitor;
27
	
28
	public NameEnvironmentWithProgress(Classpath[] paths, String[] initialFileNames, IProgressMonitor monitor) {
29
		super(paths, initialFileNames);
30
		setMonitor(monitor);
31
	}
32
	private void checkCanceled() {
33
		if (this.monitor != null && this.monitor.isCanceled()) {
34
			if (NameLookup.VERBOSE) {
35
				System.out.println(Thread.currentThread() + " CANCELLING LOOKUP "); //$NON-NLS-1$
36
			}
37
			throw new AbortCompilation(true/*silent*/, new OperationCanceledException());
38
		}
39
	}
40
	public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName) {
41
		checkCanceled();
42
		return super.findType(typeName, packageName);
43
	}
44
	public NameEnvironmentAnswer findType(char[][] compoundName) {
45
		checkCanceled();
46
		return super.findType(compoundName);
47
	}
48
	public boolean isPackage(char[][] compoundName, char[] packageName) {
49
		checkCanceled();
50
		return super.isPackage(compoundName, packageName);
51
	}
52
	
53
	public void setMonitor(IProgressMonitor monitor) {
54
		this.monitor = monitor;
55
	}
56
}
(-)model/org/eclipse/jdt/internal/core/CancelableNameEnvironment.java (-1 / +1 lines)
Lines 19-25 Link Here
19
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
19
import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
20
20
21
21
22
public class CancelableNameEnvironment extends SearchableEnvironment implements INameEnviromentWithProgress {
22
public class CancelableNameEnvironment extends SearchableEnvironment implements INameEnvironmentWithProgress {
23
	private IProgressMonitor monitor;
23
	private IProgressMonitor monitor;
24
24
25
	public CancelableNameEnvironment(JavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException {
25
	public CancelableNameEnvironment(JavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException {
(-)model/org/eclipse/jdt/internal/core/INameEnviromentWithProgress.java (-36 lines)
Removed Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
12
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
15
16
/**
17
 * The name environment provides a callback API that the compiler
18
 * can use to look up types, compilation units, and packages in the
19
 * current environment.  The name environment is passed to the compiler
20
 * on creation.
21
 * 
22
 * This name environment can be canceled using the monitor passed as an argument to
23
 * {@link #setMonitor(IProgressMonitor)}.
24
 * 
25
 * @since 3.6
26
 */
27
public interface INameEnviromentWithProgress extends INameEnvironment {
28
	
29
	/**
30
	 * Set the monitor for the given name environment. In order to be able to cancel this name environment calls,
31
	 * a non-null monitor should be given. 
32
	 * 
33
	 * @param monitor the given monitor
34
	 */
35
	void setMonitor(IProgressMonitor monitor);
36
}
(-)model/org/eclipse/jdt/internal/core/INameEnvironmentWithProgress.java (+36 lines)
Added Link Here
1
/*******************************************************************************
2
 * Copyright (c) 2010 IBM Corporation and others.
3
 * All rights reserved. This program and the accompanying materials
4
 * are made available under the terms of the Eclipse Public License v1.0
5
 * which accompanies this distribution, and is available at
6
 * http://www.eclipse.org/legal/epl-v10.html
7
 *
8
 * Contributors:
9
 *     IBM Corporation - initial API and implementation
10
 *******************************************************************************/
11
package org.eclipse.jdt.internal.core;
12
13
import org.eclipse.core.runtime.IProgressMonitor;
14
import org.eclipse.jdt.internal.compiler.env.INameEnvironment;
15
16
/**
17
 * The name environment provides a callback API that the compiler
18
 * can use to look up types, compilation units, and packages in the
19
 * current environment.  The name environment is passed to the compiler
20
 * on creation.
21
 * 
22
 * This name environment can be canceled using the monitor passed as an argument to
23
 * {@link #setMonitor(IProgressMonitor)}.
24
 * 
25
 * @since 3.6
26
 */
27
public interface INameEnvironmentWithProgress extends INameEnvironment {
28
	
29
	/**
30
	 * Set the monitor for the given name environment. In order to be able to cancel this name environment calls,
31
	 * a non-null monitor should be given. 
32
	 * 
33
	 * @param monitor the given monitor
34
	 */
35
	void setMonitor(IProgressMonitor monitor);
36
}

Return to bug 314898