01: /*******************************************************************************
02: * Copyright (c) 2004, 2006 IBM Corporation and others.
03: * All rights reserved. This program and the accompanying materials
04: * are made available under the terms of the Eclipse Public License v1.0
05: * which accompanies this distribution, and is available at
06: * http://www.eclipse.org/legal/epl-v10.html
07: *
08: * Contributors:
09: * IBM Corporation - initial API and implementation
10: *******************************************************************************/package org.eclipse.jdt.internal.core;
11:
12: import org.eclipse.core.runtime.IProgressMonitor;
13: import org.eclipse.core.runtime.OperationCanceledException;
14: import org.eclipse.jdt.core.JavaModelException;
15: import org.eclipse.jdt.core.WorkingCopyOwner;
16: import org.eclipse.jdt.internal.codeassist.ISearchRequestor;
17: import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
18: import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
19:
20: public class CancelableNameEnvironment extends SearchableEnvironment {
21: public IProgressMonitor monitor;
22:
23: public CancelableNameEnvironment(JavaProject project,
24: WorkingCopyOwner owner, IProgressMonitor monitor)
25: throws JavaModelException {
26: super (project, owner);
27: this .monitor = monitor;
28: }
29:
30: private void checkCanceled() {
31: if (this .monitor != null && this .monitor.isCanceled()) {
32: if (NameLookup.VERBOSE)
33: System.out.println(Thread.currentThread()
34: + " CANCELLING LOOKUP "); //$NON-NLS-1$
35: throw new AbortCompilation(true/*silent*/,
36: new OperationCanceledException());
37: }
38: }
39:
40: public void findPackages(char[] prefix, ISearchRequestor requestor) {
41: checkCanceled();
42: super .findPackages(prefix, requestor);
43: }
44:
45: public NameEnvironmentAnswer findType(char[] name,
46: char[][] packageName) {
47: checkCanceled();
48: return super .findType(name, packageName);
49: }
50:
51: public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
52: checkCanceled();
53: return super .findType(compoundTypeName);
54: }
55:
56: public void findTypes(char[] prefix, boolean findMembers,
57: boolean camelCaseMatch, int searchFor,
58: ISearchRequestor storage) {
59: checkCanceled();
60: super.findTypes(prefix, findMembers, camelCaseMatch, searchFor,
61: storage);
62: }
63: }
|