Tuple migration quick fix now appears only on tupels shorter than 4
Longer tuples exhibit another error message. Messages adjusted for compiler and IDE
This commit is contained in:
@@ -48,7 +48,10 @@ import static org.jetbrains.jet.lang.diagnostics.Severity.WARNING;
|
||||
public interface Errors {
|
||||
|
||||
// TODO: Temporary error message: to deprecate tuples we report this error and provide a quick fix
|
||||
@Deprecated // Tuples will be dropped in Kotlin M4
|
||||
SimpleDiagnosticFactory<PsiElement> TUPLES_ARE_NOT_SUPPORTED = SimpleDiagnosticFactory.create(ERROR);
|
||||
@Deprecated // Tuples will be dropped in Kotlin M4
|
||||
SimpleDiagnosticFactory<PsiElement> TUPLES_ARE_NOT_SUPPORTED_BIG = SimpleDiagnosticFactory.create(ERROR);
|
||||
|
||||
DiagnosticFactory1<JetFile, Throwable> EXCEPTION_WHILE_ANALYZING = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
|
||||
+2
-1
@@ -47,7 +47,8 @@ public class DefaultErrorMessages {
|
||||
static {
|
||||
|
||||
// TODO: remove when tuples are completely dropped
|
||||
MAP.put(TUPLES_ARE_NOT_SUPPORTED, "Tuples are not supported. Press Alt+Enter to replace tuples with library classes");
|
||||
MAP.put(TUPLES_ARE_NOT_SUPPORTED, "Tuples are not supported. In the IDE you can use Alt+Enter to replace tuples with library classes");
|
||||
MAP.put(TUPLES_ARE_NOT_SUPPORTED_BIG, "Tuples are not supported. Use data classes instead");
|
||||
|
||||
MAP.put(EXCEPTION_WHILE_ANALYZING, "{0}", new Renderer<Throwable>() {
|
||||
@NotNull
|
||||
|
||||
@@ -37,9 +37,7 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.TUPLES_ARE_NOT_SUPPORTED;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.UNSUPPORTED;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.WRONG_NUMBER_OF_TYPE_ARGUMENTS;
|
||||
import static org.jetbrains.jet.lang.diagnostics.Errors.*;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
@@ -182,7 +180,12 @@ public class TypeResolver {
|
||||
@Override
|
||||
public void visitTupleType(JetTupleType type) {
|
||||
// TODO: remove this method completely when tuples are droppped
|
||||
trace.report(TUPLES_ARE_NOT_SUPPORTED.on(type));
|
||||
if (type.getComponentTypeRefs().size() <= 3) {
|
||||
trace.report(TUPLES_ARE_NOT_SUPPORTED.on(type));
|
||||
}
|
||||
else {
|
||||
trace.report(TUPLES_ARE_NOT_SUPPORTED_BIG.on(type));
|
||||
}
|
||||
|
||||
// TODO labels
|
||||
result[0] = JetStandardClasses.getTupleType(resolveTypes(scope, type.getComponentTypeRefs(), trace, checkBounds));
|
||||
|
||||
+6
-1
@@ -357,7 +357,12 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
@Override
|
||||
public JetTypeInfo visitTupleExpression(JetTupleExpression expression, ExpressionTypingContext context) {
|
||||
// TODO: remove this method completely when tuples are droppped
|
||||
context.trace.report(TUPLES_ARE_NOT_SUPPORTED.on(expression));
|
||||
if (expression.getEntries().size() <= 3) {
|
||||
context.trace.report(TUPLES_ARE_NOT_SUPPORTED.on(expression));
|
||||
}
|
||||
else {
|
||||
context.trace.report(TUPLES_ARE_NOT_SUPPORTED_BIG.on(expression));
|
||||
}
|
||||
|
||||
List<JetExpression> entries = expression.getEntries();
|
||||
List<JetType> types = new ArrayList<JetType>();
|
||||
|
||||
@@ -41,6 +41,14 @@ public class IdeErrorMessages {
|
||||
public static final DiagnosticRenderer<Diagnostic> RENDERER = new DispatchingDiagnosticRenderer(MAP, DefaultErrorMessages.MAP);
|
||||
|
||||
static {
|
||||
// TODO: Remove when tuples are completely dropped
|
||||
MAP.put(TUPLES_ARE_NOT_SUPPORTED, "<html>Tuples are not supported. Press <b>Alt+Enter</b> to replace tuples with library classes</html>");
|
||||
MAP.put(TUPLES_ARE_NOT_SUPPORTED_BIG, "<html>" +
|
||||
"Tuples are not supported.<br/>" +
|
||||
"Use data classes instead. For example:<br/>" +
|
||||
"<b>data class</b> FourThings(<b>val</b> a: A, <b>val</b> b: B, <b>val</b> c: C, <b>val</b> d: D)" +
|
||||
"</html>");
|
||||
|
||||
MAP.put(TYPE_MISMATCH, "<html>Type mismatch.<table><tr><td>Required:</td><td>{0}</td></tr><tr><td>Found:</td><td>{1}</td></tr></table></html>",
|
||||
HTML_RENDER_TYPE, HTML_RENDER_TYPE);
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// "Migrate tuples in project: e.g., #(,) and #(,,) will be replaced by Pair and Triple" "true"
|
||||
// ERROR: Tuples are not supported. Press Alt+Enter to replace tuples with library classes
|
||||
// ERROR: Tuples are not supported. Press Alt+Enter to replace tuples with library classes
|
||||
// ERROR: <html>Tuples are not supported.<br/>Use data classes instead. For example:<br/><b>data class</b> FourThings(<b>val</b> a: A, <b>val</b> b: B, <b>val</b> c: C, <b>val</b> d: D)</html>
|
||||
// ERROR: <html>Tuples are not supported.<br/>Use data classes instead. For example:<br/><b>data class</b> FourThings(<b>val</b> a: A, <b>val</b> b: B, <b>val</b> c: C, <b>val</b> d: D)</html>
|
||||
|
||||
fun foo2() : Pair<Int, Int> {
|
||||
return Pair(1, 1)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
// "Migrate tuples in project: e.g., #(,) and #(,,) will be replaced by Pair and Triple" "true"
|
||||
// ERROR: Tuples are not supported. Press Alt+Enter to replace tuples with library classes
|
||||
// ERROR: Tuples are not supported. Press Alt+Enter to replace tuples with library classes
|
||||
// ERROR: <html>Tuples are not supported.<br/>Use data classes instead. For example:<br/><b>data class</b> FourThings(<b>val</b> a: A, <b>val</b> b: B, <b>val</b> c: C, <b>val</b> d: D)</html>
|
||||
// ERROR: <html>Tuples are not supported.<br/>Use data classes instead. For example:<br/><b>data class</b> FourThings(<b>val</b> a: A, <b>val</b> b: B, <b>val</b> c: C, <b>val</b> d: D)</html>
|
||||
|
||||
fun foo2() : <caret>#(Int, Int) {
|
||||
return #(1, 1)
|
||||
|
||||
@@ -130,11 +130,11 @@ public class JetQuickFixTest extends LightQuickFixTestCase {
|
||||
Collection<Diagnostic> diagnostics = exhaust.getBindingContext().getDiagnostics();
|
||||
|
||||
if (diagnostics.size() != 0) {
|
||||
String[] expectedErrorStrings = InTextDirectivesUtils.findListWithPrefix("// ERROR:", getFile().getText());
|
||||
List<String> expectedErrorStrings = InTextDirectivesUtils.findLinesWithPrefixRemoved("// ERROR:", getFile().getText());
|
||||
|
||||
System.out.println(getFile().getText());
|
||||
|
||||
Collection<String> expectedErrors = new HashSet<String>(Arrays.asList(expectedErrorStrings));
|
||||
Collection<String> expectedErrors = new HashSet<String>(expectedErrorStrings);
|
||||
|
||||
StringBuilder builder = new StringBuilder();
|
||||
boolean hasErrors = false;
|
||||
|
||||
@@ -61,7 +61,7 @@ public final class InTextDirectivesUtils {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static List<String> findLinesWithPrefixRemoved(String prefix, String fileText) {
|
||||
public static List<String> findLinesWithPrefixRemoved(String prefix, String fileText) {
|
||||
ArrayList<String> result = new ArrayList<String>();
|
||||
|
||||
for (String line : fileNonEmptyLines(fileText)) {
|
||||
|
||||
Reference in New Issue
Block a user