Supported several load from Java errors per declaration.

This commit is contained in:
Evgeny Gerashchenko
2012-11-19 21:38:01 +04:00
parent 4525e05268
commit 60f30732ed
6 changed files with 33 additions and 21 deletions
@@ -38,6 +38,7 @@ import org.jetbrains.jet.lang.resolve.BindingContextUtils;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import java.util.Collection;
import java.util.List;
import static org.jetbrains.jet.lang.diagnostics.DiagnosticUtils.sortedDiagnostics;
@@ -118,17 +119,21 @@ public final class AnalyzerWithCompilerReport {
private void reportAlternativeSignatureErrors() {
assert analyzeExhaust != null;
BindingContext bc = analyzeExhaust.getBindingContext();
Collection<DeclarationDescriptor> descriptorsWithErrors = bc.getKeys(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERROR);
Collection<DeclarationDescriptor> descriptorsWithErrors = bc.getKeys(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS);
if (!descriptorsWithErrors.isEmpty()) {
StringBuilder message = new StringBuilder("The following Java entities have annotations wrong Kotlin signatures:\n");
StringBuilder messageStart = new StringBuilder("The following Java entities have annotations wrong Kotlin signatures:\n");
for (DeclarationDescriptor descriptor : descriptorsWithErrors) {
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bc, descriptor);
assert declaration instanceof PsiModifierListOwner;
String externalName = PsiFormatUtil.getExternalName((PsiModifierListOwner) declaration);
message.append(externalName).append(": ");
message.append(bc.get(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERROR, descriptor)).append("\n");
messageStart.append(externalName).append(": ");
List<String> errors = bc.get(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor);
assert errors != null;
for (String error : errors) {
messageCollectorWrapper.report(CompilerMessageSeverity.ERROR,
messageStart + error + "\n", CompilerMessageLocation.NO_LOCATION);
}
}
messageCollectorWrapper.report(CompilerMessageSeverity.ERROR, message.toString(), CompilerMessageLocation.NO_LOCATION);
}
}