]> source.dussan.org Git - aspectj.git/commitdiff
FindBugs: fixes.
authoraclement <aclement>
Mon, 23 Aug 2004 15:09:26 +0000 (15:09 +0000)
committeraclement <aclement>
Mon, 23 Aug 2004 15:09:26 +0000 (15:09 +0000)
ajbrowser/src/org/aspectj/tools/ajbrowser/BasicEditor.java
ajde/src/org/aspectj/ajde/internal/CompilerAdapter.java
ajde/src/org/aspectj/ajde/internal/LstBuildConfigFileUpdater.java
ajde/src/org/aspectj/ajde/ui/StructureModelUtil.java
ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java
ajde/src/org/aspectj/ajde/ui/swing/BuildOptionsPanel.java
ajde/testsrc/org/aspectj/ajde/ReweavableTestCase.java
weaver/testsrc/org/aspectj/weaver/bcel/WeaveTestCase.java
weaver/testsrc/org/aspectj/weaver/patterns/ConcretizationTestCase.java

index 720ed65fd6e5155854f68f18500e8095fc2fac8f..f5a0fa4aeb1e094f565453df9a712e87eb5b25c9 100644 (file)
@@ -123,10 +123,10 @@ public class BasicEditor implements EditorAdapter {
        }
 
     public void saveContents() throws IOException {
-        if (filePath != NO_FILE && filePath != "" && editorPane.getText() != "") {
+        if (!filePath.equals(NO_FILE) && !filePath.equals("") && !editorPane.getText().equals("")) {
             BufferedWriter writer = new BufferedWriter(new FileWriter(filePath));
             writer.write(editorPane.getText());
-            writer.flush();
+            writer.close();
         }
     }
 
@@ -169,6 +169,7 @@ public class BasicEditor implements EditorAdapter {
                 contents.append('\n');
                 line = reader.readLine();
             }
+            reader.close();
             return contents.toString();
         } catch (IOException ioe) {
             return "ERROR: could not read file \"" + filePath + "\", make sure that you have mounted /project/aop on X:\\";
index f98e08c0edaad40e2435d1d0577f990d311ce96d..26cfe8894c775e00d0cbd85b2a14c63fae101f11 100644 (file)
@@ -95,10 +95,10 @@ public class CompilerAdapter {
                init();
                try { 
                        AjBuildConfig buildConfig = genBuildConfig(configFile);
-                       buildConfig.setGenerateModelMode(buildModel);
-                       if (null == buildConfig) {
+                       if (buildConfig == null) {
                 return false;
                        }
+                       buildConfig.setGenerateModelMode(buildModel);
                        currNotifier = new BuildNotifierAdapter(progressMonitor, buildManager);         
                        buildManager.setProgressListener(currNotifier);
                        messageHandler.setBuildNotifierAdapter(currNotifier);
index dc87ccb79fa87cc5f28ff9bcb43089d27ad66c50..443ef41dc38706d279e05ad32fdf6fc71717db92 100644 (file)
@@ -105,6 +105,7 @@ class LstBuildConfigFileUpdater {
                 fileContents.add(line.replace('\\', '/'));
                 line = reader.readLine();
             }
+            reader.close();
             return fileContents;
         } catch (IOException ioe) {
             Ajde.getDefault().getErrorHandler().handleError("Could not update build config file.", ioe);
@@ -193,13 +194,15 @@ class LstBuildConfigFileUpdater {
     }
     
     private void writeFile(String contents, String filePath) {
+       FileOutputStream fos = null;
         try {
-            FileOutputStream fos = new FileOutputStream(filePath, false);
+            fos = new FileOutputStream(filePath, false);
             fos.write(contents.getBytes());
-            fos.close();
         } catch (IOException ioe) {
             Ajde.getDefault().getErrorHandler().handleError("Could not update build config file: " + filePath, ioe);
-        }      
+        } finally {
+               if (fos!=null) try {fos.close();} catch (IOException ioe) {}
+        }
     }
 }
 
index a0e1cf4bf697a0d2ce53f3acdcee7ef16858a3c6..61ba5f9ee6356e39a5336a45358b75e659b3bc8f 100644 (file)
@@ -166,7 +166,7 @@ public class StructureModelUtil {
                List packages = new ArrayList();
                IHierarchy model =
                        Ajde.getDefault().getStructureModelManager().getHierarchy();
-               if (model.equals(IHierarchy.NO_STRUCTURE)) {
+               if (model.getRoot().equals(IHierarchy.NO_STRUCTURE)) {
                        return null;
                } else {
                        return getPackagesHelper(
index 1421a7a0428fcc40ae249f8341a8fb18345eb297..36c047bf4dbb8b3df8e69e4aec001c3b5b2298c2 100644 (file)
@@ -55,15 +55,16 @@ public class StructureSearchManager {
                                matches.add(node);      
                        } 
                }
-               
-               for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
-                       IProgramElement nextNode = (IProgramElement)it.next();
-                       if (nextNode instanceof IProgramElement) {
-                               findMatchesHelper(
-                                       (IProgramElement)nextNode, 
-                                       pattern, 
-                                       kind,
-                                       matches);               
+               if (node.getChildren() != null) {
+                       for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
+                               IProgramElement nextNode = (IProgramElement)it.next();
+                               if (nextNode instanceof IProgramElement) {
+                                       findMatchesHelper(
+                                                       (IProgramElement)nextNode, 
+                                                       pattern, 
+                                                       kind,
+                                                       matches);
+                               }
                        }
                }
                 
index e8866d985c0c621a7061d239220f3409e6743446..ef1f3258439fd1b9ff379be65f16c5c6e63c0ff5 100644 (file)
@@ -32,7 +32,7 @@ public class BuildOptionsPanel extends OptionsPanel {
                + "AspectJ compiler.  The Document Outline View will fail to refresh correctly when\n"
                + "incremental mode is enabled.  Submit any other bugs at http://eclipse.org/aspectj";
 
-       protected static BuildOptionsPanel INSTANCE = new BuildOptionsPanel();
+       protected static final BuildOptionsPanel INSTANCE = new BuildOptionsPanel();
 
 //     private ButtonGroup compilerMode_buttonGroup = new ButtonGroup();
        private TitledBorder titledBorder1;
index c1a6c05c147d5de05b0ffaa66bc1c53ae2140df8..fd0ef0c737516f1a07f6c5384eb49c0778f803c5 100644 (file)
@@ -34,10 +34,10 @@ public class ReweavableTestCase extends AjdeTestCase {
        public static final String outjarName = "/bin/output.jar";
 
 
-       public static int nonreweavesize_CalculatePI;
-       public static int nonreweavesize_Logger;
-       public static int reweavablesize_CalculatePI;
-       public static int reweavablesize_Logger;
+       private static int nonreweavesize_CalculatePI;
+       private static int nonreweavesize_Logger;
+       private static int reweavablesize_CalculatePI;
+       private static int reweavablesize_Logger;
                        
        /**
         * Constructor for JarResourceCopyTestCase.
index c186624f0c5a515923ef2637b1e4eba61c0a5ad6..9a7a4e7b0262564fd3ca8cf13df6417cab1ed0a1 100644 (file)
@@ -42,7 +42,8 @@ public abstract class WeaveTestCase extends TestCase {
         outDir = BcweaverTests.getOutdir();
         outDirPath = outDir.getAbsolutePath();
     }
-    public void tearDown() {
+    public void tearDown() throws Exception {
+       super.tearDown();
         BcweaverTests.removeOutDir();
         outDir = null;
         outDirPath = null;
index 8bf41f7502b469521957ba01f0b3708c84dccd3d..e6655d80d2bf724a9050e81934be8c4223250de6 100644 (file)
@@ -24,7 +24,7 @@ public class ConcretizationTestCase extends WeaveTestCase {
                super(name);
        }
                
-    String[] none = new String[0];
+   // String[] none = new String[0];