diff options
10 files changed, 137 insertions, 12 deletions
diff --git a/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java b/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java index ea57729d2..3c2914c64 100644 --- a/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java +++ b/ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java @@ -48,6 +48,7 @@ public abstract class AbstractIconRegistry { protected final AbstractIcon METHOD = createIcon(STRUCTURE_PATH + "method.gif"); protected final AbstractIcon FIELD = createIcon(STRUCTURE_PATH + "field.gif"); + protected final AbstractIcon ENUM_VALUE = createIcon(STRUCTURE_PATH + "field.gif");//???Change to an enum value icon... protected final AbstractIcon CLASS = createIcon(STRUCTURE_PATH + "class.gif"); protected final AbstractIcon INTERFACE = createIcon(STRUCTURE_PATH + "interface.gif"); @@ -115,6 +116,8 @@ public abstract class AbstractIconRegistry { return METHOD; } else if (kind == IProgramElement.Kind.FIELD) { return FIELD; + } else if (kind == IProgramElement.Kind.ENUM_VALUE) { + return ENUM_VALUE; } else if (kind == IProgramElement.Kind.POINTCUT) { return POINTCUT; } else if (kind == IProgramElement.Kind.ADVICE) { diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java index a4d43fa47..c351ae505 100644 --- a/asm/src/org/aspectj/asm/IProgramElement.java +++ b/asm/src/org/aspectj/asm/IProgramElement.java @@ -220,6 +220,7 @@ public interface IProgramElement extends Serializable { public static final Kind INTERFACE = new Kind("interface"); public static final Kind ASPECT = new Kind("aspect"); public static final Kind ENUM = new Kind("enum"); + public static final Kind ENUM_VALUE = new Kind("enumvalue"); public static final Kind ANNOTATION = new Kind("annotation"); public static final Kind INITIALIZER = new Kind("initializer"); public static final Kind INTER_TYPE_FIELD = new Kind("inter-type field"); @@ -254,6 +255,7 @@ public interface IProgramElement extends Serializable { INTERFACE, ASPECT, ENUM, + ENUM_VALUE, ANNOTATION, INITIALIZER, INTER_TYPE_FIELD, @@ -295,6 +297,7 @@ public interface IProgramElement extends Serializable { public static List getNonAJMemberKinds() { List list = new ArrayList(); list.add(METHOD); + list.add(ENUM_VALUE); list.add(FIELD); list.add(CONSTRUCTOR); return list; @@ -305,7 +308,8 @@ public interface IProgramElement extends Serializable { || this == METHOD || this == CONSTRUCTOR || this == POINTCUT - || this == ADVICE; + || this == ADVICE + || this == ENUM_VALUE; } public boolean isInterTypeMember() { @@ -317,7 +321,9 @@ public interface IProgramElement extends Serializable { public boolean isType() { return this == CLASS || this == INTERFACE - || this == ASPECT; + || this == ASPECT + || this == ANNOTATION + || this == ENUM; } public boolean isSourceFile() { 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 4494a6619..edcba82c9 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 @@ -537,15 +537,21 @@ public class AsmHierarchyBuilder extends ASTVisitor { } } - public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) { - IProgramElement peNode = new ProgramElement( - new String(fieldDeclaration.name), - IProgramElement.Kind.FIELD, - makeLocation(fieldDeclaration), - fieldDeclaration.modifiers, - "", - new ArrayList()); - peNode.setCorrespondingType(fieldDeclaration.type.toString()); + public boolean visit(FieldDeclaration fieldDeclaration, MethodScope scope) { + IProgramElement peNode = null; + if (fieldDeclaration.type == null) { // The field represents an enum value + peNode = new ProgramElement( + new String(fieldDeclaration.name),IProgramElement.Kind.ENUM_VALUE, + makeLocation(fieldDeclaration), fieldDeclaration.modifiers, + "", new ArrayList()); + peNode.setCorrespondingType(fieldDeclaration.binding.type.debugName()); + } else { + peNode = new ProgramElement( + new String(fieldDeclaration.name),IProgramElement.Kind.FIELD, + makeLocation(fieldDeclaration), fieldDeclaration.modifiers, + "", new ArrayList()); + peNode.setCorrespondingType(fieldDeclaration.type.toString()); + } peNode.setSourceSignature(genSourceSignature(fieldDeclaration)); peNode.setFormalComment(generateJavadocComment(fieldDeclaration)); @@ -599,7 +605,11 @@ public class AsmHierarchyBuilder extends ASTVisitor { protected String genSourceSignature(FieldDeclaration fieldDeclaration) { StringBuffer output = new StringBuffer(); FieldDeclaration.printModifiers(fieldDeclaration.modifiers, output); - fieldDeclaration.type.print(0, output).append(' ').append(fieldDeclaration.name); + if (fieldDeclaration.type == null) { // This is an enum value + output.append(fieldDeclaration.binding.type.debugName()).append(" ").append(fieldDeclaration.name); + } else { + fieldDeclaration.type.print(0, output).append(' ').append(fieldDeclaration.name); + } if (fieldDeclaration.initialization != null && !(fieldDeclaration.initialization instanceof QualifiedAllocationExpression)) { diff --git a/tests/bugs150/Rainbow.java b/tests/bugs150/Rainbow.java new file mode 100644 index 000000000..7b1aa769d --- /dev/null +++ b/tests/bugs150/Rainbow.java @@ -0,0 +1,3 @@ +public enum Rainbow { + Red,Orange,Yellow,Green,Blue,Indigo,Violet; +} diff --git a/tests/src/org/aspectj/systemtest/AllTests15.java b/tests/src/org/aspectj/systemtest/AllTests15.java new file mode 100644 index 000000000..647bd722a --- /dev/null +++ b/tests/src/org/aspectj/systemtest/AllTests15.java @@ -0,0 +1,21 @@ +/* + * Created on 19-01-2005 + */ +package org.aspectj.systemtest; + +import junit.framework.Test; +import junit.framework.TestSuite; + +import org.aspectj.systemtest.ajc150.AllTestsAspectJ150_NeedJava15; + +public class AllTests15 { + + public static Test suite() { + TestSuite suite = new TestSuite("AspectJ System Test Suite - JDK 1.5"); + //$JUnit-BEGIN$ + suite.addTest(AllTests14.suite()); + suite.addTestSuite(AllTestsAspectJ150_NeedJava15.class); + //$JUnit-END$ + return suite; + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java index fdd6f10a4..a84821aab 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java @@ -16,6 +16,9 @@ import junit.framework.Test; import org.aspectj.testing.XMLBasedAjcTestCase; +/** + * These are tests that will run on Java 1.4 and use the old harness format for test specification. + */ public class Ajc150Tests extends org.aspectj.testing.XMLBasedAjcTestCase { public static Test suite() { diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsNoHarness.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsNoHarness.java index 44c65430a..9c4c08fdc 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsNoHarness.java +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsNoHarness.java @@ -20,6 +20,8 @@ import org.aspectj.tools.ajc.CompilationResult; /** + * These are tests that run on Java 1.4 and use the new ajctestcase format. + * If you have a test that *needs* to run on Java 1.5 then look in Ajc150TestsRequireJava15.java */ public class Ajc150TestsNoHarness extends TestUtils { diff --git a/tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsRequireJava15.java b/tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsRequireJava15.java new file mode 100644 index 000000000..42dc6f839 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsRequireJava15.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import java.io.ByteArrayOutputStream; +import java.io.File; +import java.io.IOException; +import java.io.PrintWriter; + +import org.aspectj.asm.AsmManager; +import org.aspectj.tools.ajc.CompilationResult; + + +/** + * These tests only execute in a 1.5 environment. + */ +public class Ajc150TestsRequireJava15 extends TestUtils { + + protected void setUp() throws Exception { + super.setUp(); + baseDir = new File("../tests/bugs150"); + } + + public void testBadASMforEnums() throws IOException { + CompilationResult cR = ajc(baseDir,new String[]{"Rainbow.java","-emacssym","-1.5"}); + System.err.println(cR); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + PrintWriter pw = new PrintWriter(baos); + AsmManager.dumptree(pw,AsmManager.getDefault().getHierarchy().getRoot(),0); + pw.flush(); + String tree = baos.toString(); + assertTrue("Expected 'Red [enumvalue]' somewhere in here:"+tree,tree.indexOf("Red [enumvalue]")!=-1); + } + +}
\ No newline at end of file diff --git a/tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java b/tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java index fa0cff9c5..a528692bd 100644 --- a/tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java +++ b/tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java @@ -13,6 +13,9 @@ package org.aspectj.systemtest.ajc150; import junit.framework.Test; import junit.framework.TestSuite; +/** + * This pulls together tests we have written for AspectJ 1.5.0 that don't need Java 1.5 to run + */ public class AllTestsAspectJ150 { public static Test suite() { diff --git a/tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150_NeedJava15.java b/tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150_NeedJava15.java new file mode 100644 index 000000000..ff0f19202 --- /dev/null +++ b/tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150_NeedJava15.java @@ -0,0 +1,30 @@ +/******************************************************************************* + * Copyright (c) 2005 IBM + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Common Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/cpl-v10.html + * + * Contributors: + * Andy Clement - initial API and implementation + *******************************************************************************/ +package org.aspectj.systemtest.ajc150; + +import junit.framework.Test; +import junit.framework.TestSuite; + +/** + * This is a superset of AllTestsAspectJ150 that includes tests that must be run on Java 1.5 + */ +public class AllTestsAspectJ150_NeedJava15 { + + public static Test suite() { + TestSuite suite = new TestSuite("Java5"); + //$JUnit-BEGIN$ + suite.addTestSuite(Ajc150TestsRequireJava15.class); + suite.addTestSuite(Autoboxing.class); + + //$JUnit-END$ + return suite; + } +} |