com.intellij.psi.PsiElementcom.siyeh.InspectionGadgetsBundle



Project JetBrains/intellij-community in file ...t.AbstractClassExtendsConcreteClassInspection.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,44 +17,57 @@ package com.siyeh.ig.classlayout;
 
 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 org.jetbrains.annotations.NotNull;
 
-public class AbstractClassExtendsConcreteClassInspection extends ClassInspection {
-
-  public String getGroupDisplayName() {
-    return GroupNames.INHERITANCE_GROUP_NAME;
-  }
-
-  public BaseInspectionVisitor buildVisitor() {
-    return new AbstractClassExtendsConcreteClassVisitor();
-  }
-
-  private static class AbstractClassExtendsConcreteClassVisitor extends BaseInspectionVisitor {
-
-    public void visitClass(@NotNull PsiClass aClass) {
-      // no call to super, so that it doesn't drill down to inner classes
-      if (aClass.isInterface() || aClass.isAnnotationType()) {
-        return;
-      }
-      if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
-        return;
-      }
-      final PsiClass superClass = aClass.getSuperClass();
-      if (superClass == null) {
-        return;
-      }
-      if (superClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
-        return;
-      }
-      final String superclassName = superClass.getQualifiedName();
-      if ("java.lang.Object".equals(superclassName)) {
-        return;
-      }
-      registerClassError(aClass);
+public class AbstractClassExtendsConcreteClassInspection
+        extends ClassInspection {
+
+    public String getDisplayName() {
+        return InspectionGadgetsBundle.message(
+                "abstract.class.extends.concrete.class.display.name");
+    }
+
+    public String getGroupDisplayName() {
+        return GroupNames.INHERITANCE_GROUP_NAME;
+    }
+
+    @NotNull
+    protected String buildErrorString(Object... infos) {
+        return InspectionGadgetsBundle.message(
+                "abstract.class.extends.concrete.class.problem.descriptor");
+    }
+
+    public BaseInspectionVisitor buildVisitor() {
+        return new AbstractClassExtendsConcreteClassVisitor();
+    }
+
+    private static class AbstractClassExtendsConcreteClassVisitor
+            extends BaseInspectionVisitor {
+
+        public void visitClass(@NotNull PsiClass aClass) {
+            // no call to super, so that it doesn't drill down to inner classes
+            if (aClass.isInterface() || aClass.isAnnotationType()) {
+                return;
+            }
+            if (!aClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
+                return;
+            }
+            final PsiClass superClass = aClass.getSuperClass();
+            if (superClass == null) {
+                return;
+            }
+            if (superClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
+                return;
+            }
+            final String superclassName = superClass.getQualifiedName();
+            if ("java.lang.Object".equals(superclassName)) {
+                return;
+            }
+            registerClassError(aClass);
+        }
     }
-  }
-}
+}
\ No newline at end of file
Project JetBrains/intellij-community in file ...out.ConstantDeclaredInAbstractClassInspection.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,43 +17,51 @@ package com.siyeh.ig.classlayout;
 
 import com.intellij.codeInsight.daemon.GroupNames;
 import com.intellij.psi.PsiClass;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiField;
 import com.intellij.psi.PsiModifier;
