Removed diagnostic rendering from RedeclarationDiagnosticFactory and UnresolvedReferenceDiagnosticFactory.

This commit is contained in:
Evgeny Gerashchenko
2012-04-13 15:06:00 +04:00
parent c957997943
commit 613ddeb461
3 changed files with 8 additions and 35 deletions
@@ -44,14 +44,14 @@ public interface Errors {
DiagnosticFactory1<JetFile, Throwable> 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<JetSimpleNameExpression, DeclarationDescriptor, DeclarationDescriptor> INVISIBLE_REFERENCE = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<PsiElement, DeclarationDescriptor, DeclarationDescriptor> 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<PsiElement, JetType, JetType> TYPE_MISMATCH = DiagnosticFactory2.create(ERROR
);
@@ -107,7 +107,7 @@ public interface Errors {
.create(ERROR);
SimpleDiagnosticFactory<JetReferenceExpression>
ARGUMENT_PASSED_TWICE = SimpleDiagnosticFactory.create(ERROR);
UnresolvedReferenceDiagnosticFactory NAMED_PARAMETER_NOT_FOUND = UnresolvedReferenceDiagnosticFactory.create("Cannot find a parameter with this name");
UnresolvedReferenceDiagnosticFactory NAMED_PARAMETER_NOT_FOUND = UnresolvedReferenceDiagnosticFactory.create();
SimpleDiagnosticFactory<JetExpression> VARARG_OUTSIDE_PARENTHESES = SimpleDiagnosticFactory
.create(ERROR);
SimpleDiagnosticFactory<LeafPsiElement>
@@ -23,36 +23,16 @@ import org.jetbrains.annotations.NotNull;
* @author abreslav
*/
public class RedeclarationDiagnosticFactory extends AbstractDiagnosticFactory {
private final String name;
final Severity severity;
private final String messagePrefix;
public static final RedeclarationDiagnosticFactory REDECLARATION = new RedeclarationDiagnosticFactory(
"REDECLARATION", Severity.ERROR, "Redeclaration: ");
public static final RedeclarationDiagnosticFactory NAME_SHADOWING = new RedeclarationDiagnosticFactory(
"NAME_SHADOWING", Severity.WARNING, "Name shadowed: ");
public RedeclarationDiagnosticFactory(String name, Severity severity, String messagePrefix) {
this.name = name;
public RedeclarationDiagnosticFactory(Severity severity) {
this.severity = severity;
this.messagePrefix = messagePrefix;
}
public RedeclarationDiagnostic on(@NotNull PsiElement duplicatingElement, @NotNull String name) {
return new RedeclarationDiagnostic.SimpleRedeclarationDiagnostic(duplicatingElement, name, this);
}
@NotNull
@Override
public String getName() {
return name;
}
public String makeMessage(String identifier) {
return messagePrefix + identifier;
}
@Override
public String toString() {
return getName();
@@ -23,21 +23,14 @@ import org.jetbrains.jet.lang.psi.JetReferenceExpression;
* @author abreslav
*/
public class UnresolvedReferenceDiagnosticFactory extends AbstractDiagnosticFactory {
private final String message;
private UnresolvedReferenceDiagnosticFactory(String message) {
this.message = message;
}
String getMessage() {
return message;
private UnresolvedReferenceDiagnosticFactory() {
}
public UnresolvedReferenceDiagnostic on(@NotNull JetReferenceExpression reference) {
return new UnresolvedReferenceDiagnostic(reference, this);
}
public static UnresolvedReferenceDiagnosticFactory create(String message) {
return new UnresolvedReferenceDiagnosticFactory(message);
public static UnresolvedReferenceDiagnosticFactory create() {
return new UnresolvedReferenceDiagnosticFactory();
}
}