KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > core > CancelableNameEnvironment


1 /*******************************************************************************
2  * Copyright (c) 2004, 2006 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.core.runtime.OperationCanceledException;
15 import org.eclipse.jdt.core.JavaModelException;
16 import org.eclipse.jdt.core.WorkingCopyOwner;
17 import org.eclipse.jdt.internal.codeassist.ISearchRequestor;
18 import org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
19 import org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
20
21
22 public class CancelableNameEnvironment extends SearchableEnvironment {
23     public IProgressMonitor monitor;
24
25     public CancelableNameEnvironment(JavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor) 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() + " CANCELLING LOOKUP "); //$NON-NLS-1$
34
throw new AbortCompilation(true/*silent*/, new OperationCanceledException());
35         }
36     }
37
38     public void findPackages(char[] prefix, ISearchRequestor requestor) {
39         checkCanceled();
40         super.findPackages(prefix, requestor);
41     }
42
43     public NameEnvironmentAnswer findType(char[] name, char[][] packageName) {
44         checkCanceled();
45         return super.findType(name, packageName);
46     }
47
48     public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
49         checkCanceled();
50         return super.findType(compoundTypeName);
51     }
52
53     public void findTypes(char[] prefix, boolean findMembers, boolean camelCaseMatch, int searchFor, ISearchRequestor storage) {
54         checkCanceled();
55         super.findTypes(prefix, findMembers, camelCaseMatch, searchFor, storage);
56     }
57 }
58
Popular Tags