EA-87751 - SOE: TitleCapitalizationInspection.getTitleValue
authorAnna Kozlova <anna.kozlova@jetbrains.com>
Sun, 4 Sep 2016 18:12:23 +0000 (21:12 +0300)
committerAnna Kozlova <anna.kozlova@jetbrains.com>
Mon, 5 Sep 2016 04:57:44 +0000 (07:57 +0300)
plugins/java-i18n/src/com/intellij/codeInspection/capitalization/TitleCapitalizationInspection.java

index e048f63f88a1de07ade5438562003f291023f4f0..6788344f3bcf746dfb1224bba7e5c3a71005e067 100644 (file)
@@ -137,7 +137,7 @@ public class TitleCapitalizationInspection extends BaseJavaLocalInspectionTool {
       if (arg == returnValue) {
         return null;
       }
-      if (returnValue != null) {
+      if (returnValue != null && processed.add(returnValue)) {
         return getTitleValue(returnValue, processed);
       }
       Property propertyArgument = getPropertyArgument((PsiMethodCallExpression)arg);
@@ -147,8 +147,11 @@ public class TitleCapitalizationInspection extends BaseJavaLocalInspectionTool {
     }
     if (arg instanceof PsiReferenceExpression) {
       PsiElement result = ((PsiReferenceExpression)arg).resolve();
-      if (result instanceof PsiVariable && processed.add(result) && ((PsiVariable)result).hasModifierProperty(PsiModifier.FINAL)) {
-        return getTitleValue(((PsiVariable) result).getInitializer(), processed);
+      if (result instanceof PsiVariable && ((PsiVariable)result).hasModifierProperty(PsiModifier.FINAL)) {
+        PsiExpression initializer = ((PsiVariable)result).getInitializer();
+        if (processed.add(initializer)) {
+          return getTitleValue(initializer, processed);
+        }
       }
     }
     return null;