com.intellij.psi.PsiElementjavax.swing.JComponent



Project JetBrains/intellij-community in file ...w.SwitchStatementWithTooFewBranchesInspection.java (2006-03-10)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2005 Dave Griffith
+ * Copyright 2003-2006 Dave Griffith, Bas Leijdekkers
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,17 +17,16 @@ package com.siyeh.ig.controlflow;
 
 import com.intellij.codeInsight.daemon.GroupNames;
 import com.intellij.psi.PsiCodeBlock;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiSwitchStatement;
+import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.BaseInspectionVisitor;
 import com.siyeh.ig.StatementInspection;
 import com.siyeh.ig.StatementInspectionVisitor;
 import com.siyeh.ig.psiutils.SwitchUtils;
 import com.siyeh.ig.ui.SingleIntegerFieldOptionsPanel;
-import com.siyeh.InspectionGadgetsBundle;
 import org.jetbrains.annotations.NotNull;
 
-import javax.swing.*;
+import javax.swing.JComponent;
 
 public class SwitchStatementWithTooFewBranchesInspection
         extends StatementInspection {
@@ -50,14 +49,12 @@ public class SwitchStatementWithTooFewBranchesInspection
                 this, "m_limit");
     }
 
-    protected String buildErrorString(PsiElement location) {
-        final PsiSwitchStatement statement =
-                (PsiSwitchStatement)location.getParent();
-        assert statement != null;
-        final int numBranches = SwitchUtils.calculateBranchCount(statement);
+    @NotNull
+    protected String buildErrorString(Object... infos) {
+        final Integer branchCount = (Integer)infos[0];
         return InspectionGadgetsBundle.message(
                 "switch.statement.with.too.few.branches.problem.descriptor",
-                numBranches);
+                branchCount);
     }
 
     public BaseInspectionVisitor buildVisitor() {
@@ -73,11 +70,11 @@ public class SwitchStatementWithTooFewBranchesInspection
             if (body == null) {
                 return;
             }
-            final int numBranches = SwitchUtils.calculateBranchCount(statement);
-            if (numBranches >= m_limit) {
+            final int branchCount = SwitchUtils.calculateBranchCount(statement);
+            if (branchCount >= m_limit) {
                 return;
             }
-            registerStatementError(statement);
+            registerStatementError(statement, Integer.valueOf(branchCount));
         }
     }
 }
Project JetBrains/intellij-community in file ....SwitchStatementWithTooManyBranchesInspection.java (2006-03-10)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2005 Dave Griffith
+ * Copyright 2003-2006 Dave Griffith, Bas Leijdekkers
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,17 +17,16 @@ package com.siyeh.ig.controlflow;
 
 import com.intellij.codeInsight.daemon.GroupNames;
 import com.intellij.psi.PsiCodeBlock;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiSwitchStatement;
+import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.BaseInspectionVisitor;
 import com.siyeh.ig.StatementInspection;
 import com.siyeh.ig.StatementInspectionVisitor;
 import com.siyeh.ig.psiutils.SwitchUtils;
 import com.siyeh.ig.ui.SingleIntegerFieldOptionsPanel;
-import com.siyeh.InspectionGadgetsBundle;
 import org.jetbrains.annotations.NotNull;
 
-import javax.swing.*;
+import javax.swing.JComponent;
 
 public class SwitchStatementWithTooManyBranchesInspection
         extends StatementInspection {
@@ -50,14 +49,12 @@ public class SwitchStatementWithTooManyBranchesInspection
                 this, "m_limit");
     }
 
