Diagnostics with psi elements added
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
package org.jetbrains.jet.lang.diagnostics;
|
||||
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class DiagnosticWithPsiElement<T extends PsiElement> extends GenericDiagnostic {
|
||||
private final T psiElement;
|
||||
|
||||
public DiagnosticWithPsiElement(DiagnosticFactory factory, Severity severity, String message, T psiElement) {
|
||||
super(factory, severity, message, psiElement.getTextRange());
|
||||
this.psiElement = psiElement;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public T getPsiElement() {
|
||||
return psiElement;
|
||||
}
|
||||
}
|
||||
@@ -63,7 +63,7 @@ public interface Errors {
|
||||
|
||||
@NotNull
|
||||
public Diagnostic on(@NotNull PsiElement element) {
|
||||
return on(element.getTextRange());
|
||||
return new DiagnosticWithPsiElement<PsiElement>(this, severity, message, element);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -102,7 +102,7 @@ public interface Errors {
|
||||
|
||||
@NotNull
|
||||
public Diagnostic on(@NotNull PsiElement element, @NotNull T argument) {
|
||||
return on(element.getTextRange(), argument);
|
||||
return new DiagnosticWithPsiElement<PsiElement>(this, severity, makeMessage(argument), element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ public interface Errors {
|
||||
|
||||
@NotNull
|
||||
public Diagnostic on(@NotNull PsiElement element, @NotNull A a, @NotNull B b) {
|
||||
return on(element.getTextRange(), a, b);
|
||||
return new DiagnosticWithPsiElement<PsiElement>(this, severity, makeMessage(a, b), element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -180,7 +180,7 @@ public interface Errors {
|
||||
|
||||
@NotNull
|
||||
public Diagnostic on(@NotNull PsiElement element, @NotNull A a, @NotNull B b, @NotNull C c) {
|
||||
return on(element.getTextRange(), a, b, c);
|
||||
return new DiagnosticWithPsiElement<PsiElement>(this, severity, makeMessage(a, b, c), element);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -537,18 +537,11 @@ public interface Errors {
|
||||
|
||||
RedeclarationDiagnosticFactory REDECLARATION = RedeclarationDiagnosticFactory.INSTANCE;
|
||||
|
||||
public class UnresolvedReferenceDiagnostic extends GenericDiagnostic {
|
||||
|
||||
private final JetReferenceExpression reference;
|
||||
public class UnresolvedReferenceDiagnostic extends DiagnosticWithPsiElement<JetReferenceExpression> {
|
||||
|
||||
public UnresolvedReferenceDiagnostic(JetReferenceExpression referenceExpression) {
|
||||
super(UNRESOLVED_REFERENCE, ERROR, "Unresolved reference", referenceExpression.getTextRange());
|
||||
this.reference = referenceExpression;
|
||||
super(UNRESOLVED_REFERENCE, ERROR, "Unresolved reference", referenceExpression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetReferenceExpression getReference() {
|
||||
return reference;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user