mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
disable "Replace '+' with 'String.format()'" inside annotations
This commit is contained in:
+19
-1
@@ -15,7 +15,10 @@
|
||||
*/
|
||||
package com.siyeh.ipp.concatenation;
|
||||
|
||||
import com.intellij.psi.PsiArrayInitializerMemberValue;
|
||||
import com.intellij.psi.PsiBinaryExpression;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiNameValuePair;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.siyeh.ipp.base.PsiElementPredicate;
|
||||
import com.siyeh.ipp.psiutils.ConcatenationUtils;
|
||||
@@ -27,9 +30,24 @@ class Jdk5StringConcatenationPredicate implements PsiElementPredicate {
|
||||
if (!PsiUtil.isLanguageLevel5OrHigher(element)) {
|
||||
return false;
|
||||
}
|
||||
if(!ConcatenationUtils.isConcatenation(element)) {
|
||||
if (!ConcatenationUtils.isConcatenation(element)) {
|
||||
return false;
|
||||
}
|
||||
if (isInsideAnnotation(element)) {
|
||||
return false;
|
||||
}
|
||||
return !ErrorUtil.containsError(element);
|
||||
}
|
||||
|
||||
private static boolean isInsideAnnotation(PsiElement element) {
|
||||
for (int i = 0; i < 20 && element instanceof PsiBinaryExpression; i++) {
|
||||
// optimization: don't check deep string concatenations more than 20 levels up.
|
||||
element = element.getParent();
|
||||
if (element instanceof PsiNameValuePair ||
|
||||
element instanceof PsiArrayInitializerMemberValue) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user