Fixed printing multiple errors in Kotlin signatures.
This commit is contained in:
+10
-6
@@ -121,19 +121,23 @@ public final class AnalyzerWithCompilerReport {
|
||||
BindingContext bc = analyzeExhaust.getBindingContext();
|
||||
Collection<DeclarationDescriptor> descriptorsWithErrors = bc.getKeys(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS);
|
||||
if (!descriptorsWithErrors.isEmpty()) {
|
||||
StringBuilder messageStart = new StringBuilder("The following Java entities have annotations wrong Kotlin signatures:\n");
|
||||
StringBuilder message = 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);
|
||||
messageStart.append(externalName).append(": ");
|
||||
|
||||
List<String> errors = bc.get(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS, descriptor);
|
||||
assert errors != null;
|
||||
assert errors != null && !errors.isEmpty();
|
||||
|
||||
String externalName = PsiFormatUtil.getExternalName((PsiModifierListOwner) declaration);
|
||||
message.append(externalName).append(":\n");
|
||||
|
||||
for (String error : errors) {
|
||||
messageCollectorWrapper.report(CompilerMessageSeverity.ERROR,
|
||||
messageStart + error + "\n", CompilerMessageLocation.NO_LOCATION);
|
||||
message.append(" ").append(error).append("\n");
|
||||
}
|
||||
}
|
||||
messageCollectorWrapper.report(CompilerMessageSeverity.ERROR,
|
||||
message.toString(), CompilerMessageLocation.NO_LOCATION);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
package test;
|
||||
|
||||
val x = ClassWithWrongKotlinSignature.foo()
|
||||
val x = ClassWithWrongKotlinSignatures.foo()
|
||||
val y = ClassWithWrongKotlinSignatures.bar()
|
||||
@@ -1,4 +1,7 @@
|
||||
ERROR: The following Java entities have annotations wrong Kotlin signatures:
|
||||
ClassWithWrongKotlinSignature java.lang.String foo(): Function names mismatch, original: foo, alternative: bar
|
||||
ClassWithWrongKotlinSignatures java.lang.String foo():
|
||||
Function names mismatch, original: foo, alternative: bar
|
||||
ClassWithWrongKotlinSignatures java.lang.String bar():
|
||||
Function names mismatch, original: bar, alternative: foo
|
||||
|
||||
COMPILATION_ERROR
|
||||
|
||||
+6
-1
@@ -1,8 +1,13 @@
|
||||
import jet.runtime.typeinfo.KotlinSignature;
|
||||
|
||||
public class ClassWithWrongKotlinSignature {
|
||||
public class ClassWithWrongKotlinSignatures {
|
||||
@KotlinSignature("fun bar() : String")
|
||||
public static String foo() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@KotlinSignature("fun foo() : String")
|
||||
public static String bar() {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user