mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java-intentions] ReplaceForEachLoopWithIndexedForLoopIntention: avoid external type annotation (IDEA-364993)
GitOrigin-RevId: c2add083725824690583b04cfcb6d60cc1f77df2
This commit is contained in:
committed by
intellij-monorepo-bot
parent
516a6bda17
commit
d1bb2d18d7
+3
-1
@@ -23,6 +23,7 @@ import com.intellij.psi.*;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleManager;
|
||||
import com.intellij.psi.codeStyle.JavaCodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.VariableKind;
|
||||
import com.intellij.psi.util.PsiTypesUtil;
|
||||
import com.siyeh.IntentionPowerPackBundle;
|
||||
import com.siyeh.ig.PsiReplacementUtil;
|
||||
import com.siyeh.ig.psiutils.CommentTracker;
|
||||
@@ -215,8 +216,9 @@ public class ReplaceForEachLoopWithIndexedForLoopIntention extends MCIntention {
|
||||
final String variableName =
|
||||
createVariableName(variableNameRoot, iteratedValue);
|
||||
final Project project = context.getProject();
|
||||
final PsiType iteratedValueType = iteratedValue.getType();
|
||||
PsiType iteratedValueType = iteratedValue.getType();
|
||||
assert iteratedValueType != null;
|
||||
iteratedValueType = PsiTypesUtil.removeExternalAnnotations(iteratedValueType);
|
||||
final PsiElementFactory elementFactory =
|
||||
JavaPsiFacade.getElementFactory(project);
|
||||
final PsiDeclarationStatement declarationStatement =
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
class X {
|
||||
void test(String str) {
|
||||
<caret>for(String s : str.split("/")) {
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
class X {
|
||||
void test(String str) {
|
||||
<caret> String[] split = str.split("/");
|
||||
for (int i = 0, splitLength = split.length; i < splitLength; i++) {
|
||||
String s = split[i];
|
||||
System.out.println(s);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
@@ -18,6 +18,7 @@ public class ReplaceForEachLoopWithIndexedForLoopIntentionTest extends IPPTestCa
|
||||
public void testBlockNeeded() { doTest(); }
|
||||
public void testBlockNeededLabeled() { doTest(); }
|
||||
public void testVar() { doTest(); }
|
||||
public void testNoExternalAnno() { doTest(); }
|
||||
|
||||
@Override
|
||||
protected String getIntentionName() {
|
||||
|
||||
Reference in New Issue
Block a user