import org.aspectj.ajdt.internal.compiler.ast.AddAtAspectJAnnotationsVisitor;
import org.aspectj.ajdt.internal.compiler.ast.ValidateAtAspectJAnnotationsVisitor;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
-import org.aspectj.ajdt.internal.core.builder.AjCompilerOptions;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.bridge.IProgressListener;
import org.aspectj.org.eclipse.jdt.core.compiler.IProblem;
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
import org.aspectj.org.eclipse.jdt.internal.compiler.Compiler;
-import org.aspectj.org.eclipse.jdt.internal.compiler.ICompilerAdapter;
import org.aspectj.org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.aspectj.org.eclipse.jdt.internal.compiler.env.ICompilationUnit;
import org.aspectj.org.eclipse.jdt.internal.compiler.impl.CompilerOptions;
weaverMessageHandler = new WeaverMessageHandler(msgHandler, compiler);
world.setMessageHandler(weaverMessageHandler);
}
+
+ // the compilation lifecycle methods below are called in order as compilation progresses...
public void beforeCompiling(ICompilationUnit[] sourceUnits) {
resultsPendingWeave = new ArrayList();
reportedErrors = false;
}
+ public void beforeProcessing(CompilationUnitDeclaration unit) {
+ eWorld.showMessage(IMessage.INFO, "compiling " + new String(unit.getFileName()), null, null);
+ if (inJava5Mode && !noAtAspectJAnnotationProcessing) {
+ AddAtAspectJAnnotationsVisitor atAspectJVisitor = new AddAtAspectJAnnotationsVisitor(unit);
+ unit.traverse(atAspectJVisitor, unit.scope);
+ }
+ }
+
+ public void beforeResolving(CompilationUnitDeclaration unit) {
+ // no-op
+ }
+
+ public void afterResolving(CompilationUnitDeclaration unit) {
+ // no-op
+
+ }
+
+ public void beforeAnalysing(CompilationUnitDeclaration unit) {
+ if (inJava5Mode && !noAtAspectJAnnotationProcessing) {
+ ValidateAtAspectJAnnotationsVisitor atAspectJVisitor = new ValidateAtAspectJAnnotationsVisitor(unit);
+ unit.traverse(atAspectJVisitor, unit.scope);
+ }
+ }
+
+ public void afterAnalysing(CompilationUnitDeclaration unit) {
+ // no-op
+ }
+
+ public void beforeGenerating(CompilationUnitDeclaration unit) {
+ // no-op
+ }
+
+ public void afterGenerating(CompilationUnitDeclaration unit) {
+ // no-op
+ }
+
public void afterCompiling(CompilationUnitDeclaration[] units) {
try {
if (isXNoWeave || (reportedErrors && !proceedOnError)) {
}
}
- public void beforeProcessing(CompilationUnitDeclaration unit) {
- eWorld.showMessage(IMessage.INFO, "compiling " + new String(unit.getFileName()), null, null);
- if (inJava5Mode && !noAtAspectJAnnotationProcessing) {
- AddAtAspectJAnnotationsVisitor atAspectJVisitor = new AddAtAspectJAnnotationsVisitor(unit);
- unit.traverse(atAspectJVisitor, unit.scope);
- }
- }
-
- public void beforeAnalysing(CompilationUnitDeclaration unit) {
- if (inJava5Mode && !noAtAspectJAnnotationProcessing) {
- ValidateAtAspectJAnnotationsVisitor atAspectJVisitor = new ValidateAtAspectJAnnotationsVisitor(unit);
- unit.traverse(atAspectJVisitor, unit.scope);
- }
- }
-
public void afterProcessing(CompilationUnitDeclaration unit, int unitIndex) {
eWorld.finishedCompilationUnit(unit);
InterimCompilationResult intRes = new InterimCompilationResult(unit.compilationResult,outputFileNameProvider);
}
}
- public void beforeResolving(CompilationUnitDeclaration unit, ICompilationUnit sourceUnit, boolean verifyMethods, boolean analyzeCode, boolean generateCode) {
- resultsPendingWeave = new ArrayList();
- reportedErrors = false;
- }
-
- public void afterResolving(CompilationUnitDeclaration unit, ICompilationUnit sourceUnit, boolean verifyMethods, boolean analyzeCode, boolean generateCode) {
- InterimCompilationResult intRes = new InterimCompilationResult(unit.compilationResult,outputFileNameProvider);
- if (unit.compilationResult.hasErrors()) reportedErrors = true;
- if (isXNoWeave || !generateCode) {
- acceptResult(unit.compilationResult);
- } else if (generateCode){
- resultsPendingWeave.add(intRes);
- try {
- weave();
- } catch (IOException ex) {
- AbortCompilation ac = new AbortCompilation(null,ex);
- throw ac;
- }
- }
- }
+// public void beforeResolving(CompilationUnitDeclaration unit, ICompilationUnit sourceUnit, boolean verifyMethods, boolean analyzeCode, boolean generateCode) {
+// resultsPendingWeave = new ArrayList();
+// reportedErrors = false;
+// }
+//
+// public void afterResolving(CompilationUnitDeclaration unit, ICompilationUnit sourceUnit, boolean verifyMethods, boolean analyzeCode, boolean generateCode) {
+// InterimCompilationResult intRes = new InterimCompilationResult(unit.compilationResult,outputFileNameProvider);
+// if (unit.compilationResult.hasErrors()) reportedErrors = true;
+// if (isXNoWeave || !generateCode) {
+// acceptResult(unit.compilationResult);
+// } else if (generateCode){
+// resultsPendingWeave.add(intRes);
+// try {
+// weave();
+// } catch (IOException ex) {
+// AbortCompilation ac = new AbortCompilation(null,ex);
+// throw ac;
+// }
+// }
+// }
// helper methods...
// ==================================================================================
}
}
}
+
}
private FormalBinding[] buildFormalAdviceBindingsFrom(MethodDeclaration mDecl) {
if (mDecl.arguments == null) return new FormalBinding[0];
+ String extraArgName = maybeGetExtraArgName();
+ if (extraArgName == null) extraArgName = "";
FormalBinding[] ret = new FormalBinding[mDecl.arguments.length];
for (int i = 0; i < mDecl.arguments.length; i++) {
Argument arg = mDecl.arguments[i];
if (CharOperation.equals(joinPoint,argTypeBinding.signature()) ||
CharOperation.equals(joinPointStaticPart,argTypeBinding.signature()) ||
CharOperation.equals(joinPointEnclosingStaticPart,argTypeBinding.signature()) ||
- CharOperation.equals(proceedingJoinPoint,argTypeBinding.signature())) {
+ CharOperation.equals(proceedingJoinPoint,argTypeBinding.signature()) ||
+ name.equals(extraArgName)) {
ret[i] = new FormalBinding.ImplicitFormalBinding(type,name,i);
} else {
ret[i] = new FormalBinding(type, name, i, arg.sourceStart, arg.sourceEnd, "unknown");
}
return ret;
}
+
+ private String maybeGetExtraArgName() {
+ String argName = null;
+ if (ajAnnotations.adviceKind == AdviceKind.AfterReturning) {
+ argName = getStringLiteralFor("returning",ajAnnotations.adviceAnnotation,new int[2]);
+ } else if (ajAnnotations.adviceKind == AdviceKind.AfterThrowing) {
+ argName = getStringLiteralFor("throwing",ajAnnotations.adviceAnnotation,new int[2]);
+ }
+ return argName;
+ }
private String getStringLiteralFor(String memberName, Annotation inAnnotation, int[] location) {
if (inAnnotation instanceof SingleMemberAnnotation && memberName.equals("value")) {
import org.aspectj.ajdt.internal.compiler.AjCompilerAdapter;
import org.aspectj.ajdt.internal.compiler.IBinarySourceProvider;
+import org.aspectj.ajdt.internal.compiler.ICompilerAdapter;
+import org.aspectj.ajdt.internal.compiler.ICompilerAdapterFactory;
import org.aspectj.ajdt.internal.compiler.IIntermediateResultsRequestor;
import org.aspectj.ajdt.internal.compiler.IOutputClassFileNameProvider;
import org.aspectj.ajdt.internal.compiler.InterimCompilationResult;
import org.aspectj.org.eclipse.jdt.internal.compiler.ClassFile;
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
import org.aspectj.org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.aspectj.org.eclipse.jdt.internal.compiler.ICompilerAdapter;
-import org.aspectj.org.eclipse.jdt.internal.compiler.ICompilerAdapterFactory;
import org.aspectj.org.eclipse.jdt.internal.compiler.ICompilerRequestor;
import org.aspectj.org.eclipse.jdt.internal.compiler.IProblemFactory;
import org.aspectj.org.eclipse.jdt.internal.compiler.batch.ClasspathDirectory;
environment = new StatefulNameEnvironment(environment, state.classesFromName);
}
- org.aspectj.org.eclipse.jdt.internal.compiler.Compiler.setCompilerAdapterFactory(this);
+ org.aspectj.ajdt.internal.compiler.CompilerAdapter.setCompilerAdapterFactory(this);
org.aspectj.org.eclipse.jdt.internal.compiler.Compiler compiler =
new org.aspectj.org.eclipse.jdt.internal.compiler.Compiler(environment,
DefaultErrorHandlingPolicies.proceedWithAllProblems(),
import org.aspectj.ajdt.core.AspectJCore;
import org.aspectj.ajdt.internal.compiler.AjCompilerAdapter;
import org.aspectj.ajdt.internal.compiler.IBinarySourceProvider;
+import org.aspectj.ajdt.internal.compiler.ICompilerAdapter;
+import org.aspectj.ajdt.internal.compiler.ICompilerAdapterFactory;
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.EclipseFactory;
import org.aspectj.ajdt.internal.compiler.problem.AjProblemReporter;
+import org.aspectj.ajdt.internal.compiler.CompilerAdapter;
import org.aspectj.bridge.AbortException;
import org.aspectj.bridge.IMessage;
import org.aspectj.bridge.IMessageHandler;
import org.aspectj.org.eclipse.jdt.internal.compiler.CompilationResult;
import org.aspectj.org.eclipse.jdt.internal.compiler.Compiler;
import org.aspectj.org.eclipse.jdt.internal.compiler.DefaultErrorHandlingPolicies;
-import org.aspectj.org.eclipse.jdt.internal.compiler.ICompilerAdapter;
-import org.aspectj.org.eclipse.jdt.internal.compiler.ICompilerAdapterFactory;
import org.aspectj.org.eclipse.jdt.internal.compiler.problem.DefaultProblemFactory;
import org.aspectj.org.eclipse.jdt.internal.core.builder.BatchImageBuilder;
import org.aspectj.org.eclipse.jdt.internal.core.builder.BuildNotifier;
// super method always causes construction of a new XXXImageBuilder, which
// causes construction of a new Compiler, so we will be detected as the
// adapter.
- Compiler.setCompilerAdapterFactory(this);
+ CompilerAdapter.setCompilerAdapterFactory(this);
return super.build(kind, ignored, monitor);
}
if (kind == IMessage.DEBUG || kind == IMessage.INFO) return true;
return false;
}
-
+
/**
* No-op
* @see org.aspectj.bridge.IMessageHandler#isIgnoring(org.aspectj.bridge.IMessage.Kind)
*/
public void dontIgnore(IMessage.Kind kind) {
;
- }
-
}
+ }
private static class OutputFileNameProvider implements IOutputClassFileNameProvider {
<run class="ataspectj.PrecedenceTest"/>
</ajc-test>
-<!-- <comment>FIXME AV when JDT of M6 is in</comment>-->
-<!-- <ajc-test dir="java5/ataspectj" title="AfterXTest">-->
-<!-- <compile files="ataspectj/AfterXTest.java,ataspectj/TestHelper.java" options="-1.5"/>-->
-<!-- <run class="ataspectj.AfterXTest"/>-->
-<!-- </ajc-test>-->
+<!-- <comment>FIXME AV when JDT of M6 is in</comment> -->
+ <ajc-test dir="java5/ataspectj" title="AfterXTest">
+ <compile files="ataspectj/AfterXTest.java,ataspectj/TestHelper.java" options="-1.5"/>
+ <run class="ataspectj.AfterXTest"/>
+ </ajc-test>
<!-- <comment>FIXME AV when we impl if support in pointcut parser and weaver</comment>-->
<!-- <ajc-test dir="java5/ataspectj" title="IfPointcutTest">-->