org.aspectj.org.eclipse.jdt.internal.core.CancelableNameEnvironment Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of aspectjtools Show documentation
Show all versions of aspectjtools Show documentation
AspectJ tools most notably contains the AspectJ compiler (AJC). AJC applies aspects to Java classes during
compilation, fully replacing Javac for plain Java classes and also compiling native AspectJ or annotation-based
@AspectJ syntax. Furthermore, AJC can weave aspects into existing class files in a post-compile binary weaving step.
This library is a superset of AspectJ weaver and hence also of AspectJ runtime.
/*******************************************************************************
* Copyright (c) 2004, 2016 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
* which accompanies this distribution, and is available at
* https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
*
* Contributors:
* IBM Corporation - initial API and implementation
*******************************************************************************/
package org.aspectj.org.eclipse.jdt.internal.core;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.aspectj.org.eclipse.jdt.core.JavaModelException;
import org.aspectj.org.eclipse.jdt.core.WorkingCopyOwner;
import org.aspectj.org.eclipse.jdt.internal.codeassist.ISearchRequestor;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.NameEnvironmentAnswer;
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.AbortCompilation;
public class CancelableNameEnvironment extends SearchableEnvironment implements INameEnvironmentWithProgress {
private IProgressMonitor monitor;
public CancelableNameEnvironment(JavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor) throws JavaModelException {
this(project, owner, monitor, false);
}
public CancelableNameEnvironment(JavaProject project, WorkingCopyOwner owner, IProgressMonitor monitor, boolean excludeTestCode) throws JavaModelException {
super(project, owner, excludeTestCode);
setMonitor(monitor);
}
private void checkCanceled() {
if (this.monitor != null && this.monitor.isCanceled()) {
if (NameLookup.VERBOSE)
System.out.println(Thread.currentThread() + " CANCELLING LOOKUP "); //$NON-NLS-1$
throw new AbortCompilation(true/*silent*/, new OperationCanceledException());
}
}
@Override
public void findPackages(char[] prefix, ISearchRequestor requestor) {
checkCanceled();
super.findPackages(prefix, requestor);
}
@Override
public NameEnvironmentAnswer findType(char[] name, char[][] packageName) {
checkCanceled();
return super.findType(name, packageName);
}
@Override
public NameEnvironmentAnswer findType(char[][] compoundTypeName) {
checkCanceled();
return super.findType(compoundTypeName);
}
@Override
public NameEnvironmentAnswer findType(char[] typeName, char[][] packageName, boolean searchWithSecondaryTypes, char[] moduleName) {
return findType(typeName, packageName, moduleName);
}
@Override
public void findTypes(char[] prefix, boolean findMembers, int matchRule, int searchFor, ISearchRequestor storage, IProgressMonitor progressMonitor) {
checkCanceled();
super.findTypes(prefix, findMembers, matchRule, searchFor, storage, progressMonitor);
}
@Override
public void setMonitor(IProgressMonitor monitor) {
this.monitor = monitor;
}
}