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); 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 //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<JetSimpleNameExpression, DeclarationDescriptor, DeclarationDescriptor> INVISIBLE_REFERENCE = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<PsiElement, DeclarationDescriptor, DeclarationDescriptor> INVISIBLE_MEMBER = DiagnosticFactory2.create(ERROR); DiagnosticFactory2<PsiElement, DeclarationDescriptor, DeclarationDescriptor> INVISIBLE_MEMBER = DiagnosticFactory2.create(ERROR);
RedeclarationDiagnosticFactory REDECLARATION = RedeclarationDiagnosticFactory.REDECLARATION; RedeclarationDiagnosticFactory REDECLARATION = new RedeclarationDiagnosticFactory(ERROR);
RedeclarationDiagnosticFactory NAME_SHADOWING = RedeclarationDiagnosticFactory.NAME_SHADOWING; RedeclarationDiagnosticFactory NAME_SHADOWING = new RedeclarationDiagnosticFactory(WARNING);
DiagnosticFactory2<PsiElement, JetType, JetType> TYPE_MISMATCH = DiagnosticFactory2.create(ERROR DiagnosticFactory2<PsiElement, JetType, JetType> TYPE_MISMATCH = DiagnosticFactory2.create(ERROR
); );
@@ -107,7 +107,7 @@ public interface Errors {
.create(ERROR); .create(ERROR);
SimpleDiagnosticFactory<JetReferenceExpression> SimpleDiagnosticFactory<JetReferenceExpression>
ARGUMENT_PASSED_TWICE = SimpleDiagnosticFactory.create(ERROR); 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 SimpleDiagnosticFactory<JetExpression> VARARG_OUTSIDE_PARENTHESES = SimpleDiagnosticFactory
.create(ERROR); .create(ERROR);
SimpleDiagnosticFactory<LeafPsiElement> SimpleDiagnosticFactory<LeafPsiElement>
@@ -23,36 +23,16 @@ import org.jetbrains.annotations.NotNull;
* @author abreslav * @author abreslav
*/ */
public class RedeclarationDiagnosticFactory extends AbstractDiagnosticFactory { public class RedeclarationDiagnosticFactory extends AbstractDiagnosticFactory {
private final String name;
final Severity severity; final Severity severity;
private final String messagePrefix;
public static final RedeclarationDiagnosticFactory REDECLARATION = new RedeclarationDiagnosticFactory( public RedeclarationDiagnosticFactory(Severity severity) {
"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;
this.severity = severity; this.severity = severity;
this.messagePrefix = messagePrefix;
} }
public RedeclarationDiagnostic on(@NotNull PsiElement duplicatingElement, @NotNull String name) { public RedeclarationDiagnostic on(@NotNull PsiElement duplicatingElement, @NotNull String name) {
return new RedeclarationDiagnostic.SimpleRedeclarationDiagnostic(duplicatingElement, name, this); return new RedeclarationDiagnostic.SimpleRedeclarationDiagnostic(duplicatingElement, name, this);
} }
@NotNull
@Override
public String getName() {
return name;
}
public String makeMessage(String identifier) {
return messagePrefix + identifier;
}
@Override @Override
public String toString() { public String toString() {
return getName(); return getName();
@@ -23,21 +23,14 @@ import org.jetbrains.jet.lang.psi.JetReferenceExpression;
* @author abreslav * @author abreslav
*/ */
public class UnresolvedReferenceDiagnosticFactory extends AbstractDiagnosticFactory { public class UnresolvedReferenceDiagnosticFactory extends AbstractDiagnosticFactory {
private final String message; private UnresolvedReferenceDiagnosticFactory() {
private UnresolvedReferenceDiagnosticFactory(String message) {
this.message = message;
}
String getMessage() {
return message;
} }
public UnresolvedReferenceDiagnostic on(@NotNull JetReferenceExpression reference) { public UnresolvedReferenceDiagnostic on(@NotNull JetReferenceExpression reference) {
return new UnresolvedReferenceDiagnostic(reference, this); return new UnresolvedReferenceDiagnostic(reference, this);
} }
public static UnresolvedReferenceDiagnosticFactory create(String message) { public static UnresolvedReferenceDiagnosticFactory create() {
return new UnresolvedReferenceDiagnosticFactory(message); return new UnresolvedReferenceDiagnosticFactory();
} }
} }