summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormkersten <mkersten>2004-07-27 04:26:54 +0000
committermkersten <mkersten>2004-07-27 04:26:54 +0000
commit66e2167bdae05b1e977836eeffdd87286677676b (patch)
tree7bbda90dbdcdbf8da818848b0cfd5e83870a8ef9
parent1e5567686b5b71a2233820e1b87e7498dfcd2653 (diff)
downloadaspectj-66e2167bdae05b1e977836eeffdd87286677676b.tar.gz
aspectj-66e2167bdae05b1e977836eeffdd87286677676b.zip
Made AsmHiearchyBuilder extensible in order to support tools that require more
static structure than is currently offered by the ASM, e.g. UML views. (changes are covered by existing test cases)
-rw-r--r--org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java96
-rw-r--r--org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java5
2 files changed, 73 insertions, 28 deletions
diff --git a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
index a04930a3f..f4aa53488 100644
--- a/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
+++ b/org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
@@ -13,52 +13,94 @@
package org.aspectj.ajdt.internal.core.builder;
-import java.io.*;
-import java.util.*;
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.ListIterator;
+import java.util.Stack;
import org.aspectj.ajdt.internal.compiler.ast.AspectDeclaration;
import org.aspectj.ajdt.internal.compiler.lookup.EclipseFactory;
-import org.aspectj.asm.*;
+import org.aspectj.asm.IHierarchy;
+import org.aspectj.asm.IProgramElement;
import org.aspectj.asm.internal.ProgramElement;
-import org.aspectj.bridge.*;
+import org.aspectj.bridge.ISourceLocation;
+import org.aspectj.bridge.SourceLocation;
import org.aspectj.util.LangUtil;
import org.aspectj.weaver.Member;
-import org.eclipse.jdt.internal.compiler.*;
-import org.eclipse.jdt.internal.compiler.ast.*;
-import org.eclipse.jdt.internal.compiler.lookup.*;
+import org.eclipse.jdt.internal.compiler.ASTVisitor;
+import org.eclipse.jdt.internal.compiler.CompilationResult;
+import org.eclipse.jdt.internal.compiler.ast.ASTNode;
+import org.eclipse.jdt.internal.compiler.ast.AbstractMethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.AbstractVariableDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ExtendedStringLiteral;
+import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.ImportReference;
+import org.eclipse.jdt.internal.compiler.ast.Initializer;
+import org.eclipse.jdt.internal.compiler.ast.MethodDeclaration;
+import org.eclipse.jdt.internal.compiler.ast.QualifiedAllocationExpression;
+import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
+import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
+import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
+import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
+import org.eclipse.jdt.internal.compiler.lookup.MethodScope;
import org.eclipse.jdt.internal.compiler.problem.ProblemHandler;
/**
+ * At each iteration of <CODE>processCompilationUnit</CODE> the declarations for a
+ * particular compilation unit are added to the hierarchy passed as a a parameter.
+ *
+ * Clients who extend this class need to ensure that they do not override any of the existing
+ * behavior. If they do, the structure model will not be built properly and tools such as IDE
+ * structure views and ajdoc will fail.
+ *
* @author Mik Kersten
*/
public class AsmHierarchyBuilder extends ASTVisitor {
- public static void build(
- CompilationUnitDeclaration unit,
- IHierarchy structureModel, AjBuildConfig buildConfig) {
- LangUtil.throwIaxIfNull(unit, "unit");
- new AsmHierarchyBuilder(unit.compilationResult(), buildConfig).internalBuild(unit, structureModel);
- }
+// public static void build(
+// CompilationUnitDeclaration unit,
+// IHierarchy structureModel, AjBuildConfig buildConfig) {
+// LangUtil.throwIaxIfNull(unit, "unit");
+// new AsmHierarchyBuilder(unit., ).;
+// }
- private final Stack stack;
- private final CompilationResult currCompilationResult;
- private AsmElementFormatter formatter = new AsmElementFormatter();
- private AjBuildConfig buildConfig;
+ protected AsmElementFormatter formatter = new AsmElementFormatter();
+
+ /**
+ * Reset for every compilation unit.
+ */
+ protected AjBuildConfig buildConfig;
- protected AsmHierarchyBuilder(CompilationResult result, AjBuildConfig buildConfig) {
- LangUtil.throwIaxIfNull(result, "result");
- currCompilationResult = result;
+ /**
+ * Reset for every compilation unit.
+ */
+ protected Stack stack;
+
+ /**
+ * Reset for every compilation unit.
+ */
+ private CompilationResult currCompilationResult;
+
+ /**
+ *
+ * @param cuDeclaration
+ * @param buildConfig
+ * @param structureModel hiearchy to add this unit's declarations to
+ */
+ public void buildStructureForCompilationUnit(CompilationUnitDeclaration cuDeclaration, IHierarchy structureModel, AjBuildConfig buildConfig) {
+ currCompilationResult = cuDeclaration.compilationResult();
+ LangUtil.throwIaxIfNull(currCompilationResult, "result");
stack = new Stack();
this.buildConfig = buildConfig;
+ internalBuild(cuDeclaration, structureModel);
+// throw new RuntimeException("not implemented");
}
- /**
- * Called only by
- * build(CompilationUnitDeclaration unit, StructureModel structureModel)
- */
- private void internalBuild(
- CompilationUnitDeclaration unit,
- IHierarchy structureModel) {
+ private void internalBuild(CompilationUnitDeclaration unit, IHierarchy structureModel) {
LangUtil.throwIaxIfNull(structureModel, "structureModel");
if (!currCompilationResult.equals(unit.compilationResult())) {
throw new IllegalArgumentException("invalid unit: " + unit);
diff --git a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java
index 61d2b481d..1cef4273a 100644
--- a/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java
+++ b/org.aspectj.ajdt.core/testsrc/org/aspectj/ajdt/internal/core/builder/AsmBuilderTest.java
@@ -25,6 +25,8 @@ import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
public class AsmBuilderTest extends TestCase {
+ private AsmHierarchyBuilder builder = new AsmHierarchyBuilder();
+
public static Test suite() {
TestSuite suite = new TestSuite(AsmBuilderTest.class.getName());
//$JUnit-BEGIN$
@@ -60,7 +62,8 @@ public class AsmBuilderTest extends TestCase {
BlockScope scope = null;
try {
- new AsmHierarchyBuilder(new CompilationResult(cu, 0, 0, 0), null).visit(local, scope);
+// builder.internalBuild(new CompilationResult(cu, 0, 0, 0), null);
+ builder.visit(local, scope);
}
catch (Exception e) {
assertTrue(e instanceof NullPointerException);