From 7a013ac10b7454b2058462f2ad715fb078337bda Mon Sep 17 00:00:00 2001 From: aclement Date: Wed, 27 Aug 2008 00:39:24 +0000 Subject: [PATCH] findbugs/eclipse warnings fixed --- .../core/internal/AjdeCoreBuildManager.java | 49 ++++++------------- .../core/tests/CompilerMessagesTests.java | 2 +- .../ajde/core/tests/ResourceCopyTests.java | 2 - .../tests/model/AsmDeclarationsTests.java | 14 ++---- .../tests/model/AsmRelationshipsTests.java | 4 -- .../core/tests/model/StructureModelTests.java | 14 ++---- 6 files changed, 24 insertions(+), 61 deletions(-) diff --git a/ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java b/ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java index a1ae7a588..c1075c64d 100644 --- a/ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java +++ b/ajde.core/src/org/aspectj/ajde/core/internal/AjdeCoreBuildManager.java @@ -21,7 +21,6 @@ import java.util.StringTokenizer; import org.aspectj.ajde.core.AjCompiler; import org.aspectj.ajde.core.ICompilerConfiguration; import org.aspectj.ajde.core.IOutputLocationManager; -import org.aspectj.ajde.core.JavaOptions; import org.aspectj.ajdt.ajc.AjdtCommand; import org.aspectj.ajdt.ajc.BuildArgParser; import org.aspectj.ajdt.ajc.ConfigParser; @@ -88,14 +87,26 @@ public class AjdeCoreBuildManager { handleMessage(new Message(getFormattedOptionsString(),IMessage.INFO,null,null)); CompilationAndWeavingContext.reset(); + AjBuildConfig buildConfig = genAjBuildConfig(); if (buildConfig == null) return; - + + if (buildFresh) { + ajBuildManager.batchBuild(buildConfig,msgHandlerAdapter); + } else { + ajBuildManager.incrementalBuild(buildConfig,msgHandlerAdapter); + } +/* if (buildFresh) { + AjBuildConfig buildConfig = genAjBuildConfig(); + if (buildConfig == null) return; ajBuildManager.batchBuild(buildConfig,msgHandlerAdapter); } else { + AjBuildConfig buildConfig = ajBuildManager.getState().getBuildConfig(); + ajBuildManager.incrementalBuild(buildConfig,msgHandlerAdapter); } +*/ IncrementalStateManager.recordSuccessfulBuild(compiler.getId(),ajBuildManager.getState()); } catch (ConfigParser.ParseException pe) { @@ -109,7 +120,7 @@ public class AjdeCoreBuildManager { } else { handleMessage(new Message(message.getMessage() + "\n" + CompilationAndWeavingContext.getCurrentContext(),IMessage.ERROR,e,null)); - }; + } } catch (Throwable t) { handleMessage(new Message("Compile error: " + LangUtil.unqualifiedClassName(t) + " thrown: " + "" + t.getMessage(),IMessage.ABORT,t,null)); @@ -235,38 +246,6 @@ public class AjdeCoreBuildManager { return config; } - /** - * Check that the user hasn't specified Java 6 for the compliance, source and - * target levels. If they have then an error is thrown. - */ - private void checkNotAskedForJava6Compliance() { - // bug 164384 - Throwing an IMessage.ERRROR rather than an IMessage.ABORT - // means that we'll continue to try to compile the code. This means that - // the user may see other errors (for example, if they're using annotations - // then they'll get errors saying that they require 5.0 compliance). - // Throwing IMessage.ABORT would prevent this, however, 'abort' is really - // for compiler exceptions. - Map javaOptions = compiler.getCompilerConfiguration().getJavaOptionsMap(); - if (javaOptions != null){ - String version = (String)javaOptions.get(CompilerOptions.OPTION_Compliance); - String sourceVersion = (String)javaOptions.get(CompilerOptions.OPTION_Source); - String targetVersion = (String)javaOptions.get(CompilerOptions.OPTION_TargetPlatform); - if (version!=null && version.equals(JavaOptions.VERSION_16)) { - String msg = "Java 6.0 compliance level is unsupported"; - IMessage m = new Message(msg, IMessage.ERROR, null, null); - compiler.getMessageHandler().handleMessage(m); - } else if (sourceVersion!=null && sourceVersion.equals(JavaOptions.VERSION_16)) { - String msg = "Java 6.0 source level is unsupported"; - IMessage m = new Message(msg, IMessage.ERROR, null, null); - compiler.getMessageHandler().handleMessage(m); - } else if (targetVersion!=null && targetVersion.equals(JavaOptions.VERSION_16)) { - String msg = "Java 6.0 target level is unsupported"; - IMessage m = new Message(msg, IMessage.ERROR, null, null); - compiler.getMessageHandler().handleMessage(m); - } - } - } - /** * Configure the given AjBuildConfig with the options found in the * ICompilerConfiguration implementation associated with the AjCompiler diff --git a/ajde.core/testsrc/org/aspectj/ajde/core/tests/CompilerMessagesTests.java b/ajde.core/testsrc/org/aspectj/ajde/core/tests/CompilerMessagesTests.java index dda92a5b0..220276101 100644 --- a/ajde.core/testsrc/org/aspectj/ajde/core/tests/CompilerMessagesTests.java +++ b/ajde.core/testsrc/org/aspectj/ajde/core/tests/CompilerMessagesTests.java @@ -70,7 +70,7 @@ public class CompilerMessagesTests extends AjdeCoreTestCase { public void testDeclareMessageContents() { List msgs = handler.getMessages(); - IMessage msg = (IMessage)((TestMessageHandler.TestMessage)msgs.get(1)).getContainedMessage(); + IMessage msg = ((TestMessageHandler.TestMessage)msgs.get(1)).getContainedMessage(); assertEquals( "Please don't call setters" , msg.getMessage()); assertEquals("field-set(int apackage.SomeClass.x)", msg.getDetails()); } diff --git a/ajde.core/testsrc/org/aspectj/ajde/core/tests/ResourceCopyTests.java b/ajde.core/testsrc/org/aspectj/ajde/core/tests/ResourceCopyTests.java index 0542899a2..11ffd3481 100644 --- a/ajde.core/testsrc/org/aspectj/ajde/core/tests/ResourceCopyTests.java +++ b/ajde.core/testsrc/org/aspectj/ajde/core/tests/ResourceCopyTests.java @@ -39,7 +39,6 @@ public class ResourceCopyTests extends AjdeCoreTestCase { private TestMessageHandler handler; private TestCompilerConfiguration compilerConfig; - private String testProps; private String[] config1 = new String[] { "src" + File.separator + "Main.java", @@ -56,7 +55,6 @@ public class ResourceCopyTests extends AjdeCoreTestCase { handler = (TestMessageHandler) getCompiler().getMessageHandler(); compilerConfig = (TestCompilerConfiguration) getCompiler() .getCompilerConfiguration(); - testProps = getAbsoluteProjectDir() + File.separator + "src" + File.separator + "testsrc" + File.separator + "test.props"; } protected void tearDown() throws Exception { diff --git a/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmDeclarationsTests.java b/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmDeclarationsTests.java index 2772cec2f..bc84f85eb 100644 --- a/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmDeclarationsTests.java +++ b/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmDeclarationsTests.java @@ -13,7 +13,6 @@ import java.io.File; import org.aspectj.ajde.core.AjdeCoreTestCase; import org.aspectj.ajde.core.TestCompilerConfiguration; -import org.aspectj.ajde.core.TestMessageHandler; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IHierarchy; import org.aspectj.asm.IProgramElement; @@ -27,13 +26,11 @@ public class AsmDeclarationsTests extends AjdeCoreTestCase { "pkg" + File.separator + "InPackage.java" }; - private TestMessageHandler handler; private TestCompilerConfiguration compilerConfig; protected void setUp() throws Exception { super.setUp(); initialiseProject("coverage"); - handler = (TestMessageHandler) getCompiler().getMessageHandler(); compilerConfig = (TestCompilerConfiguration) getCompiler() .getCompilerConfiguration(); compilerConfig.setProjectSourceFiles(getSourceFileList(files)); @@ -43,13 +40,12 @@ public class AsmDeclarationsTests extends AjdeCoreTestCase { protected void tearDown() throws Exception { super.tearDown(); - handler = null; compilerConfig = null; model = null; } public void testRoot() { - IProgramElement root = (IProgramElement)model.getRoot(); + IProgramElement root = model.getRoot(); assertNotNull(root); assertEquals("Expected root to be named 'coverage' but found " + root.toLabelString(), root.toLabelString(), "coverage"); @@ -124,7 +120,7 @@ public class AsmDeclarationsTests extends AjdeCoreTestCase { } public void testInterTypeMemberDeclares() { - IProgramElement node = (IProgramElement)model.getRoot(); + IProgramElement node = model.getRoot(); assertNotNull(node); IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "InterTypeDecCoverage"); @@ -148,7 +144,7 @@ public class AsmDeclarationsTests extends AjdeCoreTestCase { } public void testPointcuts() { - IProgramElement node = (IProgramElement)model.getRoot(); + IProgramElement node = model.getRoot(); assertNotNull(node); IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage"); @@ -166,7 +162,7 @@ public class AsmDeclarationsTests extends AjdeCoreTestCase { } public void testAbstract() { - IProgramElement node = (IProgramElement)model.getRoot(); + IProgramElement node = model.getRoot(); assertNotNull(node); IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AbstractAspect"); @@ -179,7 +175,7 @@ public class AsmDeclarationsTests extends AjdeCoreTestCase { } public void testAdvice() { - IProgramElement node = (IProgramElement)model.getRoot(); + IProgramElement node = model.getRoot(); assertNotNull(node); IProgramElement aspect = AsmManager.getDefault().getHierarchy().findElementForType(null, "AdviceNamingCoverage"); diff --git a/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmRelationshipsTests.java b/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmRelationshipsTests.java index fca358138..919eec6e3 100644 --- a/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmRelationshipsTests.java +++ b/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/AsmRelationshipsTests.java @@ -16,7 +16,6 @@ import java.util.List; import org.aspectj.ajde.core.AjdeCoreTestCase; import org.aspectj.ajde.core.TestCompilerConfiguration; -import org.aspectj.ajde.core.TestMessageHandler; import org.aspectj.ajdt.internal.core.builder.AsmHierarchyBuilder; import org.aspectj.asm.AsmManager; import org.aspectj.asm.IProgramElement; @@ -31,13 +30,11 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase { "pkg" + File.separator + "InPackage.java" }; - private TestMessageHandler handler; private TestCompilerConfiguration compilerConfig; protected void setUp() throws Exception { super.setUp(); initialiseProject("coverage"); - handler = (TestMessageHandler) getCompiler().getMessageHandler(); compilerConfig = (TestCompilerConfiguration) getCompiler() .getCompilerConfiguration(); compilerConfig.setProjectSourceFiles(getSourceFileList(files)); @@ -47,7 +44,6 @@ public class AsmRelationshipsTests extends AjdeCoreTestCase { protected void tearDown() throws Exception { super.tearDown(); - handler = null; compilerConfig = null; manager = null; } diff --git a/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/StructureModelTests.java b/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/StructureModelTests.java index 8d9a7f836..397ac7fdf 100644 --- a/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/StructureModelTests.java +++ b/ajde.core/testsrc/org/aspectj/ajde/core/tests/model/StructureModelTests.java @@ -19,7 +19,6 @@ import java.util.Iterator; import org.aspectj.ajde.core.AjdeCoreTestCase; import org.aspectj.ajde.core.TestCompilerConfiguration; -import org.aspectj.ajde.core.TestMessageHandler; import org.aspectj.asm.AsmManager; import org.aspectj.asm.HierarchyWalker; import org.aspectj.asm.IHierarchy; @@ -40,13 +39,11 @@ public class StructureModelTests extends AjdeCoreTestCase { "figures" + File.separator + "primitives" + File.separator + "solid" + File.separator + "SolidPoint.java" }; - private TestMessageHandler handler; private TestCompilerConfiguration compilerConfig; protected void setUp() throws Exception { super.setUp(); initialiseProject("figures-coverage"); - handler = (TestMessageHandler) getCompiler().getMessageHandler(); compilerConfig = (TestCompilerConfiguration) getCompiler() .getCompilerConfiguration(); compilerConfig.setProjectSourceFiles(getSourceFileList(files)); @@ -56,7 +53,6 @@ public class StructureModelTests extends AjdeCoreTestCase { protected void tearDown() throws Exception { super.tearDown(); - handler = null; compilerConfig = null; manager = null; } @@ -66,8 +62,7 @@ public class StructureModelTests extends AjdeCoreTestCase { IProgramElement node = manager.getHierarchy().findElementForSourceFile( testFile.getAbsolutePath()); assertTrue("find result", node != null) ; - IProgramElement pNode = (IProgramElement)node; - String child = ((IProgramElement)pNode.getChildren().get(1)).getName(); + String child = ((IProgramElement)node.getChildren().get(1)).getName(); assertTrue("expected Figure got child " + child, child.equals("Figure")); } @@ -76,7 +71,7 @@ public class StructureModelTests extends AjdeCoreTestCase { IProgramElement node = manager.getHierarchy().findElementForSourceFile( testFile.getAbsolutePath()); assertTrue("find result", node != null) ; - IProgramElement pNode = (IProgramElement)((IProgramElement)node).getChildren().get(2); + IProgramElement pNode = (IProgramElement)(node).getChildren().get(2); IProgramElement pointcut = (IProgramElement)pNode.getChildren().get(0); assertTrue("kind", pointcut.getKind().equals(IProgramElement.Kind.POINTCUT)); assertTrue("found node: " + pointcut.getName(), pointcut.toLabelString().equals("testptct()")); @@ -92,8 +87,7 @@ public class StructureModelTests extends AjdeCoreTestCase { testFile.getAbsolutePath(), 1); assertTrue("find result", node != null) ; assertEquals("find result has children", 3, node.getChildren().size()) ; - IProgramElement pNode = (IProgramElement)node; - assertTrue("found node: " + pNode.getName(), pNode.getKind().equals(IProgramElement.Kind.FILE_JAVA)); + assertTrue("found node: " + node.getName(), node.getKind().equals(IProgramElement.Kind.FILE_JAVA)); } /** @@ -106,7 +100,7 @@ public class StructureModelTests extends AjdeCoreTestCase { File testFile = openFile("figures" + File.separator + "Main.java"); IProgramElement node = model.findElementForSourceLine(testFile.getAbsolutePath(), 11); assertTrue("find result", node != null); - IProgramElement pNode = (IProgramElement)((IProgramElement)node).getParent(); + IProgramElement pNode = node.getParent(); if (null == pNode) { assertTrue("null parent of " + node, false); } -- 2.39.5