From: mkersten Date: Fri, 8 Aug 2003 13:14:39 +0000 (+0000) Subject: Fixed ProgramElement modifiers bug. X-Git-Tag: V1_1_1~116 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=18f9c1e2dbd6533e1e939871a6129ed1a95800e8;p=aspectj.git Fixed ProgramElement modifiers bug. --- diff --git a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java index d04af28af..9f19770b4 100644 --- a/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java +++ b/ajde/src/org/aspectj/ajde/ui/swing/SwingTreeViewNodeRenderer.java @@ -69,7 +69,6 @@ class SwingTreeViewNodeRenderer extends DefaultTreeCellRenderer { // if (pNode.isOverrider()) { // //this.setText(""); // } - if (node.getMessage() != null) { if (node.getMessage().getKind().equals(IMessage.WARNING)) { setIcon(AjdeUIManager.getDefault().getIconRegistry().getWarningIcon()); diff --git a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java index e6be0bc12..dfcd03dc1 100644 --- a/ajde/testsrc/org/aspectj/ajde/AjdeTests.java +++ b/ajde/testsrc/org/aspectj/ajde/AjdeTests.java @@ -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; diff --git a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java index 8c2c2003d..8a1952cce 100644 --- a/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java +++ b/ajde/testsrc/org/aspectj/ajde/StructureModelTest.java @@ -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); diff --git a/asm/src/org/aspectj/asm/IProgramElement.java b/asm/src/org/aspectj/asm/IProgramElement.java index 24132f55d..17f16aa87 100644 --- a/asm/src/org/aspectj/asm/IProgramElement.java +++ b/asm/src/org/aspectj/asm/IProgramElement.java @@ -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. diff --git a/asm/src/org/aspectj/asm/internal/ProgramElement.java b/asm/src/org/aspectj/asm/internal/ProgramElement.java index 5fd769e02..eec6389e2 100644 --- a/asm/src/org/aspectj/asm/internal/ProgramElement.java +++ b/asm/src/org/aspectj/asm/internal/ProgramElement.java @@ -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); + } + } 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 1cdc99870..b7fd8d1be 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 @@ -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; }