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:
Andrey Breslav
2012-09-19 15:29:40 +04:00
parent 0ccdf79051
commit bd0eab5202
9 changed files with 33 additions and 13 deletions
@@ -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);
@@ -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));
@@ -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>();