mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java intention: Quick fix for error "foreach not applicable to type java.util.Iterator" - a test added (IDEA-124751)
This commit is contained in:
+11
@@ -0,0 +1,11 @@
|
||||
// "Replace 'for each' loop with iterator 'for' loop" "true"
|
||||
import java.util.Iterator;
|
||||
|
||||
public class FinalItem {
|
||||
void foo(Iterator<Integer> it) {
|
||||
for (Iterator<Integer> it1 = it; it1.hasNext(); ) {
|
||||
final Integer integer = it1.next();
|
||||
System.out.println(integer);
|
||||
}
|
||||
}
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
// "Replace 'for each' loop with iterator 'for' loop" "true"
|
||||
import java.util.Iterator;
|
||||
|
||||
public class FinalItem {
|
||||
void foo(Iterator<Integer> it) {
|
||||
for (Integer integer : <caret>it) System.out.println(integer);
|
||||
}
|
||||
}
|
||||
+24
@@ -15,13 +15,37 @@
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettings;
|
||||
import com.intellij.psi.codeStyle.CodeStyleSettingsManager;
|
||||
|
||||
/**
|
||||
* @author Pavel.Dolgov
|
||||
*/
|
||||
public class ReplaceIteratorForEachLoopWithIteratorForLoopFixTest extends LightQuickFixParameterizedTestCase {
|
||||
|
||||
private boolean myFinalLocals;
|
||||
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
|
||||
@Override
|
||||
protected void beforeActionStarted(String testName, String contents) {
|
||||
super.beforeActionStarted(testName, contents);
|
||||
if (testName.startsWith("Final")) {
|
||||
final CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
myFinalLocals = codeStyleSettings.GENERATE_FINAL_LOCALS;
|
||||
codeStyleSettings.GENERATE_FINAL_LOCALS = true;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void afterActionCompleted(String testName, String contents) {
|
||||
if (testName.startsWith("Final")) {
|
||||
final CodeStyleSettings codeStyleSettings = CodeStyleSettingsManager.getSettings(getProject());
|
||||
codeStyleSettings.GENERATE_FINAL_LOCALS = myFinalLocals;
|
||||
}
|
||||
super.afterActionCompleted(testName, contents);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/codeInsight/daemonCodeAnalyzer/quickFix/replaceIteratorForEachWithFor";
|
||||
|
||||
Reference in New Issue
Block a user