Merge remote branch 'origin/master'
This commit is contained in:
@@ -69,6 +69,7 @@ public class KotlinCompiler {
|
||||
environment.addToClasspath(rtJar);
|
||||
|
||||
environment.registerFileType(JetFileType.INSTANCE, "kt");
|
||||
environment.registerFileType(JetFileType.INSTANCE, "jet");
|
||||
environment.registerParserDefinition(new JetParserDefinition());
|
||||
|
||||
VirtualFile vFile = environment.getLocalFileSystem().findFileByPath(arguments.src);
|
||||
|
||||
@@ -20,6 +20,7 @@ import java.util.List;
|
||||
*/
|
||||
public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
private static FilenameFilter emptyFilter;
|
||||
private boolean checkInfos = false;
|
||||
private String dataPath;
|
||||
protected final String name;
|
||||
@@ -75,20 +76,49 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
emptyFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String name) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public interface NamedTestFactory {
|
||||
@NotNull Test createTest(@NotNull String dataPath, @NotNull String name);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, boolean recursive, @NotNull NamedTestFactory factory) {
|
||||
return suiteForDirectory(baseDataDir, dataPath, recursive, emptyFilter, factory);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static TestSuite suiteForDirectory(String baseDataDir, @NotNull final String dataPath, boolean recursive, final FilenameFilter filter, @NotNull NamedTestFactory factory) {
|
||||
TestSuite suite = new TestSuite(dataPath);
|
||||
final String extension = ".jet";
|
||||
FilenameFilter extensionFilter = new FilenameFilter() {
|
||||
final String extensionJet = ".jet";
|
||||
final String extensionKt = ".kt";
|
||||
final FilenameFilter extensionFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File dir, String name) {
|
||||
return name.endsWith(extension);
|
||||
return name.endsWith(extensionJet) || name.endsWith(extensionKt);
|
||||
}
|
||||
};
|
||||
FilenameFilter resultFilter;
|
||||
if (filter != emptyFilter) {
|
||||
resultFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String s) {
|
||||
if (extensionFilter.accept(file, s) && filter.accept(file, s)) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
else {
|
||||
resultFilter = extensionFilter;
|
||||
}
|
||||
File dir = new File(baseDataDir + dataPath);
|
||||
FileFilter dirFilter = new FileFilter() {
|
||||
@Override
|
||||
@@ -105,11 +135,12 @@ public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
suite.addTest(suiteForDirectory(baseDataDir, dataPath + "/" + subdir.getName(), recursive, factory));
|
||||
}
|
||||
}
|
||||
List<File> files = Arrays.asList(dir.listFiles(extensionFilter));
|
||||
List<File> files = Arrays.asList(dir.listFiles(resultFilter));
|
||||
Collections.sort(files);
|
||||
for (File file : files) {
|
||||
String fileName = file.getName();
|
||||
assert fileName != null;
|
||||
String extension = fileName.endsWith(extensionJet) ? extensionJet : extensionKt;
|
||||
suite.addTest(factory.createTest(dataPath, fileName.substring(0, fileName.length() - extension.length())));
|
||||
}
|
||||
return suite;
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
package org.jetbrains.jet.plugin;
|
||||
|
||||
import com.intellij.CommonBundle;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.PropertyKey;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.lang.ref.SoftReference;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class JetBundle {
|
||||
private static Reference<ResourceBundle> ourBundle;
|
||||
|
||||
@NonNls
|
||||
private static final String BUNDLE = "org.jetbrains.jet.plugin.JetBundle";
|
||||
|
||||
private JetBundle() {
|
||||
}
|
||||
|
||||
public static String message(@NonNls @PropertyKey(resourceBundle = BUNDLE)String key, Object... params) {
|
||||
return CommonBundle.message(getBundle(), key, params);
|
||||
}
|
||||
|
||||
private static ResourceBundle getBundle() {
|
||||
ResourceBundle bundle = null;
|
||||
if (ourBundle != null) bundle = ourBundle.get();
|
||||
if (bundle == null) {
|
||||
bundle = ResourceBundle.getBundle(BUNDLE);
|
||||
ourBundle = new SoftReference<ResourceBundle>(bundle);
|
||||
}
|
||||
return bundle;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
#quick fix messages
|
||||
add.function.body=Add function body
|
||||
add.primary.constructor=Add primary constructor to {0}
|
||||
add.primary.constructor.family=Add primary constructor
|
||||
add.return.type=Add return type declaration
|
||||
change.accessor.type=Change accessor type
|
||||
change.getter.type=Change getter type to {0}
|
||||
change.setter.type=Change setter parameter type to {0}
|
||||
make.variable.immutable=Make variable immutable
|
||||
make.variable.mutable=Make variable mutable
|
||||
change.variable.mutability.family=Change variable mutability
|
||||
remove.function.body=Remove function body
|
||||
make.element.modifier=Make {0} {1}
|
||||
add.modifier=Add ''{0}'' modifier
|
||||
make.element.not.modifier=Make {0} not {1}
|
||||
remove.modifier=Remove ''{0}'' modifier
|
||||
remove.modifier.family=Remove modifier
|
||||
remove.redundant.modifier=Remove redundant ''{0}'' modifier
|
||||
remove.parts.from.property=Remove {0} from property
|
||||
remove.parts.from.property.family=Remove parts from property
|
||||
remove.right.part.of.binary.expression=Remove right part of a binary expression
|
||||
remove.cast=Remove cast
|
||||
remove.elvis.operator=Remove elvis operator
|
||||
replace.operation.in.binary.expression=Replace operation in a binary expression
|
||||
replace.cast.with.static.assert=Replace a cast with a static assert
|
||||
replace.with.dot.call=Replace with dot call
|
||||
@@ -8,6 +8,7 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -20,13 +21,13 @@ public class AddFunctionBodyFix extends JetIntentionAction<JetFunction> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Add function body";
|
||||
return JetBundle.message("add.function.body");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Add function body";
|
||||
return JetBundle.message("add.function.body");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lexer.JetKeywordToken;
|
||||
import org.jetbrains.jet.lexer.JetToken;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -51,9 +52,9 @@ public class AddModifierFix extends JetIntentionAction<JetModifierListOwner> {
|
||||
@Override
|
||||
public String getText() {
|
||||
if (modifier == JetTokens.ABSTRACT_KEYWORD || modifier == JetTokens.OPEN_KEYWORD) {
|
||||
return "Make " + getElementName(element) + " " + modifier.getValue();
|
||||
return JetBundle.message("make.element.modifier", getElementName(element), modifier.getValue());
|
||||
}
|
||||
return "Add '" + modifier.getValue() + "' modifier";
|
||||
return JetBundle.message("add.modifier", modifier.getValue());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -9,6 +9,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetClass;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -22,13 +23,13 @@ public class AddPrimaryConstructorFix extends JetIntentionAction<JetClass> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Add primary constructor to " + element.getName();
|
||||
return JetBundle.message("add.primary.constructor", element.getName());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Add primary constructor";
|
||||
return JetBundle.message("add.primary.constructor.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -27,13 +28,13 @@ public class AddReturnTypeFix extends JetIntentionAction<JetNamedDeclaration> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Add return type declaration";
|
||||
return JetBundle.message("add.return.type");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Add return type declaration";
|
||||
return JetBundle.message("add.return.type");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -15,6 +15,7 @@ import org.jetbrains.jet.lang.psi.JetPropertyAccessor;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.psi.JetTypeReference;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -30,13 +31,13 @@ public class ChangeAccessorTypeFix extends JetIntentionAction<JetPropertyAccesso
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return (element.isGetter() ? "Change getter " : "Change setter parameter ") + "type to " + type;
|
||||
return element.isGetter() ? JetBundle.message("change.getter.type", type) : JetBundle.message("change.setter.type", type);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Change accessor type";
|
||||
return JetBundle.message("change.accessor.type");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetProperty;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -23,13 +24,13 @@ public class ChangeVariableMutabilityFix extends JetIntentionAction<JetProperty>
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Make variable " + (element.isVar() ? "immutable" : "mutable");
|
||||
return element.isVar() ? JetBundle.message("make.variable.immutable") : JetBundle.message("make.variable.mutable");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Change variable mutability";
|
||||
return JetBundle.message("change.variable.mutability.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -81,7 +81,7 @@ public class QuickFixes {
|
||||
|
||||
add(Errors.USELESS_ELVIS, RemoveRightPartOfBinaryExpressionFix.createRemoveElvisOperatorFactory());
|
||||
|
||||
add(Errors.UNNECESSARY_SAFE_CALL, ReplaceSafeCallToDotCall.createFactory());
|
||||
add(Errors.UNNECESSARY_SAFE_CALL, ReplaceSafeCallWithDotCall.createFactory());
|
||||
|
||||
JetIntentionActionFactory<JetModifierList> removeRedundantModifierFactory = RemoveModifierFix.createRemoveModifierFromListFactory(true);
|
||||
add(Errors.REDUNDANT_MODIFIER, removeRedundantModifierFactory);
|
||||
|
||||
@@ -13,6 +13,7 @@ import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetFunction;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -26,13 +27,13 @@ public class RemoveFunctionBodyFix extends JetIntentionAction<JetFunction> {
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove function body";
|
||||
return JetBundle.message("remove.function.body");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Remove function body";
|
||||
return JetBundle.message("remove.function.body");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -17,6 +17,7 @@ import org.jetbrains.jet.lang.psi.JetModifierListOwner;
|
||||
import org.jetbrains.jet.lexer.JetKeywordToken;
|
||||
import org.jetbrains.jet.lexer.JetToken;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -32,16 +33,16 @@ public class RemoveModifierFix {
|
||||
|
||||
private static String makeText(@Nullable JetModifierListOwner element, JetKeywordToken modifier, boolean isRedundant) {
|
||||
if (isRedundant) {
|
||||
return "Remove redundant '" + modifier.getValue() + "' modifier";
|
||||
return JetBundle.message("remove.redundant.modifier", modifier.getValue());
|
||||
}
|
||||
if (element != null && modifier == JetTokens.ABSTRACT_KEYWORD || modifier == JetTokens.OPEN_KEYWORD) {
|
||||
return "Make " + AddModifierFix.getElementName(element) + " not " + modifier.getValue();
|
||||
return JetBundle.message("make.element.not.modifier", AddModifierFix.getElementName(element), modifier.getValue());
|
||||
}
|
||||
return "Remove '" + modifier.getValue() + "' modifier";
|
||||
return JetBundle.message("remove.modifier", modifier.getValue());
|
||||
}
|
||||
|
||||
private static String getFamilyName() {
|
||||
return "Remove modifier fix";
|
||||
return JetBundle.message("remove.modifier.family");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -12,6 +12,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithParameters;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -66,13 +67,13 @@ public class RemovePartsFromPropertyFix extends JetIntentionAction<JetProperty>
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove " + partsToRemove(removeGetter, removeSetter, removeInitializer) + " from property";
|
||||
return JetBundle.message("remove.parts.from.property", partsToRemove(removeGetter, removeSetter, removeInitializer));
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Remove parts from property to make it abstract";
|
||||
return JetBundle.message("remove.parts.from.property.family");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-3
@@ -9,6 +9,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpressionWithTypeRHS;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -21,7 +22,7 @@ public abstract class RemoveRightPartOfBinaryExpressionFix<T extends JetExpressi
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Remove right part of a binary expression";
|
||||
return JetBundle.message("remove.right.part.of.binary.expression");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +46,7 @@ public abstract class RemoveRightPartOfBinaryExpressionFix<T extends JetExpressi
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove cast";
|
||||
return JetBundle.message("remove.cast");
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -61,7 +62,7 @@ public abstract class RemoveRightPartOfBinaryExpressionFix<T extends JetExpressi
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Remove elvis operator";
|
||||
return JetBundle.message("remove.elvis.operator");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+3
-2
@@ -10,6 +10,7 @@ import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.JetBinaryExpressionWithTypeRHS;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
@@ -24,7 +25,7 @@ public abstract class ReplaceOperationInBinaryExpressionFix<T extends JetExpress
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Replace operation in a binary expression";
|
||||
return JetBundle.message("replace.operation.in.binary.expression");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,7 +49,7 @@ public abstract class ReplaceOperationInBinaryExpressionFix<T extends JetExpress
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Replace a cast with a static assert";
|
||||
return JetBundle.message("replace.cast.with.static.assert");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
+6
-5
@@ -8,26 +8,27 @@ import com.intellij.util.IncorrectOperationException;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithPsiElement;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
import org.jetbrains.jet.plugin.JetBundle;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class ReplaceSafeCallToDotCall extends JetIntentionAction<JetElement> {
|
||||
public class ReplaceSafeCallWithDotCall extends JetIntentionAction<JetElement> {
|
||||
|
||||
public ReplaceSafeCallToDotCall(@NotNull JetElement element) {
|
||||
public ReplaceSafeCallWithDotCall(@NotNull JetElement element) {
|
||||
super(element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getText() {
|
||||
return "Replace to dot call";
|
||||
return JetBundle.message("replace.with.dot.call");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public String getFamilyName() {
|
||||
return "Replace safe call to dot call";
|
||||
return JetBundle.message("replace.with.dot.call");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -55,7 +56,7 @@ public class ReplaceSafeCallToDotCall extends JetIntentionAction<JetElement> {
|
||||
@Override
|
||||
public JetIntentionAction<JetElement> createAction(DiagnosticWithPsiElement diagnostic) {
|
||||
assert diagnostic.getPsiElement() instanceof JetElement;
|
||||
return new ReplaceSafeCallToDotCall((JetElement) diagnostic.getPsiElement());
|
||||
return new ReplaceSafeCallWithDotCall((JetElement) diagnostic.getPsiElement());
|
||||
}
|
||||
};
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace to dot call" "true"
|
||||
// "Replace with dot call" "true"
|
||||
fun foo(a: Any) {
|
||||
<caret>a.equals(0)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace to dot call" "true"
|
||||
// "Replace with dot call" "true"
|
||||
fun foo(a: Any) {
|
||||
when (a) {
|
||||
.equals(0) => true
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace to dot call" "true"
|
||||
// "Replace with dot call" "true"
|
||||
fun foo(a: Any) {
|
||||
a<caret>?.equals(0)
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// "Replace to dot call" "true"
|
||||
// "Replace with dot call" "true"
|
||||
fun foo(a: Any) {
|
||||
when (a) {
|
||||
<caret>?.equals(0) => true
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class AbstractModifierFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/abstract";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class AddPrimaryConstructorFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/addPrimaryConstructor";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
@@ -1,23 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class ChangeVariableMutabilityFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/changeVariableMutability";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
@@ -1,32 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class ClassImportFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/classImport";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JetTestCaseBase.jdkFromIdeaHome();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,24 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class ExpressionsFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/expressions";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,96 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FilenameFilter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class JetQuickFixTest extends LightQuickFixTestCase {
|
||||
private final String dataPath;
|
||||
private final String name;
|
||||
private static FilenameFilter quickFixTestsFilter;
|
||||
|
||||
public JetQuickFixTest(String dataPath, String name) {
|
||||
this.dataPath = dataPath;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
private static void setFilter() {
|
||||
final ArrayList<String> appropriateDirs = Lists.newArrayList("classImport", "expressions");
|
||||
quickFixTestsFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String s) {
|
||||
if (appropriateDirs.contains(s)) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
//setFilter(); //to launch only part of tests
|
||||
TestSuite suite = new TestSuite();
|
||||
FilenameFilter fileNameFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String s) {
|
||||
if (s.startsWith("before")) return true;
|
||||
return false;
|
||||
}
|
||||
};
|
||||
JetTestCaseBase.NamedTestFactory namedTestFactory = new JetTestCaseBase.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
return new JetQuickFixTest(dataPath, name);
|
||||
}
|
||||
};
|
||||
File dir = new File(getTestDataPathBase());
|
||||
List<String> subDirs = Arrays.asList(quickFixTestsFilter != null ? dir.list(quickFixTestsFilter) : dir.list());
|
||||
Collections.sort(subDirs);
|
||||
for (String subDirName : subDirs) {
|
||||
suite.addTest(JetTestCaseBase.suiteForDirectory(getTestDataPathBase(), subDirName, false, fileNameFilter, namedTestFactory));
|
||||
|
||||
}
|
||||
return suite;
|
||||
}
|
||||
|
||||
public static String getTestDataPathBase() {
|
||||
return JetTestCaseBase.getHomeDirectory() + "/idea/testData/quickfix/";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "test" + name.replaceFirst(name.substring(0, 1), name.substring(0, 1).toUpperCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
doSingleTest(name.substring("before".length()) + ".kt");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/" + dataPath;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JetTestCaseBase.jdkFromIdeaHome();
|
||||
}
|
||||
}
|
||||
@@ -1,26 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class ModifiersFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/modifiers";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,25 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class OverrideModifierFixTest extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/override";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,31 +0,0 @@
|
||||
package org.jetbrains.jet.plugin.quickfix;
|
||||
|
||||
import com.intellij.codeInsight.daemon.quickFix.LightQuickFixTestCase;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class TypeAdditionFixTests extends LightQuickFixTestCase {
|
||||
|
||||
public void test() throws Exception {
|
||||
doAllTests();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getBasePath() {
|
||||
return "/quickfix/typeAddition";
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PluginTestCaseBase.getTestDataPathBase();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JetTestCaseBase.jdkFromIdeaHome();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user