-    protected String buildErrorString(PsiElement location) {
-        final PsiSwitchStatement statement =
-                (PsiSwitchStatement)location.getParent();
-        assert statement != null;
-        final int numBranches = SwitchUtils.calculateBranchCount(statement);
+    @NotNull
+    protected String buildErrorString(Object... infos) {
+        final Integer branchCount = (Integer)infos[0];
         return InspectionGadgetsBundle.message(
                 "if.statement.with.too.many.branches.problem.descriptor",
-                numBranches);
+                branchCount);
     }
 
     public BaseInspectionVisitor buildVisitor() {
@@ -67,16 +64,17 @@ public class SwitchStatementWithTooManyBranchesInspection
     private class SwitchStatementWithTooManyBranchesVisitor
             extends StatementInspectionVisitor {
 
-        public void visitSwitchStatement(@NotNull PsiSwitchStatement statement) {
+        public void visitSwitchStatement(
+                @NotNull PsiSwitchStatement statement) {
             final PsiCodeBlock body = statement.getBody();
             if (body == null) {
                 return;
             }
-            final int numBranches = SwitchUtils.calculateBranchCount(statement);
-            if (numBranches <= m_limit) {
+            final int branchCount = SwitchUtils.calculateBranchCount(statement);
+            if (branchCount <= m_limit) {
                 return;
             }
-            registerStatementError(statement);
+            registerStatementError(statement, Integer.valueOf(branchCount));
         }
     }
 }
\ No newline at end of file
Project JetBrains/intellij-community in file ...om.siyeh.ig.memory.StaticCollectionInspection.java (2006-03-10)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2005 Dave Griffith
+ * Copyright 2003-2006 Dave Griffith, Bas Leijdekkers
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,18 +16,17 @@
 package com.siyeh.ig.memory;
 
 import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiField;
 import com.intellij.psi.PsiModifier;
 import com.intellij.psi.PsiType;
+import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.BaseInspectionVisitor;
 import com.siyeh.ig.VariableInspection;
 import com.siyeh.ig.psiutils.CollectionUtils;
 import com.siyeh.ig.ui.SingleCheckboxOptionsPanel;
-import com.siyeh.InspectionGadgetsBundle;
 import org.jetbrains.annotations.NotNull;
 
-import javax.swing.*;
+import javax.swing.JComponent;
 
 public class StaticCollectionInspection extends VariableInspection {
 
@@ -35,28 +34,32 @@ public class StaticCollectionInspection extends VariableInspection {
     public boolean m_ignoreWeakCollections = false;
 
     public String getDisplayName() {
-        return InspectionGadgetsBundle.message("static.collection.display.name");
+        return InspectionGadgetsBundle.message(
+                "static.collection.display.name");
     }
 
     public String getGroupDisplayName() {
         return GroupNames.MEMORY_GROUP_NAME;
     }
 
-    public String buildErrorString(PsiElement location) {
-        return InspectionGadgetsBundle.message("static.collection.problem.descriptor");
+    @NotNull
+    public String buildErrorString(Object... infos) {
+        return InspectionGadgetsBundle.message(
+                "static.collection.problem.descriptor");
     }
 
     public JComponent createOptionsPanel(){
-        return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message("static.collection.ignore.option"),
-                                              this, "m_ignoreWeakCollections");
+        return new SingleCheckboxOptionsPanel(InspectionGadgetsBundle.message(
+                "static.collection.ignore.option"),
+                this, "m_ignoreWeakCollections");
     }
+    
     public BaseInspectionVisitor buildVisitor() {
         return new StaticCollectionVisitor();
     }
 
     private class StaticCollectionVisitor extends BaseInspectionVisitor {
 
-
         public void visitField(@NotNull PsiField field) {
             if (!field.hasModifierProperty(PsiModifier.STATIC)) {
                 return;
@@ -65,11 +68,11 @@ public class StaticCollectionInspection extends VariableInspection {
             if (!CollectionUtils.isCollectionClassOrInterface(type)) {
                 return;
             }
-            if(m_ignoreWeakCollections &&
-                    !CollectionUtils.isWeakCollectionClass(type))
+            if (!m_ignoreWeakCollections ||
+                    CollectionUtils.isWeakCollectionClass(type)) {
+                return;
+            }
             registerFieldError(field);
         }
-
     }
-
-}
+}
\ No newline at end of file
Project JetBrains/intellij-community in file ...thodmetrics.ThreeNegationsPerMethodInspection.java (2006-03-10)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2005 Dave Griffith
+ * Copyright 2003-2006 Dave Griffith, Bas Leijdekkers
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -16,16 +16,15 @@
 package com.siyeh.ig.methodmetrics;
 
 import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiMethod;
+import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.BaseInspectionVisitor;
 import com.siyeh.ig.MethodInspection;
 import com.siyeh.ig.psiutils.MethodUtils;
 import com.siyeh.ig.ui.SingleCheckboxOptionsPanel;
-import com.siyeh.InspectionGadgetsBundle;
 import org.jetbrains.annotations.NotNull;
 
-import javax.swing.*;
+import javax.swing.JComponent;
 
 public class ThreeNegationsPerMethodInspection extends MethodInspection {
 
@@ -49,12 +48,9 @@ public class ThreeNegationsPerMethodInspection extends MethodInspection {
                 this, "m_ignoreInEquals");
     }
 
-    public String buildErrorString(PsiElement location) {
-        final PsiMethod method = (PsiMethod)location.getParent();
-        assert method != null;
-        final NegationCountVisitor visitor = new NegationCountVisitor();
-        method.accept(visitor);
-        final int negationCount = visitor.getCount();
+    @NotNull
+    public String buildErrorString(Object... infos) {
+        final Integer negationCount = (Integer)infos[0];
         return InspectionGadgetsBundle.message(
                 "three.negations.per.method.problem.descriptor", negationCount);
     }
@@ -76,7 +72,7 @@ public class ThreeNegationsPerMethodInspection extends MethodInspection {
             if (m_ignoreInEquals && MethodUtils.isEquals(method)) {
                 return;
             }
-            registerMethodError(method);
+            registerMethodError(method, Integer.valueOf(negationCount));
         }
     }
 }
\ No newline at end of file
Project JetBrains/intellij-community in file ...rClassWithNonSerializableOuterClassInspection.java (2006-03-10)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2003-2005 Dave Griffith
+ * Copyright 2003-2006 Dave Griffith, Bas Leijdekkers
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,18 +17,18 @@ package com.siyeh.ig.serialization;
 
 import com.intellij.codeInsight.daemon.GroupNames;
 import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiModifier;
+import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.BaseInspectionVisitor;
 import com.siyeh.ig.ClassInspection;
 import com.siyeh.ig.psiutils.SerializationUtils;
 import com.siyeh.ig.ui.SingleCheckboxOptionsPanel;
-import com.siyeh.InspectionGadgetsBundle;
 import org.jetbrains.annotations.NotNull;
 
-import javax.swing.*;
+import javax.swing.JComponent;
 
-public class SerializableInnerClassWithNonSerializableOuterClassInspection extends ClassInspection {
+public class SerializableInnerClassWithNonSerializableOuterClassInspection
+        extends ClassInspection {
 
     /**
      * @noinspection PublicField
@@ -41,15 +41,23 @@ public class SerializableInnerClassWithNonSerializableOuterClassInspection exten
 
     public JComponent createOptionsPanel() {
         return new SingleCheckboxOptionsPanel(
-                InspectionGadgetsBundle.message("serializable.inner.class.with.non.serializable.outer.class.ignore.option"),
+                InspectionGadgetsBundle.message(
+                        "serializable.inner.class.with.non.serializable.outer.class.ignore.option"),
                 this, "m_ignoreSerializableDueToInheritance");
     }
 
+    @NotNull
+    protected String buildErrorString(Object... infos) {
+        return InspectionGadgetsBundle.message(
+                "serializable.inner.class.with.non.serializable.outer.class.problem.descriptor");
+    }
+
     public BaseInspectionVisitor buildVisitor() {
         return new SerializableDefinesSerialVersionUIDVisitor();
     }
 
-    private class SerializableDefinesSerialVersionUIDVisitor extends BaseInspectionVisitor {
+    private class SerializableDefinesSerialVersionUIDVisitor
+            extends BaseInspectionVisitor {
 
         public void visitClass(@NotNull PsiClass aClass) {
             // no call to super, so it doesn't drill down