]> source.dussan.org Git - aspectj.git/commitdiff
findbugs/eclipse warnings fixed
authoraclement <aclement>
Wed, 27 Aug 2008 00:38:04 +0000 (00:38 +0000)
committeraclement <aclement>
Wed, 27 Aug 2008 00:38:04 +0000 (00:38 +0000)
17 files changed:
ajde/src/org/aspectj/ajde/Ajde.java
ajde/src/org/aspectj/ajde/internal/LstBuildConfigManager.java
ajde/src/org/aspectj/ajde/ui/AbstractIconRegistry.java
ajde/src/org/aspectj/ajde/ui/BuildConfigModel.java
ajde/src/org/aspectj/ajde/ui/BuildConfigNode.java
ajde/src/org/aspectj/ajde/ui/StructureSearchManager.java
ajde/src/org/aspectj/ajde/ui/StructureView.java
ajde/src/org/aspectj/ajde/ui/StructureViewManager.java
ajde/src/org/aspectj/ajde/ui/internal/TreeStructureViewBuilder.java
ajde/src/org/aspectj/ajde/ui/internal/UserPreferencesStore.java
ajde/src/org/aspectj/ajde/ui/swing/BrowserViewPanel.java
ajde/src/org/aspectj/ajde/ui/swing/BrowserViewTreeListener.java
ajde/src/org/aspectj/ajde/ui/swing/CompilerMessagesCellRenderer.java
ajde/src/org/aspectj/ajde/ui/swing/OptionsFrame.java
ajde/src/org/aspectj/ajde/ui/swing/StructureTreeManager.java
ajde/src/org/aspectj/ajde/ui/swing/StructureViewPanel.java
ajde/src/org/aspectj/ajde/ui/swing/TreeViewBuildConfigEditor.java

index 0ce1fa7ce2d8d037445d71b5e634235b0e084fd3..6191b60d8f12b9d6ef5c60f59499798fb2f6548d 100644 (file)
@@ -225,7 +225,7 @@ public class Ajde {
                                } else if (0 != result) {
                                        String m = "Result of running " + context;
                                        uiBuildMsgHandler.handleMessage(new Message(m,
-                                                       IMessage.ERROR, thrown, null));
+                                                       IMessage.ERROR, null, null));
                                }
                                if (null != any.fromInPipe) {
                                        String m = "Error processing input pipe for " + context;
@@ -245,8 +245,7 @@ public class Ajde {
                        }
                };
 
-               controller = LangUtil.makeProcess(controller, props.classpath,
-                               props.mainClass, props.args);
+               controller = LangUtil.makeProcess(controller, props.classpath, props.mainClass, props.args);
 
                command.append(Arrays.asList(controller.getCommand()).toString());
 
@@ -347,7 +346,7 @@ public class Ajde {
                compilerThread.start();
        }
 
