Redeclarations now report the redeclared name
This commit is contained in:
+3
-3
@@ -15,8 +15,8 @@ import static org.jetbrains.jet.lang.diagnostics.Severity.ERROR;
|
|||||||
public interface RedeclarationDiagnostic extends DiagnosticWithPsiElement<PsiElement> {
|
public interface RedeclarationDiagnostic extends DiagnosticWithPsiElement<PsiElement> {
|
||||||
public class SimpleRedeclarationDiagnostic extends DiagnosticWithPsiElementImpl<PsiElement> implements RedeclarationDiagnostic {
|
public class SimpleRedeclarationDiagnostic extends DiagnosticWithPsiElementImpl<PsiElement> implements RedeclarationDiagnostic {
|
||||||
|
|
||||||
public SimpleRedeclarationDiagnostic(@NotNull PsiElement psiElement) {
|
public SimpleRedeclarationDiagnostic(@NotNull PsiElement psiElement, @NotNull String name) {
|
||||||
super(RedeclarationDiagnosticFactory.INSTANCE, ERROR, "Redeclaration", psiElement);
|
super(RedeclarationDiagnosticFactory.INSTANCE, ERROR, "Redeclaration: " + name, psiElement);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -66,7 +66,7 @@ public interface RedeclarationDiagnostic extends DiagnosticWithPsiElement<PsiEle
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public String getMessage() {
|
public String getMessage() {
|
||||||
return "Redeclaration";
|
return "Redeclaration: " + duplicatingDescriptor.getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
+2
-2
@@ -16,8 +16,8 @@ public class RedeclarationDiagnosticFactory extends AbstractDiagnosticFactory {
|
|||||||
|
|
||||||
public RedeclarationDiagnosticFactory() {}
|
public RedeclarationDiagnosticFactory() {}
|
||||||
|
|
||||||
public RedeclarationDiagnostic on(@NotNull PsiElement duplicatingElement) {
|
public RedeclarationDiagnostic on(@NotNull PsiElement duplicatingElement, @NotNull String name) {
|
||||||
return new RedeclarationDiagnostic.SimpleRedeclarationDiagnostic(duplicatingElement);
|
return new RedeclarationDiagnostic.SimpleRedeclarationDiagnostic(duplicatingElement, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Diagnostic on(DeclarationDescriptor duplicatingDescriptor, BindingContext contextToResolveToDeclaration) {
|
public Diagnostic on(DeclarationDescriptor duplicatingDescriptor, BindingContext contextToResolveToDeclaration) {
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ public class TraceBasedRedeclarationHandler implements RedeclarationHandler {
|
|||||||
private void report(DeclarationDescriptor first) {
|
private void report(DeclarationDescriptor first) {
|
||||||
PsiElement firstElement = trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, first);
|
PsiElement firstElement = trace.get(BindingContext.DESCRIPTOR_TO_DECLARATION, first);
|
||||||
if (firstElement != null) {
|
if (firstElement != null) {
|
||||||
trace.report(REDECLARATION.on(firstElement));
|
trace.report(REDECLARATION.on(firstElement, first.getName()));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
trace.report(REDECLARATION.on(first, trace.getBindingContext()));
|
trace.report(REDECLARATION.on(first, trace.getBindingContext()));
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ public class JetPsiChecker implements Annotator {
|
|||||||
Collection<Diagnostic> diagnostics = Sets.newLinkedHashSet(bindingContext.getDiagnostics());
|
Collection<Diagnostic> diagnostics = Sets.newLinkedHashSet(bindingContext.getDiagnostics());
|
||||||
Set<PsiElement> redeclarations = Sets.newHashSet();
|
Set<PsiElement> redeclarations = Sets.newHashSet();
|
||||||
for (Diagnostic diagnostic : diagnostics) {
|
for (Diagnostic diagnostic : diagnostics) {
|
||||||
if (diagnostic.getFactory().getPsiFile(diagnostic) != file) continue;
|
if (diagnostic.getFactory().getPsiFile(diagnostic) != file) continue; // This is needed because we have the same context for all files
|
||||||
Annotation annotation = null;
|
Annotation annotation = null;
|
||||||
if (diagnostic.getSeverity() == Severity.ERROR) {
|
if (diagnostic.getSeverity() == Severity.ERROR) {
|
||||||
if (diagnostic instanceof UnresolvedReferenceDiagnostic) {
|
if (diagnostic instanceof UnresolvedReferenceDiagnostic) {
|
||||||
|
|||||||
Reference in New Issue
Block a user