]> source.dussan.org Git - aspectj.git/commitdiff
Get enum value fields to work in the ASM. Plus test reorg as we are now adding tests...
authoraclement <aclement>
Thu, 20 Jan 2005 10:26:46 +0000 (10:26 +0000)
committeraclement <aclement>
Thu, 20 Jan 2005 10:26:46 +0000 (10:26 +0000)
ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java
asm/src/org/aspectj/asm/IProgramElement.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java
tests/bugs150/Rainbow.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/AllTests15.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/Ajc150Tests.java
tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsNoHarness.java
tests/src/org/aspectj/systemtest/ajc150/Ajc150TestsRequireJava15.java [new file with mode: 0644]
tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150.java
tests/src/org/aspectj/systemtest/ajc150/AllTestsAspectJ150_NeedJava15.java [new file with mode: 0644]

index ea57729d224719cdedc079244b44488bbcf16c9c..3c2914c64c4063796f017299c59446efbdd4c505 100644 (file)
@@ -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) {
index a4d43fa4712bc9d88902b894aef42f4bc03e4872..c351ae505f468895563865127f3824af2a29217d 100644 (file)
@@ -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() {
index 4494a661937600b6506cae256e6730088251a5e0..edcba82c9f57ec201878076d023df4f7f774a3b2 100644 (file)
@@ -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 (file)
index 0000000..7b1aa76
--- /dev/null
@@ -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 (file)
index 0000000..647bd72
--- /dev/null
@@ -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;
+       }
+}
index fdd6f10a42366ad9a037120260cdeff05ffd3345..a84821aabd25833f7bb7d2947e3537d1566d605d 100644 (file)
@@ -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() {
index 44c65430a437b2d731bea66904ac373fa80c95e0..9c4c08fdc6ecc2d37c053183e3205b9f5ed534e6 100644 (file)
@@ -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 (file)
index 0000000..42dc6f8
--- /dev/null
@@ -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
index fa0cff9c55059f634f2dcc7b9d50502c1be6d851..a528692bdae442a8af52abd87c7f84918dbbb3f5 100644 (file)
@@ -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 (file)
index 0000000..ff0f192
--- /dev/null
@@ -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;
+       }
+}