]> source.dussan.org Git - aspectj.git/commitdiff
changes from HEAD + updates for building inside eclipse ajdt_support
authoracolyer <acolyer>
Tue, 8 Jun 2004 14:01:58 +0000 (14:01 +0000)
committeracolyer <acolyer>
Tue, 8 Jun 2004 14:01:58 +0000 (14:01 +0000)
org.aspectj.ajdt.core/.classpath
org.aspectj.ajdt.core/src/org/aspectj/ajdt/ajc/BuildArgParser.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/core/AspectJCore.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/WeaverMessageHandler.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/compiler/ast/InterTypeMethodDeclaration.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildConfig.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AspectJBuilder.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/EclipseClassPathManager.java

index 0f9073da2331f0e45bf618a591ddfc698d2e2953..c98495474f96fe37fe2b55b32e4f56542a37c130 100644 (file)
@@ -1,16 +1,16 @@
 <?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>
index 70160a2036666eea32e75006ddf6a7732e471f2a..d010975a4cb653f55a3332660b1d18cffd4177db 100644 (file)
@@ -88,7 +88,9 @@ public class BuildArgParser extends Main {
         *         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;
        }  
       
     /**
@@ -100,8 +102,7 @@ public class BuildArgParser extends Main {
      * @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
@@ -124,7 +125,7 @@ public class BuildArgParser extends Main {
             }
                                
                        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
index ef35459e05e793e27e2b8aac92e4c967f3b3e076..f80fd75c1335c7292803073703a88cdf0242d07b 100644 (file)
@@ -42,6 +42,10 @@ public class AspectJCore extends JavaCore {
                super(pluginDescriptor);
        }
        
+       public static AspectJCore getAspectJCore() {
+               return (AspectJCore) getPlugin();
+       }
+       
        /* (non-Javadoc)
         * @see org.eclipse.jdt.core.JavaCore#getCompilerOptions()
         */
index 5f2f49f720d270d2a7a6bf7b5b340a4d500a39a5..71017a6c398ff954c2973403221ee53c17145445 100644 (file)
@@ -49,6 +49,19 @@ public class WeaverMessageHandler implements IMessageHandler {
                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
index ef69dc0227b6d1603882c242b1e0a666df8fc36b..1027ba06760ad504f77835d962cf757db9af8dd4 100644 (file)
@@ -104,8 +104,8 @@ public class InterTypeMethodDeclaration extends InterTypeDeclaration {
                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),
index 51f539f3bcd75523b67f13ecfa42dcfe48dc255a..74f5c4767fe47f9b360cf67ed3a5e337991c8228 100644 (file)
@@ -299,9 +299,10 @@ public class AjBuildConfig { // XXX needs bootclasspath?
      * @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) {
index da10e2e6d1c4d2a5a4345dc48c9e6fde1a50d9b9..276f708b8b6972e12a2d7188de6cebb4615a6f2d 100644 (file)
@@ -65,6 +65,7 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto
        // 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;
                
@@ -97,10 +98,16 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto
         * @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
@@ -110,7 +117,9 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto
                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());
@@ -130,7 +139,7 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto
                return new AjCompilerAdapter(forCompiler,isBatchBuild,myBcelWorld,
                                     myWeaver,eFactory,unwovenResultCollector,ajNotifier,fileNameProvider,bsProvider,
                                         fullBinarySourceEntries,resultSetForFullWeave,
-                                        options.noWeave);
+                                        ajOptions.noWeave);
        }               
        
        /* (non-Javadoc)
@@ -143,8 +152,8 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto
 
        
        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);
@@ -203,7 +212,7 @@ public class AspectJBuilder extends JavaBuilder implements ICompilerAdapterFacto
                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());
index 38e3a889f33bdf034f65a71f0d2c1d594a2dcdea..84e521c03d569aa3816e85b50b44f7b10afe1013 100644 (file)
@@ -38,6 +38,12 @@ public class EclipseClassPathManager extends ClassPathManager {
                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)
         */