mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-20 21:41:24 +07:00
LightQuickFixTestCase: Check whether <caret> is present in "before" files; wrong tests fixed
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// "Break string on '\n'" "false"
|
||||
|
||||
class A {
|
||||
String s = "Hello!\n";
|
||||
String s = "Hello!<caret>\n";
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
// "Break string on '\n'" "false"
|
||||
|
||||
class A {
|
||||
String s = "Hello!\n\r";
|
||||
String s = "Hello!<caret>\n\r";
|
||||
}
|
||||
|
||||
@@ -7,6 +7,6 @@ class Example {
|
||||
}
|
||||
|
||||
{
|
||||
Function<String, String> r = (s) -> m(s, s);
|
||||
Function<String, String> r = (s) -> <caret>m(s, s);
|
||||
}
|
||||
}
|
||||
@@ -12,7 +12,7 @@ public class Test {
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
void foo() {
|
||||
void f<caret>oo() {
|
||||
foo(new ArrayList<String>()).addAll(foo1(new ArrayList<String>);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,13 @@
|
||||
// "Suppress for field" "false"
|
||||
/** @noinspection ALL*/
|
||||
class a {
|
||||
static private String mm = "00";
|
||||
static private String <caret>mm = "00";
|
||||
// The "Convert to local" inspection should be reported here if not suppressed
|
||||
|
||||
static void test() {
|
||||
mm = "1";
|
||||
if(mm == "1") {
|
||||
mm = "2";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,6 +4,6 @@ public class Test {
|
||||
{
|
||||
int i = 0;
|
||||
//noinspection SillyAssignment my very long comment
|
||||
i = i;
|
||||
i = <caret>i;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// "Suppress for method" "false"
|
||||
/** @noinspection UNUSED_SYMBOL*/
|
||||
class a {
|
||||
private void run() {
|
||||
private void <caret>run() {
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import java.util.Optional;
|
||||
public class Test {
|
||||
|
||||
void m(String ss) {
|
||||
f(ss);
|
||||
f(<caret>ss);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -5,7 +5,7 @@ class A {
|
||||
|
||||
void m() {
|
||||
|
||||
new StringTokenizer("asd", "\\\t\nqwerty!#2@$")
|
||||
new StringTokenizer("asd", "\\\t\nqw<caret>erty!#2@$")
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,23 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInspection.LocalInspectionTool;
|
||||
import com.intellij.codeInspection.localCanBeFinal.LocalCanBeFinal;
|
||||
import com.intellij.openapi.roots.LanguageLevelProjectExtension;
|
||||
import com.intellij.codeInspection.varScopeCanBeNarrowed.FieldCanBeLocalInspection;
|
||||
import com.intellij.pom.java.LanguageLevel;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -15,7 +30,7 @@ public class SuppressLocalInspectionTest extends LightQuickFixParameterizedTestC
|
||||
@NotNull
|
||||
@Override
|
||||
protected LocalInspectionTool[] configureLocalInspectionTools() {
|
||||
return new LocalInspectionTool[]{new LocalCanBeFinal()};
|
||||
return new LocalInspectionTool[]{new LocalCanBeFinal(), new FieldCanBeLocalInspection()};
|
||||
}
|
||||
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
|
||||
@@ -336,7 +336,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
|
||||
@Override
|
||||
public void configureFromFileText(String name, String contents) throws IOException {
|
||||
LightPlatformCodeInsightTestCase.configureFromFileText(name, contents);
|
||||
LightPlatformCodeInsightTestCase.configureFromFileText(name, contents, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2015 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -474,6 +474,18 @@ public class EditorTestUtil {
|
||||
this.carets = carets;
|
||||
this.blockSelection = blockSelection;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if current CaretAndSelectionState contains at least one caret or selection explicitly specified
|
||||
*/
|
||||
public boolean hasExplicitCaret() {
|
||||
if(carets.isEmpty()) return false;
|
||||
if(blockSelection == null && carets.size() == 1) {
|
||||
CaretInfo caret = carets.get(0);
|
||||
return caret.position != null || caret.selection != null;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public static class CaretInfo {
|
||||
|
||||
@@ -146,12 +146,28 @@ public abstract class LightPlatformCodeInsightTestCase extends LightPlatformTest
|
||||
*/
|
||||
@NotNull
|
||||
protected static Document configureFromFileText(@NonNls @NotNull final String fileName, @NonNls @NotNull final String fileText) {
|
||||
return configureFromFileText(fileName, fileText, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Same as configureByFile but text is provided directly.
|
||||
* @param fileName - name of the file.
|
||||
* @param fileText - data file text.
|
||||
* @param checkCaret - if true, if will be verified that file contains at least one caret or selection marker
|
||||
*/
|
||||
@NotNull
|
||||
protected static Document configureFromFileText(@NonNls @NotNull final String fileName,
|
||||
@NonNls @NotNull final String fileText,
|
||||
boolean checkCaret) {
|
||||
return new WriteCommandAction<Document>(null) {
|
||||
@Override
|
||||
protected void run(@NotNull Result<Document> result) throws Throwable {
|
||||
final Document fakeDocument = new DocumentImpl(fileText);
|
||||
|
||||
EditorTestUtil.CaretAndSelectionState caretsState = EditorTestUtil.extractCaretAndSelectionMarkers(fakeDocument);
|
||||
if(checkCaret) {
|
||||
assertTrue("No caret specified in " + fileName, caretsState.hasExplicitCaret());
|
||||
}
|
||||
|
||||
String newFileText = fakeDocument.getText();
|
||||
Document document;
|
||||
|
||||
Reference in New Issue
Block a user