mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
notnull
This commit is contained in:
+2
-1
@@ -17,13 +17,14 @@ package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInsight.template.impl.TemplateManagerImpl;
|
||||
import com.intellij.codeInsight.template.impl.TemplateState;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author anna
|
||||
*/
|
||||
public class DelegateWithDefaultParamValueTest extends LightQuickFixParameterizedTestCase {
|
||||
@Override
|
||||
protected void doAction(String text, boolean actionShouldBeAvailable, String testFullPath, String testName)
|
||||
protected void doAction(@NotNull String text, boolean actionShouldBeAvailable, String testFullPath, String testName)
|
||||
throws Exception {
|
||||
TemplateManagerImpl.setTemplateTesting(getProject(), getTestRootDisposable());
|
||||
super.doAction(text, actionShouldBeAvailable, testFullPath, testName);
|
||||
|
||||
+1
-1
@@ -17,7 +17,7 @@ public class EnableOptimizeImportsOnTheFlyTest extends LightQuickFixParameterize
|
||||
public void test() throws Exception { doAllTests(); }
|
||||
|
||||
@Override
|
||||
protected void doAction(final String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
|
||||
protected void doAction(@NotNull final String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
|
||||
throws Exception {
|
||||
boolean old = CodeInsightSettings.getInstance().OPTIMIZE_IMPORTS_ON_THE_FLY;
|
||||
|
||||
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
package com.intellij.codeInsight.daemon.quickFix;
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* tests corresponding intention for availability only, does not invoke action
|
||||
@@ -8,7 +9,7 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
*/
|
||||
public abstract class LightQuickFixAvailabilityTestCase extends LightQuickFixParameterizedTestCase {
|
||||
@Override
|
||||
protected void doAction(final String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
|
||||
protected void doAction(@NotNull final String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
|
||||
throws Exception {
|
||||
IntentionAction action = findActionWithText(text);
|
||||
assertTrue("Action with text '" + text + "' is " + (action == null ? "not " :"") +
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ public class ConvertParameterToLocalVariableTest extends LightQuickFixParameteri
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doAction(final String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
|
||||
protected void doAction(@NotNull final String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
|
||||
throws Exception {
|
||||
|
||||
final LocalQuickFix fix = new ParameterCanBeLocalInspection.ConvertParameterToLocalQuickFix();
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ public class InlineSameParameterValueTest extends LightQuickFixParameterizedTest
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void doAction(final String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
|
||||
protected void doAction(@NotNull final String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
|
||||
throws Exception {
|
||||
final LocalQuickFix fix = (LocalQuickFix)new SameParameterValueInspection().getQuickFix(text);
|
||||
assert fix != null;
|
||||
|
||||
+22
-19
@@ -35,13 +35,13 @@ import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
import com.intellij.testFramework.LightPlatformTestCase;
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
import com.intellij.util.IncorrectOperationException;
|
||||
import com.intellij.util.ObjectUtils;
|
||||
import com.intellij.util.ui.UIUtil;
|
||||
import org.intellij.lang.annotations.RegExp;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@@ -49,8 +49,6 @@ import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.notNull;
|
||||
|
||||
public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase {
|
||||
@NonNls protected static final String BEFORE_PREFIX = "before";
|
||||
@NonNls protected static final String AFTER_PREFIX = "after";
|
||||
@@ -61,12 +59,13 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
return false;
|
||||
}
|
||||
|
||||
protected Pair<String, Boolean> parseActionHintImpl(final PsiFile file, String contents) {
|
||||
@NotNull
|
||||
protected Pair<String, Boolean> parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents) {
|
||||
return parseActionHint(file, contents);
|
||||
}
|
||||
|
||||
private static void doTestFor(final String testName, final QuickFixTestCase quickFixTestCase) {
|
||||
final String relativePath = notNull(quickFixTestCase.getBasePath(), "") + "/" + BEFORE_PREFIX + testName;
|
||||
final String relativePath = ObjectUtils.notNull(quickFixTestCase.getBasePath(), "") + "/" + BEFORE_PREFIX + testName;
|
||||
final String testFullPath = quickFixTestCase.getTestDataPath().replace(File.separatorChar, '/') + relativePath;
|
||||
final File testFile = new File(testFullPath);
|
||||
CommandProcessor.getInstance().executeCommand(quickFixTestCase.getProject(), () -> {
|
||||
@@ -105,7 +104,8 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
protected void beforeActionStarted(final String testName, final String contents) {
|
||||
}
|
||||
|
||||
public static Pair<String, Boolean> parseActionHint(final PsiFile file, String contents) {
|
||||
@NotNull
|
||||
public static Pair<String, Boolean> parseActionHint(@NotNull PsiFile file, @NotNull String contents) {
|
||||
return parseActionHint(file, contents, " \"(.*)\" \"(true|false)\".*");
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
return Pair.create(text, actionShouldBeAvailable);
|
||||
}
|
||||
|
||||
public static void doAction(String text,
|
||||
public static void doAction(@NotNull String text,
|
||||
boolean actionShouldBeAvailable,
|
||||
String testFullPath,
|
||||
String testName,
|
||||
@@ -140,7 +140,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
if (action == null) {
|
||||
if (actionShouldBeAvailable) {
|
||||
List<IntentionAction> actions = quickFix.getAvailableActions();
|
||||
List<String> texts = new ArrayList<String>();
|
||||
List<String> texts = new ArrayList<>();
|
||||
for (IntentionAction intentionAction : actions) {
|
||||
texts.add(intentionAction.getText());
|
||||
}
|
||||
@@ -162,33 +162,33 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
fail("Action '" + text + "' is still available after its invocation in test " + testFullPath);
|
||||
}
|
||||
}
|
||||
String expectedFilePath = notNull(quickFix.getBasePath(), "") + "/" + AFTER_PREFIX + testName;
|
||||
String expectedFilePath = ObjectUtils.notNull(quickFix.getBasePath(), "") + "/" + AFTER_PREFIX + testName;
|
||||
quickFix.checkResultByFile("In file :" + expectedFilePath, expectedFilePath, false);
|
||||
}
|
||||
}
|
||||
|
||||
protected void doAction(final String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
|
||||
protected void doAction(@NotNull String text, final boolean actionShouldBeAvailable, final String testFullPath, final String testName)
|
||||
throws Exception {
|
||||
doAction(text, actionShouldBeAvailable, testFullPath, testName, myWrapper);
|
||||
}
|
||||
|
||||
protected void doAction(final String actionName) {
|
||||
protected void doAction(@NotNull String actionName) {
|
||||
final List<IntentionAction> available = getAvailableActions();
|
||||
final IntentionAction action = findActionWithText(available, actionName);
|
||||
assertNotNull("Action '" + actionName + "' not found among " + available.toString(), action);
|
||||
assertNotNull("Action '" + actionName + "' not found among " + available, action);
|
||||
invoke(action);
|
||||
}
|
||||
|
||||
protected static void invoke(IntentionAction action) throws IncorrectOperationException {
|
||||
protected static void invoke(@NotNull IntentionAction action) throws IncorrectOperationException {
|
||||
ShowIntentionActionsHandler.chooseActionAndInvoke(getFile(), getEditor(), action, action.getText());
|
||||
UIUtil.dispatchAllInvocationEvents();
|
||||
}
|
||||
|
||||
protected IntentionAction findActionWithText(final String text) {
|
||||
protected IntentionAction findActionWithText(@NotNull String text) {
|
||||
return findActionWithText(getAvailableActions(), text);
|
||||
}
|
||||
|
||||
public static IntentionAction findActionWithText(@NotNull List<IntentionAction> actions, final String text) {
|
||||
public static IntentionAction findActionWithText(@NotNull List<IntentionAction> actions, @NotNull String text) {
|
||||
for (IntentionAction action : actions) {
|
||||
if (text.equals(action.getText())) {
|
||||
return action;
|
||||
@@ -198,7 +198,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated use {@link com.intellij.codeInsight.daemon.quickFix.LightQuickFixParameterizedTestCase}
|
||||
* @deprecated use {@link LightQuickFixParameterizedTestCase}
|
||||
* to get separate tests for all data files in testData directory.
|
||||
*/
|
||||
protected void doAllTests() {
|
||||
@@ -215,7 +215,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static File[] getBeforeTestFiles(QuickFixTestCase testCase) {
|
||||
public static File[] getBeforeTestFiles(@NotNull QuickFixTestCase testCase) {
|
||||
assertNotNull("getBasePath() should not return null!", testCase.getBasePath());
|
||||
|
||||
final String testDirPath = testCase.getTestDataPath().replace(File.separatorChar, '/') + testCase.getBasePath();
|
||||
@@ -257,8 +257,9 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
return myTestDataPath;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Pair<String, Boolean> parseActionHintImpl(PsiFile file, String contents) {
|
||||
public Pair<String, Boolean> parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents) {
|
||||
return LightQuickFixTestCase.this.parseActionHintImpl(file, contents);
|
||||
}
|
||||
|
||||
@@ -278,7 +279,7 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
}
|
||||
|
||||
@Override
|
||||
public void checkResultByFile(String s, String expectedFilePath, boolean b) throws Exception {
|
||||
public void checkResultByFile(String s, @NotNull String expectedFilePath, boolean b) throws Exception {
|
||||
LightQuickFixTestCase.this.checkResultByFile(s, expectedFilePath, b);
|
||||
}
|
||||
|
||||
@@ -297,11 +298,13 @@ public abstract class LightQuickFixTestCase extends LightDaemonAnalyzerTestCase
|
||||
LightQuickFixTestCase.invoke(action);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<HighlightInfo> doHighlighting() {
|
||||
return LightQuickFixTestCase.this.doHighlighting();
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public List<IntentionAction> getAvailableActions() {
|
||||
return LightQuickFixTestCase.this.getAvailableActions();
|
||||
|
||||
+6
-2
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.intention.IntentionAction;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -33,7 +34,8 @@ public interface QuickFixTestCase {
|
||||
|
||||
String getTestDataPath();
|
||||
|
||||
Pair<String, Boolean> parseActionHintImpl(PsiFile file, String contents);
|
||||
@NotNull
|
||||
Pair<String, Boolean> parseActionHintImpl(@NotNull PsiFile file, @NotNull String contents);
|
||||
|
||||
void beforeActionStarted(String testName, String contents);
|
||||
|
||||
@@ -41,7 +43,7 @@ public interface QuickFixTestCase {
|
||||
|
||||
void doAction(String text, boolean actionShouldBeAvailable, String testFullPath, String testName) throws Exception;
|
||||
|
||||
void checkResultByFile(String s, String expectedFilePath, boolean b) throws Exception;
|
||||
void checkResultByFile(String s, @NotNull String expectedFilePath, boolean b) throws Exception;
|
||||
|
||||
IntentionAction findActionWithText(String text);
|
||||
|
||||
@@ -49,8 +51,10 @@ public interface QuickFixTestCase {
|
||||
|
||||
void invoke(IntentionAction action);
|
||||
|
||||
@NotNull
|
||||
List<HighlightInfo> doHighlighting();
|
||||
|
||||
@NotNull
|
||||
List<IntentionAction> getAvailableActions();
|
||||
|
||||
void bringRealEditorBack();
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ public class FetchExternalResourcesFixTest extends LightQuickFixParameterizedTes
|
||||
|
||||
// just check for action availability
|
||||
@Override
|
||||
protected void doAction(String text, boolean actionShouldBeAvailable, String testFullPath, String testName) throws Exception {
|
||||
protected void doAction(@NotNull String text, boolean actionShouldBeAvailable, String testFullPath, String testName) throws Exception {
|
||||
IntentionAction action = findActionWithText(text);
|
||||
if (action == null && actionShouldBeAvailable) {
|
||||
fail("Action with text '" + text + "' is not available in test " + testFullPath);
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ public class IgnoreExternalResourcesFixTest extends LightQuickFixParameterizedTe
|
||||
|
||||
// just check for action availability
|
||||
@Override
|
||||
protected void doAction(String text, boolean actionShouldBeAvailable, String testFullPath, String testName) throws Exception {
|
||||
protected void doAction(@NotNull String text, boolean actionShouldBeAvailable, String testFullPath, String testName) throws Exception {
|
||||
IntentionAction action = findActionWithText(text);
|
||||
if (action == null && actionShouldBeAvailable) {
|
||||
fail("Action with text '" + text + "' is not available in test " + testFullPath);
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ public class ManuallySetupExternalResourcesFixTest extends LightQuickFixParamete
|
||||
|
||||
// just check for action availability
|
||||
@Override
|
||||
protected void doAction(String text, boolean actionShouldBeAvailable, String testFullPath, String testName) throws Exception {
|
||||
protected void doAction(@NotNull String text, boolean actionShouldBeAvailable, String testFullPath, String testName) throws Exception {
|
||||
IntentionAction action = findActionWithText(text);
|
||||
if (action == null && actionShouldBeAvailable) {
|
||||
fail("Action with text '" + text + "' is not available in test " + testFullPath);
|
||||
|
||||
Reference in New Issue
Block a user