-       class CompilerThread extends Thread {
+       static class CompilerThread extends Thread {
 
                private AjCompiler compiler;
                private boolean buildFresh;
@@ -505,8 +504,7 @@ public class Ajde {
        public AjCompiler getCompilerForConfigFile(String configFile) {
                if (configFile == null)
                        return null;
-               if ((compiler == null || !compiler.getId().equals(configFile))
-                               && configFile != null) {
+               if ((compiler == null || !compiler.getId().equals(configFile))) {
                        if (compiler != null) {
                                // have to remove the incremental state of the previous
                                // compiler - this will remove it from the
index d66d40c597a6113a8e4dcb10e26b4bf179c14551..c0ff8b8a97d2bf7ea27b24111faca247f3b03e57 100644 (file)
@@ -87,7 +87,7 @@ public class LstBuildConfigManager implements BuildConfigManager {
         addFilesToDirTree(model, relativePaths, badEntries);
         
         pruneEmptyDirs(root);
-        sortModel((BuildConfigNode)model.getRoot(), ALPHABETICAL_COMPARATOR);
+        sortModel(model.getRoot(), ALPHABETICAL_COMPARATOR);
         //addImportedFilesToDirTree(model, importedFiles);
         
         addProblemEntries(root, badEntries);
index 8a0ed8b4031393ac5bdafe7443694924ca54c339..742cc1a6b1e8a58992547b09f95c614434078e55 100644 (file)
@@ -76,9 +76,7 @@ public abstract class AbstractIconRegistry {
        /**
         * @return      null if the kind could not be resolved
         */
-       protected AbstractIcon getStructureIcon(IProgramElement.Kind kind, IProgramElement.Accessibility accessibility) {
-               return getStructureIcon(kind, IProgramElement.Accessibility.PUBLIC);
-       }       
+       protected abstract AbstractIcon getStructureIcon(IProgramElement.Kind kind, IProgramElement.Accessibility accessibility);
        
        /**
         * Assumes "public" visibility for the icon.
index e682a6204dec2db6a3b882a9e733da317945be36..01ef07bd37ba1e9a4f3d0d0d7daedf03cc7bcf20 100644 (file)
@@ -42,8 +42,7 @@ public class BuildConfigModel {
                        return upPathMatch;
                } else {
                        StringTokenizer st = new StringTokenizer(path, "/");
-                       BuildConfigNode node = (BuildConfigNode)root;
-                       return getNodeForPathHelper(st, node);
+                       return getNodeForPathHelper(st, root);
                }
        }
 
@@ -72,7 +71,7 @@ public class BuildConfigModel {
        
        public List getActiveNodes(BuildConfigNode.Kind kind) {
                List nodes = new ArrayList();
-               getActiveNodesHelper((BuildConfigNode)getRoot(), kind, nodes);
+               getActiveNodesHelper(root, kind, nodes);
                return nodes;
        }
 
@@ -134,8 +133,7 @@ public class BuildConfigModel {
                                && ((node.getSourceLocation().getLine() <= lineNumber
                                        && node.getSourceLocation().getEndLine() >= lineNumber)
                                        ||
-                                       (lineNumber <= 1
-                                        && node instanceof BuildConfigNode)    
+                                       (lineNumber <= 1)       
                                );
                } catch (IOException ioe) { 
                        return false;
index 94e92a87f8b77e1406f462aee28c0d6e710d468e..c80f49b4d5e2d432f02f2a1c13e93e29c37e983e 100644 (file)
@@ -100,12 +100,11 @@ public class BuildConfigNode {
         * Comparison is string-name based only.
         */
        public int compareTo(Object o) throws ClassCastException {
-               if (this == o) {
-                       return 0;
-               } else {
+               if (o instanceof BuildConfigNode) {
                        BuildConfigNode sn = (BuildConfigNode)o;
                        return this.getName().compareTo(sn.getName());
                }
+               return -1;
        }
 
        public String getName() {
@@ -197,9 +196,15 @@ public class BuildConfigNode {
                        return name;
                }       
                
-               public boolean equals(Object o) {
-                       return o.equals(name);  
-               }
+//             public boolean equals(Object o) {
+//                     return (o instanceof Kind? this==o : false);
+////                   return o.equals(name);  
+//             }
+//             
+//             public int hashCode() {
+//                     return ordinal;
+////                   return name.hashCode();
+//             }
                
                public boolean isDeclareKind() {
                        return name.startsWith("declare");      
index 5ec11e6a4d50be60d86c6d8bb09293e9d70698da..143c7ae528e866db54563b305d84c08da0e8695c 100644 (file)
@@ -39,10 +39,10 @@ public class StructureSearchManager {
                
                List matches = new ArrayList();
                IHierarchy model = AsmManager.getDefault().getHierarchy();
-               if (model.equals(IHierarchy.NO_STRUCTURE)) {
+               if (model.getRoot().equals(IHierarchy.NO_STRUCTURE)) {
                        return null;
                } else {
-                       return findMatchesHelper((IProgramElement)model.getRoot(), pattern, kind, matches);
+                       return findMatchesHelper(model.getRoot(), pattern, kind, matches);
                }
        }                                       
        
@@ -61,9 +61,9 @@ public class StructureSearchManager {
                if (node != null && node.getChildren() != null) {
                        for (Iterator it = node.getChildren().iterator(); it.hasNext(); ) {
                                IProgramElement nextNode = (IProgramElement)it.next();
-                               if (nextNode instanceof IProgramElement) {
+                               if (nextNode!=null) {
                                        findMatchesHelper(
-                                                       (IProgramElement)nextNode, 
+                                                       nextNode, 
                                                        pattern, 
                                                        kind,
                                                        matches);
index 6535dd2b1bc2c84c76f5dd58e2b1e3e6eeaca85f..edbae46983bf190ebfac721e78da7914b046d7fd 100644 (file)
@@ -57,7 +57,7 @@ public abstract class StructureView {
         */
        public IStructureViewNode getActiveNode() {
                if (activeNode != null 
-                       && activeNode.getStructureNode() instanceof IProgramElement) {
+                       && activeNode.getStructureNode()!=null) {
                        return activeNode;
                } else {
                        return null;
index 1d06d94098106308bfbe531b8ed5b10c1f289246..b36d32f6cc453abd977ebc8cebe727891ce09d2d 100644 (file)
@@ -93,8 +93,8 @@ public class StructureViewManager {
                        newFilePath,
                        lineNumber);
                
-               if (currNode instanceof IProgramElement) {
-                       navigationAction((IProgramElement)currNode, true);      
+               if (currNode!=null) {
+                       navigationAction(currNode, true);       
                }
        } 
                
@@ -127,7 +127,7 @@ public class StructureViewManager {
                StructureView view = (StructureView)it.next();
                if (!(view instanceof GlobalStructureView) || !recordHistory || defaultFileView == null) {
                        if (node.getKind().equals(IProgramElement.Kind.CODE)) {
-                               IProgramElement parentNode = (IProgramElement)node.getParent();
+                               IProgramElement parentNode = node.getParent();
                                if (parentNode != null) {
                                        IStructureViewNode currNode = view.findCorrespondingViewNode(parentNode);
                                        int lineOffset = node.getSourceLocation().getLine() - parentNode.getSourceLocation().getLine();
index 5b312fd251f2bc0b93764ef1ccd8341e8067afe6..af1a2477f322c6e5e41d3e7cf3dc90daccb09dfd 100644 (file)
@@ -163,8 +163,8 @@ public class TreeStructureViewBuilder {
        }
        
        private boolean acceptNode(IProgramElement node, StructureViewProperties properties) {
-               if (node instanceof IProgramElement) {
-                       IProgramElement pNode = (IProgramElement)node;
+               if (node!=null) {
+                       IProgramElement pNode = node;
                        if (!acceptGranularity(pNode.getKind(), properties.getGranularity())) {
                                return false;
                        } else if (pNode.getKind().isMember()) {
@@ -180,11 +180,6 @@ public class TreeStructureViewBuilder {
                                        }       
                                }
                        }
-//             } else if (node instanceof IRelationship) {
-//                     IRelationship relation = (IRelationship)node;
-//                     return properties.getRelations().contains(relation);
-               } else {
-                       return true;
                }
                return true;
        }
@@ -387,15 +382,12 @@ public class TreeStructureViewBuilder {
                IProgramElement sv1 = ((IStructureViewNode)o1).getStructureNode();
                IProgramElement sv2 = ((IStructureViewNode)o2).getStructureNode();        
                        
-            if (sv1 instanceof IProgramElement && sv2 instanceof IProgramElement) {
+            if (sv1!=null && sv2!=null) {
          
-               IProgramElement p1 = (IProgramElement)sv1;
-               IProgramElement p2 = (IProgramElement)sv2;
+                               if (sv2.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return 1;
+                               if (sv1.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return -1;
                
-                               if (p2.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return 1;
-                               if (p1.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return -1;
-               
-                               return p1.getName().compareTo(p2.getName());
+                               return sv1.getName().compareTo(sv2.getName());
             } else {
                return 0;       
            }
@@ -405,15 +397,13 @@ public class TreeStructureViewBuilder {
     private static final Comparator DECLARATIONAL_COMPARATOR = new Comparator() {
         public int compare(Object o1, Object o2) {            
                IProgramElement sv1 = ((IStructureViewNode)o1).getStructureNode();
-               IProgramElement sv2 = ((IStructureViewNode)o2).getStructureNode();        
-            if (sv1 instanceof IProgramElement && sv2 instanceof IProgramElement) {
-               IProgramElement p1 = (IProgramElement)sv1;
-               IProgramElement p2 = (IProgramElement)sv2;
-               if (p2.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return 1;
-                               if (p1.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return -1;
-               if (p1.getSourceLocation() == null || p2.getSourceLocation() == null) {
+               IProgramElement sv2 = ((IStructureViewNode)o2).getStructureNode();      
+            if (sv1!=null && sv2!=null) {
+               if (sv2.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return 1;
+                               if (sv1.getKind() == IProgramElement.Kind.IMPORT_REFERENCE) return -1;
+               if (sv1.getSourceLocation() == null || sv2.getSourceLocation() == null) {
                        return 0;
-               } else if (p1.getSourceLocation().getLine() < p2.getSourceLocation().getLine()) {
+               } else if (sv1.getSourceLocation().getLine() < sv2.getSourceLocation().getLine()) {
                        return -1;
                } else {
                        return 1;
index 7e791cc5c24ee659c94b05577e37c3b05f60b7bd..b1120f0fbd5c9ecba608e7f1128e19ba11f3081f 100644 (file)
@@ -34,7 +34,7 @@ import org.aspectj.util.LangUtil;
 
 public class UserPreferencesStore implements UserPreferencesAdapter {
     public static final String FILE_NAME = "/.ajbrowser";
-    private final String VALUE_SEP = ";";
+    private static final String VALUE_SEP = ";";
     private Properties properties = new Properties();
     private boolean persist = true;
        
index c237cbca1913f412824552ae5e02269d9fc6ff44..0b15049b67c6d40420bb2c9a4f79283d8c6888f1 100644 (file)
@@ -107,7 +107,7 @@ public class BrowserViewPanel extends JPanel implements StructureViewRenderer {
 
     public void updateView(StructureView structureView) {
        if (structureView instanceof GlobalStructureView) {
-               treeManager.updateTree((GlobalStructureView)structureView);
+               treeManager.updateTree(structureView);
        }
     }
 
index d7ea37076f474628af11c38f78aea5ccfc6f5967..8e88a38a49195c25d3e509492f49c898640a1ff7 100644 (file)
@@ -61,7 +61,7 @@ class BrowserViewTreeListener implements TreeSelectionListener, MouseListener {
         SwingTreeViewNode treeNode = (SwingTreeViewNode)tree.getLastSelectedPathComponent();
         if (treeNode != null && !e.isControlDown() && !e.isShiftDown() && e.getModifiers() != 4) {
             IProgramElement currNode = (IProgramElement)treeNode.getUserObject();
-            if (currNode instanceof IProgramElement && !e.isControlDown()
+            if (currNode!=null && !e.isControlDown()
                 && !e.isShiftDown() && e.getModifiers() != 4) {
                 //AjdeUIManager.getDefault().getViewManager().showNodeInMasterView((ProgramElementNode)currNode);
                 //if (AjdeUIManager.getDefault().getViewManager().isSplitViewMode()) {
@@ -83,7 +83,7 @@ class BrowserViewTreeListener implements TreeSelectionListener, MouseListener {
             SwingTreeViewNode treeNode = (SwingTreeViewNode)tree.getLastSelectedPathComponent();
             if (treeNode != null) {
                 IProgramElement currNode = (IProgramElement)treeNode.getUserObject();
-                if (currNode instanceof IProgramElement && !e.isControlDown() && !e.isShiftDown()
+                if (currNode!=null && !e.isControlDown() && !e.isShiftDown()
                     && e.getModifiers() != 4) {
                     //AjdeUIManager.getDefault().getViewManager().showNodeInMasterView(((LinkNode)currNode).getProgramElementNode());
                     //AjdeUIManager.getDefault().getViewManager().showNodeInSlaveView(((LinkNode)currNode).getProgramElementNode());
index 77de70d539faac4b02d945da8bb986a8ae0d8c57..ea681475f36f57bb88aaa16c9a0e8c6414882b12 100644 (file)
@@ -45,7 +45,7 @@ public class CompilerMessagesCellRenderer extends JLabel implements ListCellRend
                                IMessage cm = (IMessage) value;
                 label = cm.getMessage();
                 if (LangUtil.isEmpty(label)) {
-                    label = cm.getMessage().toString();
+                    label = cm.getMessage();
                 }
                 kind = cm.getKind();
                 Throwable thrown = cm.getThrown();
index f92b19d7f8ba652e99bf14716c9dcf752ca43892..130183676a10319f72013876e5d1729a16eb8853 100644 (file)
@@ -142,20 +142,20 @@ public class OptionsFrame extends JFrame {
         setVisible(true);
         main_tabbedPane.setSelectedComponent(panel);
     }
-
-       private void loadOptions() {
-               try {
-                       Component[] components = main_tabbedPane.getComponents();
-                       for (int i = 0; i < components.length; i++) {
-                               if (components[i] instanceof OptionsPanel) {
-                                       ((OptionsPanel)components[i]).loadOptions();
-                               }
-                       }
-               } catch (IOException ioe) {
-               Message msg = new Message("Could not load options.",IMessage.ERROR,ioe,null);
-               Ajde.getDefault().getMessageHandler().handleMessage(msg);
-               }
-       }
+//
+//     private void loadOptions() {
+//             try {
+//                     Component[] components = main_tabbedPane.getComponents();
+//                     for (int i = 0; i < components.length; i++) {
+//                             if (components[i] instanceof OptionsPanel) {
+//                                     ((OptionsPanel)components[i]).loadOptions();
+//                             }
+//                     }
+//             } catch (IOException ioe) {
+//             Message msg = new Message("Could not load options.",IMessage.ERROR,ioe,null);
+//             Ajde.getDefault().getMessageHandler().handleMessage(msg);
+//             }
+//     }
 
        private void saveOptions() {
                try {
index 7e1f8123bc76443c7c80077903ce9501275b70c3..7cde2b7697badd583f5b8604c2c412a37f1e58ff 100644 (file)
@@ -81,7 +81,7 @@ class StructureTreeManager {
     private void highlightNode(SwingTreeViewNode parent, IProgramElement node) {
         for (int i = 0; i < parent.getChildCount(); i++) {
             SwingTreeViewNode currNode = (SwingTreeViewNode)parent.getChildAt(i);
-            IProgramElement sNode = (IProgramElement)currNode.getStructureNode();
+            IProgramElement sNode = currNode.getStructureNode();
             if (sNode != null && sNode.equals(node) && currNode.getKind() != IStructureViewNode.Kind.LINK) {
                 TreePath path = new TreePath(currNode.getPath());
                 structureTree.setSelectionPath(path);
@@ -177,7 +177,7 @@ class StructureTreeManager {
         structureTree.expandPath(structureTree.getPathForRow(0));
     }
 
-    private class StructureTreeModel extends DefaultTreeModel implements TreeModel {
+    private static class StructureTreeModel extends DefaultTreeModel {
         
                private static final long serialVersionUID = 1L;
 
index 69eb0fd5171a5270833eed8a4673d7b42ed623ac..c1435051ade26bd76c714b39a761b01317257ea6 100644 (file)
@@ -103,7 +103,7 @@ public class StructureViewPanel extends JPanel implements StructureViewRenderer
        public void setActiveNode(IStructureViewNode node, int lineOffset) {
                if (node == null) return;
 //             if (!(node.getStructureNode() instanceof IProgramElement)) return;
-               IProgramElement pNode = (IProgramElement)node.getStructureNode();
+               IProgramElement pNode = node.getStructureNode();
                treeManager.highlightNode(pNode);
                if (pNode.getSourceLocation() != null) {
                        Ajde.getDefault().getEditorAdapter().showSourceLine(
@@ -117,8 +117,8 @@ public class StructureViewPanel extends JPanel implements StructureViewRenderer
        public void highlightActiveNode() {
                if (currentView.getActiveNode() == null) return;
                IProgramElement node = currentView.getActiveNode().getStructureNode();
-               if (node instanceof IProgramElement) {
-                       treeManager.highlightNode((IProgramElement)node);
+               if (node!=null) {
+                       treeManager.highlightNode(node);
                }
        }
 
index 64a69998c7854cdc72d34d001698d39e3bba8c06..3d332c865356aa3c7d044e8c84edffae5e090c3b 100644 (file)
@@ -90,7 +90,7 @@ public class TreeViewBuildConfigEditor extends JPanel implements BuildConfigEdit
             jLabel1.setText(" Build configuration: " + configFile);
 
             model = Ajde.getDefault().getBuildConfigManager().buildModel(configFile);            
-                       root = buildTree((BuildConfigNode)model.getRoot());
+                       root = buildTree(model.getRoot());
 
             buildConfig_tree.setModel(new DefaultTreeModel(root));
             buildConfig_tree.addMouseListener(new ConfigFileMouseAdapter(buildConfig_tree));
@@ -155,7 +155,7 @@ public class TreeViewBuildConfigEditor extends JPanel implements BuildConfigEdit
         jScrollPane.getViewport().add(buildConfig_tree, null);
     }
 
-    private class ConfigTreeNode extends DefaultMutableTreeNode {
+    private static class ConfigTreeNode extends DefaultMutableTreeNode {
        
                private static final long serialVersionUID = 1L;
                public JCheckBox checkBox = null;
@@ -176,7 +176,7 @@ public class TreeViewBuildConfigEditor extends JPanel implements BuildConfigEdit
 
     }
 
-    private class ConfigFileMouseAdapter extends MouseAdapter {
+    private static class ConfigFileMouseAdapter extends MouseAdapter {
         private JTree tree = null;
         final JCheckBox checkBoxProto = new JCheckBox();
         final int width = checkBoxProto.getPreferredSize().width;