+import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.BaseInspectionVisitor;
 import com.siyeh.ig.FieldInspection;
 import org.jetbrains.annotations.NotNull;
 
 public class ConstantDeclaredInAbstractClassInspection extends FieldInspection {
 
-  public String getGroupDisplayName() {
-    return GroupNames.CLASSLAYOUT_GROUP_NAME;
-  }
+    public String getGroupDisplayName() {
+        return GroupNames.CLASSLAYOUT_GROUP_NAME;
+    }
+
+    @NotNull
+    protected String buildErrorString(Object... infos) {
+        return InspectionGadgetsBundle.message(
+                "constant.declared.in.abstract.class.problem.descriptor");
+    }
 
-  public BaseInspectionVisitor buildVisitor() {
-    return new ConstantDeclaredInAbstractClassVisitor();
-  }
+    public BaseInspectionVisitor buildVisitor() {
+        return new ConstantDeclaredInAbstractClassVisitor();
+    }
 
-  private static class ConstantDeclaredInAbstractClassVisitor extends BaseInspectionVisitor {
+    private static class ConstantDeclaredInAbstractClassVisitor
+            extends BaseInspectionVisitor {
 
-    public void visitField(@NotNull PsiField field) {
-      //no call to super, so we don't drill into anonymous classes
-      if (!field.hasModifierProperty(PsiModifier.STATIC) ||
-          !field.hasModifierProperty(PsiModifier.PUBLIC) ||
-          !field.hasModifierProperty(PsiModifier.FINAL)) {
-        return;
-      }
-      final PsiClass containingClass = field.getContainingClass();
-      if (containingClass == null) {
-        return;
-      }
-      if (containingClass.isInterface() || containingClass.isAnnotationType()) {
-        return;
-      }
-      if (!containingClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
-        return;
-      }
-      registerFieldError(field);
+        public void visitField(@NotNull PsiField field) {
+            //no call to super, so we don't drill into anonymous classes
+            if (!field.hasModifierProperty(PsiModifier.STATIC) ||
+                    !field.hasModifierProperty(PsiModifier.PUBLIC) ||
+                    !field.hasModifierProperty(PsiModifier.FINAL)) {
+                return;
+            }
+            final PsiClass containingClass = field.getContainingClass();
+            if (containingClass == null) {
+                return;
+            }
+            if (containingClass.isInterface() ||
+                    containingClass.isAnnotationType()) {
+                return;
+            }
+            if (!containingClass.hasModifierProperty(PsiModifier.ABSTRACT)) {
+                return;
+            }
+            registerFieldError(field);
+        }
     }
-  }
 }
Project JetBrains/intellij-community in file ...eh.ig.controlflow.ContinueStatementInspection.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,7 +17,7 @@ package com.siyeh.ig.controlflow;
 
 import com.intellij.codeInsight.daemon.GroupNames;
 import com.intellij.psi.PsiContinueStatement;
-import com.intellij.psi.PsiElement;
+import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.BaseInspectionVisitor;
 import com.siyeh.ig.StatementInspection;
 import com.siyeh.ig.StatementInspectionVisitor;
@@ -25,20 +25,27 @@ import org.jetbrains.annotations.NotNull;
 
 public class ContinueStatementInspection extends StatementInspection {
 
-  public String getGroupDisplayName() {
-    return GroupNames.CONTROL_FLOW_GROUP_NAME;
-  }
-
-  public BaseInspectionVisitor buildVisitor() {
-    return new ContinueStatementVisitor();
-  }
+    public String getGroupDisplayName() {
+        return GroupNames.CONTROL_FLOW_GROUP_NAME;
+    }
 
-  private static class ContinueStatementVisitor extends StatementInspectionVisitor {
+    @NotNull
+    protected String buildErrorString(Object... infos) {
+        return InspectionGadgetsBundle.message(
+                "statement.problem.descriptor");
+    }
 
-    public void visitContinueStatement(@NotNull PsiContinueStatement statement) {
-      super.visitContinueStatement(statement);
-      registerStatementError(statement);
+    public BaseInspectionVisitor buildVisitor() {
+        return new ContinueStatementVisitor();
     }
 
-  }
-}
+    private static class ContinueStatementVisitor
+            extends StatementInspectionVisitor {
+
+        public void visitContinueStatement(
+                @NotNull PsiContinueStatement statement) {
+            super.visitContinueStatement(statement);
+            registerStatementError(statement);
+        }
+    }
+}
\ No newline at end of file
Project JetBrains/intellij-community in file ...ig.junit.TestMethodWithoutAssertionInspection.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,8 +16,8 @@
 package com.siyeh.ig.junit;
 
 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.ExpressionInspection;
 import com.siyeh.ig.psiutils.TestUtils;
@@ -25,33 +25,39 @@ import org.jetbrains.annotations.NotNull;
 
 public class TestMethodWithoutAssertionInspection extends ExpressionInspection {
 
-  public String getID() {
-    return "JUnitTestMethodWithNoAssertions";
-  }
-
-  public String getGroupDisplayName() {
-    return GroupNames.JUNIT_GROUP_NAME;
-  }
-
-  public BaseInspectionVisitor buildVisitor() {
-    return new TestMethodWithoutAssertionVisitor();
-  }
-
-  private static class TestMethodWithoutAssertionVisitor extends BaseInspectionVisitor {
-
-    public void visitMethod(@NotNull PsiMethod method) {
-      super.visitMethod(method);
-      if (!TestUtils.isJUnitTestMethod(method)) {
-        return;
-      }
-      final ContainsAssertionVisitor visitor = new ContainsAssertionVisitor();
-      method.accept(visitor);
-      if (visitor.containsAssertion()) {
-        return;
-      }
-      registerMethodError(method);
+    public String getID() {
+        return "JUnitTestMethodWithNoAssertions";
     }
 
+    public String getGroupDisplayName() {
+        return GroupNames.JUNIT_GROUP_NAME;
+    }
+
+    @NotNull
+    protected String buildErrorString(Object... infos) {
+        return InspectionGadgetsBundle.message(
+                "test.method.without.assertion.problem.descriptor");
+    }
 
-  }
-}
+    public BaseInspectionVisitor buildVisitor() {
+        return new TestMethodWithoutAssertionVisitor();
+    }
+
+    private static class TestMethodWithoutAssertionVisitor
+            extends BaseInspectionVisitor {
+
+        public void visitMethod(@NotNull PsiMethod method) {
+            super.visitMethod(method);
+            if (!TestUtils.isJUnitTestMethod(method)) {
+                return;
+            }
+            final ContainsAssertionVisitor visitor =
+                    new ContainsAssertionVisitor();
+            method.accept(visitor);
+            if (visitor.containsAssertion()) {
+                return;
+            }
+            registerMethodError(method);
+        }
+    }
+}
\ No newline at end of file
Project JetBrains/intellij-community in file ...c.com.siyeh.ig.numeric.OctalLiteralInspection.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,55 +16,62 @@
 package com.siyeh.ig.numeric;
 
 import com.intellij.codeInsight.daemon.GroupNames;
-import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiLiteralExpression;
 import com.intellij.psi.PsiType;
+import com.siyeh.InspectionGadgetsBundle;
 import com.siyeh.ig.BaseInspectionVisitor;
 import com.siyeh.ig.ExpressionInspection;
-import org.jetbrains.annotations.NotNull;
 import org.jetbrains.annotations.NonNls;
+import org.jetbrains.annotations.NotNull;
 
 public class OctalLiteralInspection extends ExpressionInspection {
 
-  public String getID() {
-    return "OctalInteger";
-  }
+    public String getID() {
+        return "OctalInteger";
+    }
+
+    public String getGroupDisplayName() {
+        return GroupNames.NUMERIC_GROUP_NAME;
+    }
 
-  public String getGroupDisplayName() {
-    return GroupNames.NUMERIC_GROUP_NAME;
-  }
+    @NotNull
+    protected String buildErrorString(Object... infos) {
+        return InspectionGadgetsBundle.message(
+                "octal.literal.problem.descriptor");
+    }
 
-  public boolean isEnabledByDefault() {
-    return true;
-  }
+    public boolean isEnabledByDefault() {
+        return true;
+    }
 
-  public BaseInspectionVisitor buildVisitor() {
-    return new OctalLiteralVisitor();
-  }
+    public BaseInspectionVisitor buildVisitor() {
+        return new OctalLiteralVisitor();
+    }
 
-  private static class OctalLiteralVisitor extends BaseInspectionVisitor {
+    private static class OctalLiteralVisitor extends BaseInspectionVisitor {
 
-    public void visitLiteralExpression(@NotNull PsiLiteralExpression literal) {
-      super.visitLiteralExpression(literal);
-      final PsiType type = literal.getType();
-      if (type == null) {
-        return;
-      }
-      if (!(type.equals(PsiType.INT)
-            || type.equals(PsiType.LONG))) {
-        return;
-      }
-      @NonNls final String text = literal.getText();
-      if ("0".equals(text) || "0L".equals(text) || "0l".equals(text)) {
-        return;
-      }
-      if (text.charAt(0) != '0') {
-        return;
-      }
-      if (text.startsWith("0x") || text.startsWith("0X")) {
-        return;
-      }
-      registerError(literal);
+        public void visitLiteralExpression(
+                @NotNull PsiLiteralExpression literal) {
+            super.visitLiteralExpression(literal);
+            final PsiType type = literal.getType();
+            if (type == null) {
+                return;
+            }
+            if (!(type.equals(PsiType.INT)
+                    || type.equals(PsiType.LONG))) {
+                return;
+            }
+            @NonNls final String text = literal.getText();
+            if ("0".equals(text) || "0L".equals(text) || "0l".equals(text)) {
+                return;
+            }
+            if (text.charAt(0) != '0') {
+                return;
+            }
+            if (text.startsWith("0x") || text.startsWith("0X")) {
+                return;
+            }
+            registerError(literal);
+        }
     }
-  }
-}
+}
\ No newline at end of file