<?xml version="1.0" encoding="UTF-8"?>
<classpath>
- <classpathentry kind="src" path="src"/>
- <classpathentry kind="var" path="JRE_LIB" sourcepath="JRE_SRC"/>
- <classpathentry kind="src" path="/org.eclipse.jdt.core"/>
- <classpathentry kind="src" path="/bridge"/>
- <classpathentry kind="src" path="/weaver"/>
- <classpathentry kind="src" path="/asm"/>
- <classpathentry kind="src" path="/util"/>
- <classpathentry kind="src" path="/runtime"/>
- <classpathentry kind="src" path="testsrc"/>
- <classpathentry kind="lib" path="/lib/bcel/bcel.jar" sourcepath="/lib/bcel/bcel-src.zip"/>
- <classpathentry kind="lib" path="/lib/junit/junit.jar" sourcepath="/lib/junit/junit-src.jar"/>
- <classpathentry kind="src" path="/testing-util"/>
- <classpathentry kind="output" path="bin"/>
+ <classpathentry kind="src" path="src"/>
+ <classpathentry sourcepath="JRE_SRC" kind="var" path="JRE_LIB"/>
+ <classpathentry kind="src" path="/bridge"/>
+ <classpathentry kind="src" path="/weaver"/>
+ <classpathentry kind="src" path="/asm"/>
+ <classpathentry kind="src" path="/util"/>
+ <classpathentry kind="src" path="/runtime"/>
+ <classpathentry kind="src" path="testsrc"/>
+ <classpathentry sourcepath="/lib/bcel/bcel-src.zip" kind="lib" path="/lib/bcel/bcel.jar"/>
+ <classpathentry sourcepath="/lib/junit/junit-src.jar" kind="lib" path="/lib/junit/junit.jar"/>
+ <classpathentry kind="src" path="/testing-util"/>
+ <classpathentry kind="src" path="/org.eclipse.jdt.core"/>
+ <classpathentry kind="output" path="bin"/>
</classpath>
* which will be invalid unless there are no handler errors.
*/
public AjBuildConfig genBuildConfig(String[] args) {
- return genBuildConfig(args, true, null);
+ AjBuildConfig config = new AjBuildConfig();
+ populateBuildConfig(config, args, true, null);
+ return config;
}
/**
* @return AjBuildConfig per args,
* which will be invalid unless there are no handler errors.
*/
- public AjBuildConfig genBuildConfig(String[] args, boolean setClasspath, File configFile) {
- AjBuildConfig buildConfig = new AjBuildConfig();
+ public AjBuildConfig populateBuildConfig(AjBuildConfig buildConfig, String[] args, boolean setClasspath, File configFile) {
buildConfig.setConfigFile(configFile);
try {
// sets filenames to be non-null in order to make sure that file paramters are ignored
}
List javaArgList = new ArrayList();
- // disable all special eclipse warnings by default
+ // disable all special eclipse warnings by default - why???
//??? might want to instead override getDefaultOptions()
javaArgList.add("-warn:none");
// these next four lines are some nonsense to fool the eclipse batch compiler
super(pluginDescriptor);
}
+ public static AspectJCore getAspectJCore() {
+ return (AspectJCore) getPlugin();
+ }
+
/* (non-Javadoc)
* @see org.eclipse.jdt.core.JavaCore#getCompilerOptions()
*/
if (! (message.isError() || message.isWarning()) ) return sink.handleMessage(message);
// we only care about warnings and errors here...
ISourceLocation sLoc = message.getSourceLocation();
+
+ // See bug 62073. We should assert that the caller pass the correct primary source location.
+ // But for AJ1.2 final we will simply do less processing of the locations if that is not the
+ // case (By calling sink.handleMessage()) - this ensures we don't put out bogus source context info.
+ if (sLoc instanceof EclipseSourceLocation) {
+ EclipseSourceLocation esLoc = (EclipseSourceLocation)sLoc;
+ if (currentlyWeaving!=null && esLoc.getCompilationResult()!=null) {
+ if (!currentlyWeaving.equals(((EclipseSourceLocation)sLoc).getCompilationResult()))
+ return sink.handleMessage(message);
+ // throw new RuntimeException("Primary source location must match the file we are currently processing!");
+ }
+ }
+
CompilationResult problemSource = currentlyWeaving;
if (problemSource == null) {
// must be a problem found during completeTypeBindings phase of begin to compile
binding = classScope.referenceContext.binding.resolveTypesFor(binding);
if (binding == null) {
// if binding is null, we failed to find a type used in the method params, this error
- // has already been reported.
- throw new AbortCompilation();
+ // has already been reported.
+ throw new AbortCompilation(compilationResult);
}
ResolvedMember sig = new ResolvedMember(Member.METHOD, EclipseFactory.fromBinding(onTypeBinding),
declaredModifiers, EclipseFactory.fromBinding(binding.returnType), new String(declaredSelector),
* @param global the AjBuildConfig to read globals from
*/
public void installGlobals(AjBuildConfig global) { // XXX relies on default values
- Map optionsMap = options.getMap();
- join(optionsMap,global.getOptions().getMap());
- options.set(optionsMap);
+ // don't join the options - they already have defaults taken care of.
+// Map optionsMap = options.getMap();
+// join(optionsMap,global.getOptions().getMap());
+// options.set(optionsMap);
join(aspectpath, global.aspectpath);
join(classpath, global.classpath);
if (null == configFile) {
// One builder instance per project (important)
private BcelWeaver myWeaver = null;
private BcelWorld myBcelWorld = null;
+ private EclipseClassPathManager cpManager = null;
private UnwovenResultCollector unwovenResultCollector = null;
private OutputFileNameProvider fileNameProvider = null;
* @see org.eclipse.jdt.internal.compiler.ICompilerAdapterFactory#getAdapter(org.eclipse.jdt.internal.compiler.Compiler)
*/
public ICompilerAdapter getAdapter(Compiler forCompiler) {
- AjCompilerOptions options = (AjCompilerOptions) forCompiler.options;
+ Map javaOptions = forCompiler.options.getMap();
+ // TODO get aspectj options from project and add into map before...
+ AjCompilerOptions ajOptions = new AjCompilerOptions(javaOptions);
+ forCompiler.options = ajOptions;
if (isBatchBuild || myBcelWorld == null || myWeaver == null) {
- initWorldAndWeaver(options);
+ initWorldAndWeaver(ajOptions);
+ } else {
+ // update the nameEnvironment each time we compile...
+ cpManager.setNameEnvironment(nameEnvironment);
}
// * an eclipse factory -- create from AjLookupEnvironment, need to hide AjBuildManager field
forCompiler.problemReporter = pr;
AjLookupEnvironment le =
new AjLookupEnvironment(forCompiler, forCompiler.options, pr,nameEnvironment);
- EclipseFactory eFactory = new EclipseFactory(le,myBcelWorld,options.xSerializableAspects);
+ EclipseFactory eFactory = new EclipseFactory(le,myBcelWorld,ajOptions.xSerializableAspects);
+ le.factory = eFactory;
+ forCompiler.lookupEnvironment = le;
AjBuildNotifier ajNotifier = (AjBuildNotifier) notifier;
if (fileNameProvider == null ) fileNameProvider = new OutputFileNameProvider(getProject());
return new AjCompilerAdapter(forCompiler,isBatchBuild,myBcelWorld,
myWeaver,eFactory,unwovenResultCollector,ajNotifier,fileNameProvider,bsProvider,
fullBinarySourceEntries,resultSetForFullWeave,
- options.noWeave);
+ ajOptions.noWeave);
}
/* (non-Javadoc)
private void initWorldAndWeaver(AjCompilerOptions options) {
- EclipseClassPathManager cpMgr = new EclipseClassPathManager(nameEnvironment);
- myBcelWorld = new BcelWorld(cpMgr,new UnhandledMessageHandler(getProject()),null /*(xrefHandler)*/);
+ cpManager = new EclipseClassPathManager(nameEnvironment);
+ myBcelWorld = new BcelWorld(cpManager,new UnhandledMessageHandler(getProject()),null /*(xrefHandler)*/);
myBcelWorld.setXnoInline(options.xNoInline);
myBcelWorld.setXlazyTjp(options.xLazyThisJoinPoint);
setLintProperties(myBcelWorld,options);
public boolean handleMessage(IMessage message) throws AbortException {
try {
IMarker marker = project.createMarker(IJavaModelMarker.JAVA_MODEL_PROBLEM_MARKER);
- marker.setAttribute(IMarker.MESSAGE, message);
+ marker.setAttribute(IMarker.MESSAGE, message.getMessage());
marker.setAttribute(IMarker.SEVERITY, message.isError() ? IMarker.SEVERITY_ERROR : IMarker.SEVERITY_WARNING);
} catch (CoreException e) {
AspectJCore.getPlugin().getLog().log(e.getStatus());
this.nameEnv = env;
}
+ // class path manager will be used by weaver across multiple compiles,
+ // whereas a name environment may be constructed per-compile.
+ public void setNameEnvironment(INameEnvironment env) {
+ this.nameEnv = env;
+ }
+
/* (non-Javadoc)
* @see org.aspectj.weaver.bcel.ClassPathManager#addPath(java.lang.String, org.aspectj.bridge.IMessageHandler)
*/