From b03d4bb299917983d2c104e818f014e3743f4c17 Mon Sep 17 00:00:00 2001 From: acolyer Date: Fri, 10 Feb 2006 17:53:34 +0000 Subject: [PATCH] don't hold eclipse source types in ajstate --- .../internal/core/builder/AjBuildManager.java | 28 +- .../ajdt/internal/core/builder/AjState.java | 264 +++++++++++++----- 2 files changed, 225 insertions(+), 67 deletions(-) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java index caa4f2d7e..4e5230a91 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjBuildManager.java @@ -44,6 +44,7 @@ import org.aspectj.ajdt.internal.compiler.IIntermediateResultsRequestor; import org.aspectj.ajdt.internal.compiler.IOutputClassFileNameProvider; import org.aspectj.ajdt.internal.compiler.InterimCompilationResult; import org.aspectj.ajdt.internal.compiler.lookup.AjLookupEnvironment; +import org.aspectj.ajdt.internal.compiler.lookup.AnonymousClassPublisher; import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory; import org.aspectj.ajdt.internal.compiler.problem.AjProblemReporter; import org.aspectj.asm.AsmManager; @@ -176,6 +177,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc if (baseHandler instanceof ILifecycleAware) { ((ILifecycleAware)baseHandler).buildStarting(!batch); } + CompilationAndWeavingContext.reset(); int phase = batch ? CompilationAndWeavingContext.BATCH_BUILD : CompilationAndWeavingContext.INCREMENTAL_BUILD; ContextToken ct = CompilationAndWeavingContext.enteringPhase(phase ,buildConfig); try { @@ -260,6 +262,11 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc CompilationAndWeavingContext.leavingPhase(ct); return false; } + + if (state.requiresFullBatchBuild()) { + return batchBuild(buildConfig, baseHandler); + } + binarySourcesForTheNextCompile = state.getBinaryFilesToCompile(false); files = state.getFilesToCompile(false); hereWeGoAgain = !(files.isEmpty() && binarySourcesForTheNextCompile.isEmpty()); @@ -829,6 +836,8 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc handler.handleMessage(new Message("build cancelled:"+oce.getMessage(),IMessage.WARNING,null,null)); } // cleanup + org.aspectj.ajdt.internal.compiler.CompilerAdapter.setCompilerAdapterFactory(null); + AnonymousClassPublisher.aspectOf().setAnonymousClassCreationListener(null); environment.cleanup(); environment = null; } @@ -1108,6 +1117,7 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc */ public ICompilerAdapter getAdapter(org.aspectj.org.eclipse.jdt.internal.compiler.Compiler forCompiler) { // complete compiler config and return a suitable adapter... + populateCompilerOptionsFromLintSettings(forCompiler); AjProblemReporter pr = new AjProblemReporter(DefaultErrorHandlingPolicies.proceedWithAllProblems(), forCompiler.options, getProblemFactory()); @@ -1134,10 +1144,24 @@ public class AjBuildManager implements IOutputClassFileNameProvider,IBinarySourc this, // IOutputFilenameProvider this, // IBinarySourceProvider state.getBinarySourceMap(), - state.getResultSetToUseForFullWeave(), buildConfig.isNoWeave(), buildConfig.getProceedOnError(), - buildConfig.isNoAtAspectJAnnotationProcessing()); + buildConfig.isNoAtAspectJAnnotationProcessing(), + state); + } + + /** + * Some AspectJ lint options need to be known about in the compiler. This is + * how we pass them over... + * @param forCompiler + */ + private void populateCompilerOptionsFromLintSettings(org.aspectj.org.eclipse.jdt.internal.compiler.Compiler forCompiler) { + BcelWorld world = this.state.getBcelWorld(); + IMessage.Kind swallowedExceptionKind = world.getLint().swallowedExceptionInCatchBlock.getKind(); + Map optionsMap = new HashMap(); + optionsMap.put(CompilerOptions.OPTION_ReportSwallowedExceptionInCatchBlock, + swallowedExceptionKind == null ? "ignore" : swallowedExceptionKind.toString()); + forCompiler.options.set(optionsMap); } /* (non-Javadoc) diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java index 48f0f28ef..e47215ace 100644 --- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java +++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AjState.java @@ -15,6 +15,7 @@ package org.aspectj.ajdt.internal.core.builder; import java.io.File; import java.io.FileFilter; +import java.io.FilenameFilter; import java.io.IOException; import java.util.ArrayList; import java.util.Collection; @@ -38,6 +39,7 @@ import org.aspectj.org.eclipse.jdt.internal.compiler.classfmt.ClassFormatExcepti import org.aspectj.org.eclipse.jdt.internal.core.builder.ReferenceCollection; import org.aspectj.org.eclipse.jdt.internal.core.builder.StringSet; import org.aspectj.util.FileUtil; +import org.aspectj.weaver.IWeaver; import org.aspectj.weaver.ResolvedType; import org.aspectj.weaver.bcel.BcelWeaver; import org.aspectj.weaver.bcel.BcelWorld; @@ -64,29 +66,27 @@ public class AjState { private AjBuildConfig buildConfig; + private boolean batchBuildRequiredThisTime = false; + /** - * Holds the CompilationResult produced by JDT as a result of compiling the given - * source file. InterimCompilationResults are *very* memory intensive and we would - * like to release them as soon as possible (currently they are retained in memory - * until the next full build). - * - * Populated in noteResult which adds an InterimCompilationResult (post JDT compile, - * but pre-weave). - * - * The values() of this Map are passed to AjCompilerAdaptor as the result set to - * use if the weaver indicates that a full weave is required. + * Keeps a list of (FQN,Filename) pairs (as ClassFile objects) + * for types that resulted from the compilation of the given + * File. * - * In incremental building, used by addDependentsOf(File) to compute the compile set - * when a given file has been added or modified. + * Populated in noteResult and used in addDependentsOf(File) * - * When processing deleted files, this map is used to see if any of the compilation units - * that came from that file were aspects, and if so, to trigger a full build. + * Added by AMC during state refactoring, 1Q06. + */ + private Map/**/ fullyQualifiedTypeNamesResultingFromCompilationUnit = new HashMap(); + + /** + * Source files defining aspects * - * When deleting class files in preparation for a full build, entries are removed - * from the map. + * Populated in noteResult and used in processDeletedFiles * + * Added by AMC during state refactoring, 1Q06. */ - private Map/*