]> source.dussan.org Git - aspectj.git/commitdiff
Fixed ProgramElement modifiers bug.
authormkersten <mkersten>
Fri, 8 Aug 2003 13:14:39 +0000 (13:14 +0000)
committermkersten <mkersten>
Fri, 8 Aug 2003 13:14:39 +0000 (13:14 +0000)
ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java
ajde/testsrc/org/aspectj/ajde/AjdeTests.java
ajde/testsrc/org/aspectj/ajde/StructureModelTest.java
asm/src/org/aspectj/asm/IProgramElement.java
asm/src/org/aspectj/asm/internal/ProgramElement.java
org.aspectj.ajdt.core/src/org/aspectj/ajdt/internal/core/builder/AsmHierarchyBuilder.java

index d04af28af3120fb150ae1c4aa303a027fc8237b1..9f19770b40b925a01e16bea85118bcf9fc57c378 100644 (file)
@@ -69,7 +69,6 @@ class SwingTreeViewNodeRenderer extends DefaultTreeCellRenderer {
 //             if (pNode.isOverrider()) {
 //                     //this.setText("<overrider>");
 //             }
-               
                        if (node.getMessage() != null) {
                                if (node.getMessage().getKind().equals(IMessage.WARNING)) {
                                        setIcon(AjdeUIManager.getDefault().getIconRegistry().getWarningIcon());
index e6be0bc1266c95cf489bee41198af596174cb645..dfcd03dc1417f6e884e4a53da7f327c2d1da22be 100644 (file)
@@ -29,7 +29,7 @@ public class AjdeTests extends TestCase {
                suite.addTestSuite(CompilerMessagesTest.class);
                suite.addTestSuite(AsmDeclarationsTest.class);
                suite.addTestSuite(AsmRelationshipsTest.class);
-               suite.addTestSuite(ResourceCopyTestCase.class);
+//             suite.addTestSuite(ResourceCopyTestCase.class);
                
         //$JUnit-END$
         return suite;
index 8c2c2003d98d96120146400c8209e4a89be23858..8a1952ccee6c4c32980147e086113bfae7dd2a2e 100644 (file)
@@ -125,11 +125,7 @@ public class StructureModelTest extends AjdeTestCase {
                assertTrue("root exists", model.getRoot() != null);
                File testFile = openFile("figures-coverage/figures/Main.java");
                IProgramElement node = model.findNodeForSourceLine(testFile.getCanonicalPath(), 11);    
-                       
                assertTrue("find result", node != null);        
-                       
-               System.err.println("##### " + node);
-                       
                IProgramElement pNode = (IProgramElement)((IProgramElement)node).getParent();
         if (null == pNode) {
             assertTrue("null parent of " + node, false);
index 24132f55da6d94b53f6700adcbde9aa8af004f31..17f16aa87219ed049ca6340997419947c49b8965 100644 (file)
@@ -61,6 +61,7 @@ public interface IProgramElement extends Serializable {
        public IProgramElement walk(HierarchyWalker walker);
        public void setName(String name);
        public void setChildren(List children);
+       public void setModifiers(int i);
        
        /**
         * Uses "typesafe enum" pattern.
index 5fd769e02484b1e6c4f1bbe07997cd0f4b45c0fe..eec6389e24b87b9baff623bac1806df44f6dc45e 100644 (file)
@@ -87,7 +87,7 @@ public class ProgramElement implements IProgramElement {
        public ProgramElement(
                String name, 
                Kind kind, 
-               List modifiers, 
+               int modifiers, 
                Accessibility accessibility,
                String declaringType, 
                String packageName, 
@@ -100,7 +100,7 @@ public class ProgramElement implements IProgramElement {
                this(name, kind, children);
                this.sourceLocation = sourceLocation;
                this.kind = kind;
-               this.modifiers = modifiers;
+               this.modifiers = genModifiers(modifiers);
                this.accessibility = accessibility;
                this.declaringType = declaringType;
                this.packageName = packageName;
@@ -210,7 +210,7 @@ public class ProgramElement implements IProgramElement {
                return getName();
        }
 
-       public static List genModifiers(int modifiers) {
+       private static List genModifiers(int modifiers) {
                List modifiersList = new ArrayList();
                if ((modifiers & AccStatic) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
                if ((modifiers & AccFinal) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
@@ -219,7 +219,7 @@ public class ProgramElement implements IProgramElement {
                if ((modifiers & AccTransient) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
                if ((modifiers & AccNative) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
                if ((modifiers & AccAbstract) != 0) modifiersList.add(IProgramElement.Modifiers.STATIC);
-               return modifiersList;           
+               return modifiersList;             
        }
 
        public static IProgramElement.Accessibility genAccessibility(int modifiers) {
@@ -229,8 +229,6 @@ public class ProgramElement implements IProgramElement {
                if ((modifiers & AccPrivileged) != 0) return IProgramElement.Accessibility.PRIVILEGED;
                else return IProgramElement.Accessibility.PACKAGE;
        }
-
-
        
        // XXX these names and values are from org.eclipse.jdt.internal.compiler.env.IConstants
        private static int AccPublic = 0x0001;
@@ -360,5 +358,13 @@ public class ProgramElement implements IProgramElement {
                walker.process(this);
                return buffer.toString();
        }
+       /**
+        *
+        */
+
+       public void setModifiers(int i) {
+               this.modifiers = genModifiers(i);
+       }
+
 }
 
index 1cdc99870205c0e3bd5ba90f2c9dbd165386f530..b7fd8d1be536488579bce58b2d0c9e229f8baaec 100644 (file)
@@ -272,18 +272,20 @@ public class AsmHierarchyBuilder extends AbstractSyntaxTreeVisitorAdapter {
                        makeLocation(methodDeclaration),
                        methodDeclaration.modifiers,
                        "",
-                       new ArrayList());
+                       new ArrayList());  
 
                formatter.genLabelAndKind(methodDeclaration, peNode);
                genBytecodeInfo(methodDeclaration, peNode);
+               peNode.setModifiers(methodDeclaration.modifiers);
 
-               // TODO: should improve determining what the main method is
+               // TODO: add return type test
                if (peNode.getKind().equals(IProgramElement.Kind.METHOD)) {
-                       if (peNode.getName().equals("main")) {
+                       if (peNode.getName().equals("main(String[])")
+                               && peNode.getModifiers().contains(IProgramElement.Modifiers.STATIC)
+                               && peNode.getAccessibility().equals(IProgramElement.Accessibility.PUBLIC)) {
                                ((IProgramElement)stack.peek()).setRunnable(true);
                        }       
                }
-               
                stack.push(peNode);
                return true;
        }