diff --git a/.idea/inspectionProfiles/idea_default.xml b/.idea/inspectionProfiles/idea_default.xml
index 87c20723c79..8014ee92b70 100644
--- a/.idea/inspectionProfiles/idea_default.xml
+++ b/.idea/inspectionProfiles/idea_default.xml
@@ -409,6 +409,9 @@
+
diff --git a/compiler/cli/src/org/jetbrains/jet/compiler/KotlinToJVMBytecodeCompiler.java b/compiler/cli/src/org/jetbrains/jet/compiler/KotlinToJVMBytecodeCompiler.java
index 6eb3fd6ef21..324b7740a4e 100644
--- a/compiler/cli/src/org/jetbrains/jet/compiler/KotlinToJVMBytecodeCompiler.java
+++ b/compiler/cli/src/org/jetbrains/jet/compiler/KotlinToJVMBytecodeCompiler.java
@@ -37,10 +37,8 @@ import org.jetbrains.jet.compiler.messages.CompilerMessageSeverity;
import org.jetbrains.jet.compiler.messages.MessageCollector;
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
-import org.jetbrains.jet.lang.diagnostics.Diagnostic;
-import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory;
-import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
-import org.jetbrains.jet.lang.diagnostics.Severity;
+import org.jetbrains.jet.lang.diagnostics.*;
+import org.jetbrains.jet.lang.diagnostics.rendering.DefaultErrorMessages;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetPsiUtil;
import org.jetbrains.jet.lang.resolve.BindingContext;
@@ -63,6 +61,7 @@ import java.util.List;
* @author abreslav
*/
public class KotlinToJVMBytecodeCompiler {
+ private static final SimpleDiagnosticFactory SYNTAX_ERROR_FACTORY = SimpleDiagnosticFactory.create(Severity.ERROR);
@Nullable
public static ClassFileFactory compileModule(
@@ -271,7 +270,7 @@ public class KotlinToJVMBytecodeCompiler {
public void visitErrorElement(PsiErrorElement element) {
String description = element.getErrorDescription();
String message = StringUtil.isEmpty(description) ? "Syntax error" : description;
- Diagnostic diagnostic = DiagnosticFactory.create(Severity.ERROR, message).on(element);
+ Diagnostic diagnostic = new SyntaxErrorDiagnostic(element, Severity.ERROR, message);
reportDiagnostic(messageCollectorWrapper, diagnostic);
}
});
@@ -326,7 +325,14 @@ public class KotlinToJVMBytecodeCompiler {
DiagnosticUtils.LineAndColumn lineAndColumn = DiagnosticUtils.getLineAndColumn(diagnostic);
VirtualFile virtualFile = diagnostic.getPsiFile().getVirtualFile();
String path = virtualFile == null ? null : virtualFile.getPath();
- collector.report(convertSeverity(diagnostic.getSeverity()), diagnostic.getMessage(), CompilerMessageLocation.create(path, lineAndColumn.getLine(), lineAndColumn.getColumn()));
+ String render;
+ if (diagnostic.getFactory() == SYNTAX_ERROR_FACTORY) {
+ render = ((SyntaxErrorDiagnostic)diagnostic).message;
+ }
+ else {
+ render = DefaultErrorMessages.RENDERER.render(diagnostic);
+ }
+ collector.report(convertSeverity(diagnostic.getSeverity()), render, CompilerMessageLocation.create(path, lineAndColumn.getLine(), lineAndColumn.getColumn()));
}
private static CompilerMessageSeverity convertSeverity(Severity severity) {
@@ -352,4 +358,13 @@ public class KotlinToJVMBytecodeCompiler {
collector.report(CompilerMessageSeverity.ERROR, message.toString(), CompilerMessageLocation.NO_LOCATION);
}
}
+
+ private static class SyntaxErrorDiagnostic extends SimpleDiagnostic {
+ private String message;
+
+ private SyntaxErrorDiagnostic(@NotNull PsiErrorElement psiElement, @NotNull Severity severity, String message) {
+ super(psiElement, SYNTAX_ERROR_FACTORY, severity);
+ this.message = message;
+ }
+ }
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java b/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java
index 88e8988b2c5..3cf3bedd3f3 100644
--- a/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java
+++ b/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java
@@ -320,12 +320,6 @@ public class CheckerTestUtil {
return SyntaxErrorDiagnosticFactory.instance;
}
- @NotNull
- @Override
- public String getMessage() {
- throw new IllegalStateException();
- }
-
@NotNull
@Override
public Severity getSeverity() {
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AbstractDiagnostic.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AbstractDiagnostic.java
index 3e1622aa486..33450c87fe2 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AbstractDiagnostic.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AbstractDiagnostic.java
@@ -25,15 +25,15 @@ import org.jetbrains.annotations.NotNull;
*/
public abstract class AbstractDiagnostic implements ParametrizedDiagnostic {
private final E psiElement;
- private final String message;
private final AbstractDiagnosticFactory factory;
private final Severity severity;
- public AbstractDiagnostic(@NotNull E psiElement, @NotNull AbstractDiagnosticFactory factory, @NotNull Severity severity, @NotNull String message) {
+ public AbstractDiagnostic(@NotNull E psiElement,
+ @NotNull AbstractDiagnosticFactory factory,
+ @NotNull Severity severity) {
this.psiElement = psiElement;
this.factory = factory;
this.severity = severity;
- this.message = message;
}
@NotNull
@@ -48,19 +48,12 @@ public abstract class AbstractDiagnostic implements Parame
return psiElement.getContainingFile();
}
- @NotNull
- @Override
- public String getMessage() {
- return message;
- }
-
@NotNull
@Override
public Severity getSeverity() {
return severity;
}
-
@Override
@NotNull
public E getPsiElement() {
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AbstractDiagnosticFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AbstractDiagnosticFactory.java
index 8d6198a8a58..aeebc9f633f 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AbstractDiagnosticFactory.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AbstractDiagnosticFactory.java
@@ -19,7 +19,7 @@ package org.jetbrains.jet.lang.diagnostics;
/**
* @author abreslav
*/
-public class AbstractDiagnosticFactory {
+public abstract class AbstractDiagnosticFactory {
private String name = null;
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AmbiguousDescriptorDiagnosticFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AmbiguousDescriptorDiagnosticFactory.java
index 57cf016fdb4..809012d233b 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AmbiguousDescriptorDiagnosticFactory.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/AmbiguousDescriptorDiagnosticFactory.java
@@ -17,11 +17,8 @@
package org.jetbrains.jet.lang.diagnostics;
import com.intellij.psi.PsiElement;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.CallableDescriptor;
import org.jetbrains.jet.lang.resolve.calls.ResolvedCall;
-import org.jetbrains.jet.resolve.DescriptorRenderer;
import java.util.Collection;
@@ -29,24 +26,11 @@ import java.util.Collection;
* @author abreslav
*/
public class AmbiguousDescriptorDiagnosticFactory extends DiagnosticFactory1>> {
- public static AmbiguousDescriptorDiagnosticFactory create(String messageTemplate) {
- return new AmbiguousDescriptorDiagnosticFactory(messageTemplate);
+ public static AmbiguousDescriptorDiagnosticFactory create() {
+ return new AmbiguousDescriptorDiagnosticFactory();
}
- public AmbiguousDescriptorDiagnosticFactory(String messageTemplate) {
- super(Severity.ERROR, messageTemplate, PositioningStrategies.DEFAULT, AMBIGUOUS_DESCRIPTOR_RENDERER);
+ public AmbiguousDescriptorDiagnosticFactory() {
+ super(Severity.ERROR, PositioningStrategies.DEFAULT);
}
-
- private static Renderer>> AMBIGUOUS_DESCRIPTOR_RENDERER =
- new Renderer>>() {
- @NotNull
- @Override
- public String render(@Nullable Collection extends ResolvedCall extends CallableDescriptor>> argument) {
- StringBuilder stringBuilder = new StringBuilder("\n");
- for (ResolvedCall extends CallableDescriptor> call : argument) {
- stringBuilder.append(DescriptorRenderer.TEXT.render(call.getResultingDescriptor())).append("\n");
- }
- return stringBuilder.toString();
- }
- };
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Diagnostic.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Diagnostic.java
index d4369a0513d..8fcfbf18762 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Diagnostic.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Diagnostic.java
@@ -31,9 +31,6 @@ public interface Diagnostic {
@NotNull
AbstractDiagnosticFactory getFactory();
- @NotNull
- String getMessage();
-
@NotNull
Severity getSeverity();
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory.java
deleted file mode 100644
index 5e893eef3f1..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * Copyright 2010-2012 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 org.jetbrains.jet.lang.diagnostics;
-
-import com.intellij.psi.PsiElement;
-import org.jetbrains.annotations.NotNull;
-
-/**
- * @author svtk
- */
-public class DiagnosticFactory extends DiagnosticFactoryWithPsiElement {
- protected final String message;
-
- protected DiagnosticFactory(Severity severity, String message, PositioningStrategy super E> positioningStrategy) {
- super(severity, positioningStrategy);
- this.message = message;
- }
-
- public static DiagnosticFactory create(Severity severity, String message) {
- return create(severity, message, PositioningStrategies.DEFAULT);
- }
-
- public static DiagnosticFactory create(Severity severity, String message, PositioningStrategy super T> positioningStrategy) {
- return new DiagnosticFactory(severity, message, positioningStrategy);
- }
-
- @NotNull
- public ParametrizedDiagnostic on(@NotNull E element) {
- return new DiagnosticWithPsiElement(element, this, severity, message);
- }
-}
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory1.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory1.java
index c6e1d9d3f91..ebc4ebe4b23 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory1.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory1.java
@@ -22,40 +22,21 @@ import org.jetbrains.annotations.NotNull;
/**
* @author svtk
*/
-public class DiagnosticFactory1 extends DiagnosticFactoryWithMessageFormat {
- private final Renderer super A> renderer;
-
- protected String makeMessage(@NotNull A argument) {
- return messageFormat.format(new Object[]{makeMessageFor(argument)});
- }
-
- protected String makeMessageFor(@NotNull A argument) {
- return renderer.render(argument);
- }
-
+public class DiagnosticFactory1 extends DiagnosticFactoryWithPsiElement {
@NotNull
public ParametrizedDiagnostic on(@NotNull E element, @NotNull A argument) {
- return new DiagnosticWithPsiElement(element, this, severity, makeMessage(argument));
+ return new DiagnosticWithParameters1(element, argument, this, severity);
}
- protected DiagnosticFactory1(Severity severity, String message, PositioningStrategy super E> positioningStrategy, Renderer super A> renderer) {
- super(severity, message, positioningStrategy);
- this.renderer = renderer;
+ protected DiagnosticFactory1(Severity severity, PositioningStrategy super E> positioningStrategy) {
+ super(severity, positioningStrategy);
}
- public static DiagnosticFactory1 create(Severity severity, String message, PositioningStrategy super T> positioningStrategy, Renderer super A> renderer) {
- return new DiagnosticFactory1(severity, message, positioningStrategy, renderer);
+ public static DiagnosticFactory1 create(Severity severity, PositioningStrategy super T> positioningStrategy) {
+ return new DiagnosticFactory1(severity, positioningStrategy);
}
- public static DiagnosticFactory1 create(Severity severity, String message, PositioningStrategy super T> positioningStrategy) {
- return create(severity, message, positioningStrategy, Renderers.TO_STRING);
- }
-
- public static DiagnosticFactory1 create(Severity severity, String message, Renderer super A> renderer) {
- return create(severity, message, PositioningStrategies.DEFAULT, renderer);
- }
-
- public static DiagnosticFactory1 create(Severity severity, String message) {
- return create(severity, message, PositioningStrategies.DEFAULT, Renderers.TO_STRING);
+ public static DiagnosticFactory1 create(Severity severity) {
+ return create(severity, PositioningStrategies.DEFAULT);
}
}
\ No newline at end of file
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory2.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory2.java
index 8eb63ff8c04..5f63a87870b 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory2.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory2.java
@@ -22,48 +22,23 @@ import org.jetbrains.annotations.NotNull;
/**
* @author abreslav
*/
-public class DiagnosticFactory2 extends DiagnosticFactoryWithMessageFormat {
- private final Renderer super A> rendererForA;
- private final Renderer super B> rendererForB;
-
- private String makeMessage(@NotNull A a, @NotNull B b) {
- return messageFormat.format(new Object[] {makeMessageForA(a), makeMessageForB(b)});
- }
-
- private String makeMessageForA(@NotNull A a) {
- return rendererForA.render(a);
- }
-
- private String makeMessageForB(@NotNull B b) {
- return rendererForB.render(b);
- }
+public class DiagnosticFactory2 extends DiagnosticFactoryWithPsiElement {
@NotNull
public ParametrizedDiagnostic on(@NotNull E element, @NotNull A a, @NotNull B b) {
- return new DiagnosticWithPsiElement(element, this, severity, makeMessage(a, b));
+ return new DiagnosticWithParameters2(element, a, b, this, severity);
}
-
- private DiagnosticFactory2(Severity severity, String message, PositioningStrategy super E> positioningStrategy, Renderer super A> rendererForA, Renderer super B> rendererForB) {
- super(severity, message, positioningStrategy);
- this.rendererForA = rendererForA;
- this.rendererForB = rendererForB;
+ private DiagnosticFactory2(Severity severity, PositioningStrategy super E> positioningStrategy) {
+ super(severity, positioningStrategy);
}
- public static DiagnosticFactory2 create(Severity severity, String messageStub, PositioningStrategy super T> positioningStrategy, Renderer super A> rendererForA, Renderer super B> rendererForB) {
- return new DiagnosticFactory2(severity, messageStub, positioningStrategy, rendererForA, rendererForB);
+ public static DiagnosticFactory2 create(Severity severity, PositioningStrategy super T> positioningStrategy) {
+ return new DiagnosticFactory2(severity, positioningStrategy);
}
- public static DiagnosticFactory2 create(Severity severity, String messageStub, PositioningStrategy super T> positioningStrategy) {
- return new DiagnosticFactory2(severity, messageStub, positioningStrategy, Renderers.TO_STRING, Renderers.TO_STRING);
- }
-
- public static DiagnosticFactory2 create(Severity severity, String messageStub, Renderer super A> rendererForA, Renderer super B> rendererForB) {
- return new DiagnosticFactory2(severity, messageStub, PositioningStrategies.DEFAULT, rendererForA, rendererForB);
- }
-
- public static DiagnosticFactory2 create(Severity severity, String messageStub) {
- return new DiagnosticFactory2(severity, messageStub, PositioningStrategies.DEFAULT, Renderers.TO_STRING, Renderers.TO_STRING);
+ public static DiagnosticFactory2 create(Severity severity) {
+ return new DiagnosticFactory2(severity, PositioningStrategies.DEFAULT);
}
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory3.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory3.java
index caa5b8518e1..2bb0deb23da 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory3.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactory3.java
@@ -22,51 +22,22 @@ import org.jetbrains.annotations.NotNull;
/**
* @author svtk
*/
-public class DiagnosticFactory3 extends DiagnosticFactoryWithMessageFormat {
- private final Renderer super A> rendererForA;
- private final Renderer super B> rendererForB;
- private final Renderer super C> rendererForC;
-
- protected DiagnosticFactory3(Severity severity, String messageStub, PositioningStrategy super E> positioningStrategy, Renderer super A> rendererForA, Renderer super B> rendererForB, Renderer super C> rendererForC) {
- super(severity, messageStub, positioningStrategy);
- this.rendererForA = rendererForA;
- this.rendererForB = rendererForB;
- this.rendererForC = rendererForC;
+public class DiagnosticFactory3 extends DiagnosticFactoryWithPsiElement {
+
+ protected DiagnosticFactory3(Severity severity, PositioningStrategy super E> positioningStrategy) {
+ super(severity, positioningStrategy);
}
- public static DiagnosticFactory3 create(Severity severity, String messageStub) {
- return create(severity, messageStub, PositioningStrategies.DEFAULT);
+ public static DiagnosticFactory3 create(Severity severity) {
+ return create(severity, PositioningStrategies.DEFAULT);
}
- public static DiagnosticFactory3 create(Severity severity, String messageStub, PositioningStrategy super T> positioningStrategy) {
- return create(severity, messageStub, positioningStrategy, Renderers.TO_STRING, Renderers.TO_STRING, Renderers.TO_STRING);
+ public static DiagnosticFactory3 create(Severity severity, PositioningStrategy super T> positioningStrategy) {
+ return new DiagnosticFactory3(severity, positioningStrategy);
}
- public static DiagnosticFactory3 create(Severity severity, String messageStub, Renderer super A> rendererForA, Renderer super B> rendererForB, Renderer super C> rendererForC) {
- return create(severity, messageStub, PositioningStrategies.DEFAULT, rendererForA, rendererForB, rendererForC);
- }
-
- public static DiagnosticFactory3 create(Severity severity, String messageStub, PositioningStrategy super T> positioningStrategy, Renderer super A> rendererForA, Renderer super B> rendererForB, Renderer super C> rendererForC) {
- return new DiagnosticFactory3(severity, messageStub, positioningStrategy, rendererForA, rendererForB, rendererForC);
- }
-
- private String makeMessage(@NotNull A a, @NotNull B b, @NotNull C c) {
- return messageFormat.format(new Object[]{makeMessageForA(a), makeMessageForB(b), makeMessageForC(c)});
- }
-
- private String makeMessageForA(@NotNull A a) {
- return rendererForA.render(a);
- }
-
- private String makeMessageForB(@NotNull B b) {
- return rendererForB.render(b);
- }
-
- private String makeMessageForC(@NotNull C c) {
- return rendererForC.render(c);
- }
@NotNull
public ParametrizedDiagnostic on(@NotNull E element, @NotNull A a, @NotNull B b, @NotNull C c) {
- return new DiagnosticWithPsiElement(element, this, severity, makeMessage(a, b, c));
+ return new DiagnosticWithParameters3(element, a, b, c, this, severity);
}
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithMessageFormat.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithMessageFormat.java
deleted file mode 100644
index 9478ec5191d..00000000000
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticFactoryWithMessageFormat.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright 2010-2012 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 org.jetbrains.jet.lang.diagnostics;
-
-import com.intellij.psi.PsiElement;
-
-import java.text.MessageFormat;
-
-/**
-* @author abreslav
-*/
-public abstract class DiagnosticFactoryWithMessageFormat extends DiagnosticFactoryWithPsiElement {
- protected final MessageFormat messageFormat;
-
- public DiagnosticFactoryWithMessageFormat(Severity severity, String message) {
- this(severity, message, PositioningStrategies.DEFAULT);
- }
-
- public DiagnosticFactoryWithMessageFormat(Severity severity, String message, PositioningStrategy super E> positioningStrategy) {
- super(severity, positioningStrategy);
- this.messageFormat = new MessageFormat(message);
- }
-}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder.java
index f0c110e14bd..c1f1472d2c5 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticHolder.java
@@ -17,7 +17,6 @@
package org.jetbrains.jet.lang.diagnostics;
import com.intellij.openapi.util.TextRange;
-import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
@@ -38,7 +37,7 @@ public interface DiagnosticHolder {
if (diagnostic.getSeverity() == Severity.ERROR) {
PsiFile psiFile = diagnostic.getPsiFile();
List textRanges = diagnostic.getTextRanges();
- throw new IllegalStateException(diagnostic.getMessage() + DiagnosticUtils.atLocation(psiFile, textRanges.get(0)));
+ throw new IllegalStateException(diagnostic.getFactory().getName() + DiagnosticUtils.atLocation(psiFile, textRanges.get(0)));
}
}
};
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters1.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters1.java
new file mode 100644
index 00000000000..50976c627c4
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters1.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2010-2012 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 org.jetbrains.jet.lang.diagnostics;
+
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+/**
+ * @author Evgeny Gerashchenko
+ * @since 4/11/12
+ */
+public class DiagnosticWithParameters1 extends AbstractDiagnostic {
+ private A a;
+
+ public DiagnosticWithParameters1(@NotNull E psiElement,
+ @NotNull A a,
+ @NotNull DiagnosticFactory1 factory,
+ @NotNull Severity severity) {
+ super(psiElement, factory, severity);
+ this.a = a;
+ }
+
+ @NotNull
+ @Override
+ public DiagnosticFactory1 getFactory() {
+ return (DiagnosticFactory1)super.getFactory();
+ }
+
+ @Override
+ @NotNull
+ public List getTextRanges() {
+ return getFactory().getTextRanges(this);
+ }
+
+ @NotNull
+ public A getA() {
+ return a;
+ }
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/UnresolvedReferenceDiagnostic.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters2.java
similarity index 50%
rename from compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/UnresolvedReferenceDiagnostic.java
rename to compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters2.java
index 8b1f2242987..272577dcfba 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/UnresolvedReferenceDiagnostic.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters2.java
@@ -17,37 +17,48 @@
package org.jetbrains.jet.lang.diagnostics;
import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.jet.lang.psi.JetArrayAccessExpression;
-import org.jetbrains.jet.lang.psi.JetReferenceExpression;
-import java.util.Collections;
import java.util.List;
-import static org.jetbrains.jet.lang.diagnostics.Severity.ERROR;
-
/**
- * @author abreslav
+ * @author Evgeny Gerashchenko
+ * @since 4/11/12
*/
-public class UnresolvedReferenceDiagnostic extends AbstractDiagnostic {
+public class DiagnosticWithParameters2 extends AbstractDiagnostic {
+ private A a;
+ private B b;
- public UnresolvedReferenceDiagnostic(JetReferenceExpression referenceExpression, String message) {
- super(referenceExpression, Errors.UNRESOLVED_REFERENCE, ERROR, message);
+ public DiagnosticWithParameters2(@NotNull E psiElement,
+ @NotNull A a,
+ @NotNull B b,
+ @NotNull DiagnosticFactory2 factory,
+ @NotNull Severity severity) {
+ super(psiElement, factory, severity);
+ this.a = a;
+ this.b = b;
}
@NotNull
@Override
- public String getMessage() {
- return super.getMessage() + ": " + getPsiElement().getText();
+ public DiagnosticFactory2 getFactory() {
+ return (DiagnosticFactory2)super.getFactory();
}
- @NotNull
@Override
+ @NotNull
public List getTextRanges() {
- JetReferenceExpression element = getPsiElement();
- if (element instanceof JetArrayAccessExpression) {
- return ((JetArrayAccessExpression) element).getBracketRanges();
- }
- return Collections.singletonList(element.getTextRange());
+ return getFactory().getTextRanges(this);
+ }
+
+ @NotNull
+ public A getA() {
+ return a;
+ }
+
+ @NotNull
+ public B getB() {
+ return b;
}
}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters3.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters3.java
new file mode 100644
index 00000000000..febe21d7a5b
--- /dev/null
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/DiagnosticWithParameters3.java
@@ -0,0 +1,72 @@
+/*
+ * Copyright 2010-2012 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 org.jetbrains.jet.lang.diagnostics;
+
+import com.intellij.openapi.util.TextRange;
+import com.intellij.psi.PsiElement;
+import org.jetbrains.annotations.NotNull;
+
+import java.util.List;
+
+/**
+ * @author Evgeny Gerashchenko
+ * @since 4/11/12
+ */
+public class DiagnosticWithParameters3 extends AbstractDiagnostic {
+ private A a;
+ private B b;
+ private C c;
+
+ public DiagnosticWithParameters3(@NotNull E psiElement,
+ @NotNull A a,
+ @NotNull B b,
+ @NotNull C c,
+ @NotNull DiagnosticFactory3 factory,
+ @NotNull Severity severity) {
+ super(psiElement, factory, severity);
+ this.a = a;
+ this.b = b;
+ this.c = c;
+ }
+
+ @NotNull
+ @Override
+ public DiagnosticFactory3 getFactory() {
+ return (DiagnosticFactory3)super.getFactory();
+ }
+
+ @Override
+ @NotNull
+ public List getTextRanges() {
+ return getFactory().getTextRanges(this);
+ }
+
+ @NotNull
+ public A getA() {
+ return a;
+ }
+
+ @NotNull
+ public B getB() {
+ return b;
+ }
+
+ @NotNull
+ public C getC() {
+ return c;
+ }
+}
diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java
index d2e374196ed..929f1350017 100644
--- a/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java
+++ b/compiler/frontend/src/org/jetbrains/jet/lang/diagnostics/Errors.java
@@ -21,267 +21,259 @@ import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiNameIdentifierOwner;
import com.intellij.psi.impl.source.tree.LeafPsiElement;
import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.lang.descriptors.*;
import org.jetbrains.jet.lang.psi.*;
import org.jetbrains.jet.lang.resolve.calls.inference.SolutionStatus;
import org.jetbrains.jet.lang.types.JetType;
import org.jetbrains.jet.lexer.JetKeywordToken;
import org.jetbrains.jet.lexer.JetTokens;
-import org.jetbrains.jet.resolve.DescriptorRenderer;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import java.util.Collection;
import java.util.Collections;
-import java.util.Iterator;
import java.util.List;
-import static org.jetbrains.jet.lang.diagnostics.Renderers.*;
import static org.jetbrains.jet.lang.diagnostics.Severity.ERROR;
import static org.jetbrains.jet.lang.diagnostics.Severity.WARNING;
/**
+ * For error messages, see DefaultErrorMessages and IdeErrorMessages.
+ *
* @author abreslav
*/
public interface Errors {
- DiagnosticFactory1 EXCEPTION_WHILE_ANALYZING = DiagnosticFactory1.create(ERROR, "{0}", new Renderer() {
- @NotNull
- @Override
- public String render(@Nullable Throwable e) {
- return e.getClass().getSimpleName() + ": " + e.getMessage();
- }
- });
+ DiagnosticFactory1 EXCEPTION_WHILE_ANALYZING = DiagnosticFactory1.create(ERROR);
- UnresolvedReferenceDiagnosticFactory UNRESOLVED_REFERENCE = UnresolvedReferenceDiagnosticFactory.create("Unresolved reference");
+ UnresolvedReferenceDiagnosticFactory UNRESOLVED_REFERENCE = UnresolvedReferenceDiagnosticFactory.create();
//Elements with "INVISIBLE_REFERENCE" error are marked as unresolved, unlike elements with "INVISIBLE_MEMBER" error
- DiagnosticFactory2 INVISIBLE_REFERENCE = DiagnosticFactory2.create(ERROR, "Cannot access ''{0}'' in ''{1}''", NAME, NAME);
- DiagnosticFactory2 INVISIBLE_MEMBER = DiagnosticFactory2.create(ERROR, "Cannot access ''{0}'' in ''{1}''", NAME, NAME);
+ DiagnosticFactory2 INVISIBLE_REFERENCE =
+ DiagnosticFactory2.create(ERROR);
+ DiagnosticFactory2 INVISIBLE_MEMBER = DiagnosticFactory2.create(ERROR);
- RedeclarationDiagnosticFactory REDECLARATION = RedeclarationDiagnosticFactory.REDECLARATION;
- RedeclarationDiagnosticFactory NAME_SHADOWING = RedeclarationDiagnosticFactory.NAME_SHADOWING;
+ RedeclarationDiagnosticFactory REDECLARATION = new RedeclarationDiagnosticFactory(ERROR);
+ RedeclarationDiagnosticFactory NAME_SHADOWING = new RedeclarationDiagnosticFactory(WARNING);
- DiagnosticFactory2 TYPE_MISMATCH = DiagnosticFactory2.create(ERROR, "Type mismatch: inferred type is {1} but {0} was expected",
- RENDER_TYPE, RENDER_TYPE);
- DiagnosticFactory1> INCOMPATIBLE_MODIFIERS =
- DiagnosticFactory1.create(ERROR, "Incompatible modifiers: ''{0}''",
- new Renderer>() {
- @NotNull
- @Override
- public String render(@Nullable Collection element) {
- assert element != null;
- StringBuilder sb = new StringBuilder();
- for (Iterator iterator = element.iterator(); iterator.hasNext(); ) {
- JetKeywordToken modifier = iterator.next();
- sb.append(modifier.getValue());
- if (iterator.hasNext()) {
- sb.append(" ");
- }
- }
- return sb.toString();
- }
- });
- DiagnosticFactory1 ILLEGAL_MODIFIER = DiagnosticFactory1.create(ERROR, "Illegal modifier ''{0}''");
+ DiagnosticFactory2 TYPE_MISMATCH = DiagnosticFactory2.create(ERROR);
+ DiagnosticFactory1> INCOMPATIBLE_MODIFIERS = DiagnosticFactory1.create(ERROR);
+ DiagnosticFactory1 ILLEGAL_MODIFIER = DiagnosticFactory1.create(ERROR);
- DiagnosticFactory2 REDUNDANT_MODIFIER = DiagnosticFactory2.create(Severity.WARNING, "Modifier {0} is redundant because {1} is present");
- DiagnosticFactory ABSTRACT_MODIFIER_IN_TRAIT = DiagnosticFactory.create(WARNING, "Modifier ''{0}'' is redundant in trait", PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
- DiagnosticFactory OPEN_MODIFIER_IN_TRAIT = DiagnosticFactory.create(WARNING, "Modifier ''{0}'' is redundant in trait", PositioningStrategies.positionModifier(JetTokens.OPEN_KEYWORD));
- DiagnosticFactory REDUNDANT_MODIFIER_IN_GETTER = DiagnosticFactory.create(WARNING, "Visibility modifiers are redundant in getter");
- DiagnosticFactory TRAIT_CAN_NOT_BE_FINAL = DiagnosticFactory.create(ERROR, "Trait can not be final");
- DiagnosticFactory TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM = DiagnosticFactory.create(ERROR, "Type checking has run into a recursive problem. Easiest workaround: specify types of your declarations explicitly"); // TODO: message
- DiagnosticFactory RETURN_NOT_ALLOWED = DiagnosticFactory.create(ERROR, "'return' is not allowed here");
- DiagnosticFactory PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE = DiagnosticFactory.create(ERROR, "Projections are not allowed for immediate arguments of a supertype", new PositioningStrategy() {
- @NotNull
- @Override
- public List mark(@NotNull JetTypeProjection element) {
- return markNode(element.getProjectionNode());
- }
- });
- DiagnosticFactory LABEL_NAME_CLASH = DiagnosticFactory.create(WARNING, "There is more than one label with such a name in this scope");
- DiagnosticFactory EXPRESSION_EXPECTED_NAMESPACE_FOUND = DiagnosticFactory.create(ERROR, "Expression expected, but a namespace name found");
+ DiagnosticFactory2 REDUNDANT_MODIFIER = DiagnosticFactory2.create(Severity.WARNING);
+ SimpleDiagnosticFactory ABSTRACT_MODIFIER_IN_TRAIT = SimpleDiagnosticFactory
+ .create(WARNING, PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
+ SimpleDiagnosticFactory OPEN_MODIFIER_IN_TRAIT = SimpleDiagnosticFactory
+ .create(WARNING, PositioningStrategies.positionModifier(JetTokens.OPEN_KEYWORD));
+ SimpleDiagnosticFactory
+ REDUNDANT_MODIFIER_IN_GETTER = SimpleDiagnosticFactory.create(WARNING);
+ SimpleDiagnosticFactory TRAIT_CAN_NOT_BE_FINAL = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory RETURN_NOT_ALLOWED = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE =
+ SimpleDiagnosticFactory.create(ERROR, PositioningStrategies.PROJECTION_MODIFIER);
+ SimpleDiagnosticFactoryLABEL_NAME_CLASH = SimpleDiagnosticFactory.create(WARNING);
+ SimpleDiagnosticFactory EXPRESSION_EXPECTED_NAMESPACE_FOUND = SimpleDiagnosticFactory.create(ERROR);
- DiagnosticFactory1 CANNOT_IMPORT_FROM_ELEMENT = DiagnosticFactory1.create(ERROR, "Cannot import from ''{0}''", NAME);
- DiagnosticFactory1 CANNOT_BE_IMPORTED = DiagnosticFactory1.create(ERROR, "Cannot import ''{0}'', functions and properties can be imported only from packages", NAME);
- DiagnosticFactory USELESS_HIDDEN_IMPORT = DiagnosticFactory.create(WARNING, "Useless import, it is hidden further");
- DiagnosticFactory USELESS_SIMPLE_IMPORT = DiagnosticFactory.create(WARNING, "Useless import, does nothing");
+ DiagnosticFactory1 CANNOT_IMPORT_FROM_ELEMENT = DiagnosticFactory1.create(ERROR);
+ DiagnosticFactory1 CANNOT_BE_IMPORTED = DiagnosticFactory1.create(ERROR);
+ SimpleDiagnosticFactoryUSELESS_HIDDEN_IMPORT = SimpleDiagnosticFactory.create(WARNING);
+ SimpleDiagnosticFactory USELESS_SIMPLE_IMPORT = SimpleDiagnosticFactory.create(WARNING);
- DiagnosticFactory CANNOT_INFER_PARAMETER_TYPE = DiagnosticFactory.create(ERROR, "Cannot infer a type for this parameter. To specify it explicitly use the {(p : Type) => ...} notation");
+ SimpleDiagnosticFactory CANNOT_INFER_PARAMETER_TYPE = SimpleDiagnosticFactory.create(ERROR);
- DiagnosticFactory NO_BACKING_FIELD_ABSTRACT_PROPERTY = DiagnosticFactory.create(ERROR, "This property doesn't have a backing field, because it's abstract");
- DiagnosticFactory NO_BACKING_FIELD_CUSTOM_ACCESSORS = DiagnosticFactory.create(ERROR, "This property doesn't have a backing field, because it has custom accessors without reference to the backing field");
- DiagnosticFactory INACCESSIBLE_BACKING_FIELD = DiagnosticFactory.create(ERROR, "The backing field is not accessible here");
- DiagnosticFactory NOT_PROPERTY_BACKING_FIELD = DiagnosticFactory.create(ERROR, "The referenced variable is not a property and doesn't have backing field");
+ SimpleDiagnosticFactory NO_BACKING_FIELD_ABSTRACT_PROPERTY = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory NO_BACKING_FIELD_CUSTOM_ACCESSORS = SimpleDiagnosticFactory.create(ERROR
+ );
+ SimpleDiagnosticFactory INACCESSIBLE_BACKING_FIELD = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory NOT_PROPERTY_BACKING_FIELD = SimpleDiagnosticFactory.create(ERROR);
- DiagnosticFactory MIXING_NAMED_AND_POSITIONED_ARGUMENTS = DiagnosticFactory.create(ERROR, "Mixing named and positioned arguments in not allowed");
- DiagnosticFactory ARGUMENT_PASSED_TWICE = DiagnosticFactory.create(ERROR, "An argument is already passed for this parameter");
- UnresolvedReferenceDiagnosticFactory NAMED_PARAMETER_NOT_FOUND = UnresolvedReferenceDiagnosticFactory.create("Cannot find a parameter with this name");
- DiagnosticFactory VARARG_OUTSIDE_PARENTHESES = DiagnosticFactory.create(ERROR, "Passing value as a vararg is only allowed inside a parenthesized argument list");
- DiagnosticFactory NON_VARARG_SPREAD = DiagnosticFactory.create(ERROR, "The spread operator (*foo) may only be applied in a vararg position");
+ SimpleDiagnosticFactory MIXING_NAMED_AND_POSITIONED_ARGUMENTS = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory ARGUMENT_PASSED_TWICE = SimpleDiagnosticFactory.create(ERROR);
+ UnresolvedReferenceDiagnosticFactory NAMED_PARAMETER_NOT_FOUND = UnresolvedReferenceDiagnosticFactory.create();
+ SimpleDiagnosticFactory VARARG_OUTSIDE_PARENTHESES = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory NON_VARARG_SPREAD = SimpleDiagnosticFactory.create(ERROR);
- DiagnosticFactory MANY_FUNCTION_LITERAL_ARGUMENTS = DiagnosticFactory.create(ERROR, "Only one function literal is allowed outside a parenthesized argument list");
- DiagnosticFactory PROPERTY_WITH_NO_TYPE_NO_INITIALIZER = DiagnosticFactory.create(ERROR, "This property must either have a type annotation or be initialized");
+ SimpleDiagnosticFactory MANY_FUNCTION_LITERAL_ARGUMENTS = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory PROPERTY_WITH_NO_TYPE_NO_INITIALIZER = SimpleDiagnosticFactory.create(ERROR);
- DiagnosticFactory ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS = DiagnosticFactory.create(ERROR, "This property cannot be declared abstract", PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
- DiagnosticFactory ABSTRACT_PROPERTY_NOT_IN_CLASS = DiagnosticFactory.create(ERROR, "A property may be abstract only when defined in a class or trait", PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
- DiagnosticFactory ABSTRACT_PROPERTY_WITH_INITIALIZER = DiagnosticFactory.create(ERROR, "Property with initializer cannot be abstract");
- DiagnosticFactory ABSTRACT_PROPERTY_WITH_GETTER = DiagnosticFactory.create(ERROR, "Property with getter implementation cannot be abstract");
- DiagnosticFactory ABSTRACT_PROPERTY_WITH_SETTER = DiagnosticFactory.create(ERROR, "Property with setter implementation cannot be abstract");
+ SimpleDiagnosticFactory ABSTRACT_PROPERTY_IN_PRIMARY_CONSTRUCTOR_PARAMETERS = SimpleDiagnosticFactory
+ .create(ERROR, PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
+ SimpleDiagnosticFactory ABSTRACT_PROPERTY_NOT_IN_CLASS = SimpleDiagnosticFactory.create(ERROR,
+ PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
+ SimpleDiagnosticFactory ABSTRACT_PROPERTY_WITH_INITIALIZER = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory ABSTRACT_PROPERTY_WITH_GETTER = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactoryABSTRACT_PROPERTY_WITH_SETTER = SimpleDiagnosticFactory.create(ERROR);
- DiagnosticFactory PACKAGE_MEMBER_CANNOT_BE_PROTECTED = DiagnosticFactory.create(ERROR, "Package member cannot be protected");
+ SimpleDiagnosticFactory PACKAGE_MEMBER_CANNOT_BE_PROTECTED = SimpleDiagnosticFactory.create(ERROR);
- DiagnosticFactory GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY = DiagnosticFactory.create(ERROR, "Getter visibility must be the same as property visibility");
- DiagnosticFactory BACKING_FIELD_IN_TRAIT = DiagnosticFactory.create(ERROR, "Property in a trait cannot have a backing field", PositioningStrategies.POSITION_NAME_IDENTIFIER);
- DiagnosticFactory MUST_BE_INITIALIZED = DiagnosticFactory.create(ERROR, "Property must be initialized", PositioningStrategies.POSITION_NAME_IDENTIFIER);
- DiagnosticFactory MUST_BE_INITIALIZED_OR_BE_ABSTRACT = DiagnosticFactory.create(ERROR, "Property must be initialized or be abstract", PositioningStrategies.POSITION_NAME_IDENTIFIER);
- DiagnosticFactory PROPERTY_INITIALIZER_IN_TRAIT = DiagnosticFactory.create(ERROR, "Property initializers are not allowed in traits");
- DiagnosticFactory PROPERTY_INITIALIZER_NO_BACKING_FIELD = DiagnosticFactory.create(ERROR, "Initializer is not allowed here because this property has no backing field");
- DiagnosticFactory3 ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS = DiagnosticFactory3.create(ERROR, "Abstract property {0} in non-abstract class {1}", PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
- DiagnosticFactory3 ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS = DiagnosticFactory3.create(ERROR, "Abstract function {0} in non-abstract class {1}", PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
- DiagnosticFactory1 ABSTRACT_FUNCTION_WITH_BODY = DiagnosticFactory1.create(ERROR, "A function {0} with body cannot be abstract", PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
- DiagnosticFactory1 NON_ABSTRACT_FUNCTION_WITH_NO_BODY = DiagnosticFactory1.create(ERROR, "Method {0} without a body must be abstract", PositioningStrategies.POSITION_NAME_IDENTIFIER);
- DiagnosticFactory1 NON_MEMBER_ABSTRACT_FUNCTION = DiagnosticFactory1.create(ERROR, "Function {0} is not a class or trait member and cannot be abstract", PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
+ SimpleDiagnosticFactory GETTER_VISIBILITY_DIFFERS_FROM_PROPERTY_VISIBILITY = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory BACKING_FIELD_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR,
+ PositioningStrategies.POSITION_NAME_IDENTIFIER);
+ SimpleDiagnosticFactory MUST_BE_INITIALIZED = SimpleDiagnosticFactory.create(ERROR,
+ PositioningStrategies.POSITION_NAME_IDENTIFIER);
+ SimpleDiagnosticFactory MUST_BE_INITIALIZED_OR_BE_ABSTRACT = SimpleDiagnosticFactory.create(ERROR,
+ PositioningStrategies.POSITION_NAME_IDENTIFIER);
+ SimpleDiagnosticFactoryPROPERTY_INITIALIZER_IN_TRAIT = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory PROPERTY_INITIALIZER_NO_BACKING_FIELD = SimpleDiagnosticFactory.create(ERROR);
+ DiagnosticFactory2 ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS =
+ DiagnosticFactory2.create(ERROR, PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
+ DiagnosticFactory2 ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS =
+ DiagnosticFactory2.create(ERROR,PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
+ DiagnosticFactory1 ABSTRACT_FUNCTION_WITH_BODY =
+ DiagnosticFactory1.create(ERROR, PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
+ DiagnosticFactory1 NON_ABSTRACT_FUNCTION_WITH_NO_BODY =
+ DiagnosticFactory1.create(ERROR, PositioningStrategies.POSITION_NAME_IDENTIFIER);
+ DiagnosticFactory1 NON_MEMBER_ABSTRACT_FUNCTION =
+ DiagnosticFactory1.create(ERROR, PositioningStrategies.POSITION_ABSTRACT_MODIFIER);
- DiagnosticFactory1 NON_MEMBER_FUNCTION_NO_BODY = DiagnosticFactory1.create(ERROR, "Function {0} must have a body", PositioningStrategies.POSITION_NAME_IDENTIFIER);
- DiagnosticFactory NON_FINAL_MEMBER_IN_FINAL_CLASS = DiagnosticFactory.create(ERROR, "Non final member in a final class", PositioningStrategies.positionModifier(JetTokens.OPEN_KEYWORD));
+ DiagnosticFactory1 NON_MEMBER_FUNCTION_NO_BODY =
+ DiagnosticFactory1.create(ERROR, PositioningStrategies.POSITION_NAME_IDENTIFIER);
+ SimpleDiagnosticFactory NON_FINAL_MEMBER_IN_FINAL_CLASS =
+ SimpleDiagnosticFactory.create(ERROR, PositioningStrategies.positionModifier(JetTokens.OPEN_KEYWORD));
- DiagnosticFactory PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE = DiagnosticFactory.create(ERROR, "Public or protected member should specify a type", PositioningStrategies.POSITION_NAME_IDENTIFIER);
+ SimpleDiagnosticFactory PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE =
+ SimpleDiagnosticFactory.create(ERROR, PositioningStrategies.POSITION_NAME_IDENTIFIER);
- DiagnosticFactory PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT = DiagnosticFactory.create(ERROR, "Projections are not allowed on type arguments of functions and properties"); // TODO : better positioning
- DiagnosticFactory SUPERTYPE_NOT_INITIALIZED = DiagnosticFactory.create(ERROR, "This type has a constructor, and thus must be initialized here");
- DiagnosticFactory SUPERTYPE_NOT_INITIALIZED_DEFAULT = DiagnosticFactory.create(ERROR, "Constructor invocation should be explicitly specified");
- DiagnosticFactory SECONDARY_CONSTRUCTOR_BUT_NO_PRIMARY = DiagnosticFactory.create(ERROR, "A secondary constructor may appear only in a class that has a primary constructor");
- DiagnosticFactory SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST = DiagnosticFactory.create(ERROR, "Secondary constructors must have an initializer list");
- DiagnosticFactory BY_IN_SECONDARY_CONSTRUCTOR = DiagnosticFactory.create(ERROR, "'by'-clause is only supported for primary constructors");
- DiagnosticFactory INITIALIZER_WITH_NO_ARGUMENTS = DiagnosticFactory.create(ERROR, "Constructor arguments required");
- DiagnosticFactory MANY_CALLS_TO_THIS = DiagnosticFactory.create(ERROR, "Only one call to 'this(...)' is allowed");
- DiagnosticFactory1 NOTHING_TO_OVERRIDE = DiagnosticFactory1.create(ERROR, "{0} overrides nothing", PositioningStrategies.POSITION_OVERRIDE_MODIFIER, DescriptorRenderer.TEXT);
- DiagnosticFactory3 VIRTUAL_MEMBER_HIDDEN =
- DiagnosticFactory3.create(ERROR, "''{0}'' hides ''{1}'' in class {2} and needs 'override' modifier", PositioningStrategies.POSITION_NAME_IDENTIFIER, DescriptorRenderer.TEXT, DescriptorRenderer.TEXT, DescriptorRenderer.TEXT);
+ SimpleDiagnosticFactory PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT =
+ SimpleDiagnosticFactory.create(ERROR, PositioningStrategies.PROJECTION_MODIFIER);
+ SimpleDiagnosticFactory SUPERTYPE_NOT_INITIALIZED = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory SUPERTYPE_NOT_INITIALIZED_DEFAULT = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory SECONDARY_CONSTRUCTOR_BUT_NO_PRIMARY = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory BY_IN_SECONDARY_CONSTRUCTOR = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory INITIALIZER_WITH_NO_ARGUMENTS = SimpleDiagnosticFactory.create(ERROR);
+ SimpleDiagnosticFactory MANY_CALLS_TO_THIS = SimpleDiagnosticFactory.create(ERROR);
+ DiagnosticFactory1 NOTHING_TO_OVERRIDE =
+ DiagnosticFactory1.create(ERROR, PositioningStrategies.POSITION_OVERRIDE_MODIFIER);
+ DiagnosticFactory3
+ VIRTUAL_MEMBER_HIDDEN = DiagnosticFactory3.create(ERROR, PositioningStrategies.POSITION_NAME_IDENTIFIER);
DiagnosticFactory3 CANNOT_OVERRIDE_INVISIBLE_MEMBER =
- DiagnosticFactory3.create(ERROR, "''{0}'' cannot has no access to ''{1}'' in class {2}, so it cannot override it", PositioningStrategies.POSITION_OVERRIDE_MODIFIER, DescriptorRenderer.TEXT, DescriptorRenderer.TEXT, DescriptorRenderer.TEXT);
- DiagnosticFactory CANNOT_INFER_VISIBILITY = DiagnosticFactory.create(ERROR, "Cannot infer visibility. Please specify it explicitly", PositioningStrategies.POSITION_OVERRIDE_MODIFIER);
+ DiagnosticFactory3.create(ERROR, PositioningStrategies.POSITION_OVERRIDE_MODIFIER);
+ SimpleDiagnosticFactory CANNOT_INFER_VISIBILITY = SimpleDiagnosticFactory.create(ERROR, PositioningStrategies.POSITION_OVERRIDE_MODIFIER);
- DiagnosticFactory1 ENUM_ENTRY_SHOULD_BE_INITIALIZED = DiagnosticFactory1.create(ERROR, "Missing delegation specifier ''{0}''", PositioningStrategies.POSITION_NAME_IDENTIFIER, NAME);
- DiagnosticFactory1 ENUM_ENTRY_ILLEGAL_TYPE = DiagnosticFactory1.create(ERROR, "The type constructor of enum entry should be ''{0}''", NAME);
+ DiagnosticFactory1 ENUM_ENTRY_SHOULD_BE_INITIALIZED =
+ DiagnosticFactory1.create(ERROR, PositioningStrategies.POSITION_NAME_IDENTIFIER);
+ DiagnosticFactory1 ENUM_ENTRY_ILLEGAL_TYPE = DiagnosticFactory1.create(ERROR);
- DiagnosticFactory1 UNINITIALIZED_VARIABLE = DiagnosticFactory1.create(ERROR, "Variable ''{0}'' must be initialized", NAME);
- DiagnosticFactory1 UNINITIALIZED_PARAMETER = DiagnosticFactory1.create(ERROR, "Parameter ''{0}'' is uninitialized here", NAME);
- UnusedElementDiagnosticFactory UNUSED_VARIABLE = UnusedElementDiagnosticFactory.create(WARNING, "Variable ''{0}'' is never used", PositioningStrategies.POSITION_NAME_IDENTIFIER, NAME);
- UnusedElementDiagnosticFactory UNUSED_PARAMETER = UnusedElementDiagnosticFactory.create(WARNING, "Parameter ''{0}'' is never used", PositioningStrategies.POSITION_NAME_IDENTIFIER, NAME);
- UnusedElementDiagnosticFactory ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE = UnusedElementDiagnosticFactory.create(WARNING, "Variable ''{0}'' is assigned but never accessed", PositioningStrategies.POSITION_NAME_IDENTIFIER, NAME);
- DiagnosticFactory1 VARIABLE_WITH_REDUNDANT_INITIALIZER = DiagnosticFactory1.create(WARNING, "Variable ''{0}'' initializer is redundant", NAME);
- DiagnosticFactory2 UNUSED_VALUE = DiagnosticFactory2.create(WARNING, "The value ''{0}'' assigned to ''{1}'' is never used", ELEMENT_TEXT, TO_STRING);
- DiagnosticFactory1 UNUSED_CHANGED_VALUE = DiagnosticFactory1.create(WARNING, "The value changed at ''{0}'' is never used", ELEMENT_TEXT);
- DiagnosticFactory UNUSED_EXPRESSION = DiagnosticFactory.create(WARNING, "The expression is unused");
- DiagnosticFactory UNUSED_FUNCTION_LITERAL = DiagnosticFactory.create(WARNING, "The function literal is unused. If you mean block, you can use 'run { ... }'");
+ DiagnosticFactory1 UNINITIALIZED_VARIABLE = DiagnosticFactory1.create(ERROR);
+ DiagnosticFactory1 UNINITIALIZED_PARAMETER = DiagnosticFactory1.create(ERROR);
+ UnusedElementDiagnosticFactory UNUSED_VARIABLE =
+ UnusedElementDiagnosticFactory.create(WARNING, PositioningStrategies.POSITION_NAME_IDENTIFIER);
+ UnusedElementDiagnosticFactory