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();
|
BindingContext bc = analyzeExhaust.getBindingContext();
|
||||||
Collection<DeclarationDescriptor> descriptorsWithErrors = bc.getKeys(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS);
|
Collection<DeclarationDescriptor> descriptorsWithErrors = bc.getKeys(BindingContext.LOAD_FROM_JAVA_SIGNATURE_ERRORS);
|
||||||
if (!descriptorsWithErrors.isEmpty()) {
|
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) {
|
for (DeclarationDescriptor descriptor : descriptorsWithErrors) {
|
||||||
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bc, descriptor);
|
PsiElement declaration = BindingContextUtils.descriptorToDeclaration(bc, descriptor);
|
||||||
assert declaration instanceof PsiModifierListOwner;
|
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);
|
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) {
|
for (String error : errors) {
|
||||||
messageCollectorWrapper.report(CompilerMessageSeverity.ERROR,
|
message.append(" ").append(error).append("\n");
|
||||||
messageStart + error + "\n", CompilerMessageLocation.NO_LOCATION);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
messageCollectorWrapper.report(CompilerMessageSeverity.ERROR,
|
||||||
|
message.toString(), CompilerMessageLocation.NO_LOCATION);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
package test;
|
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:
|
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
|
COMPILATION_ERROR
|
||||||
|
|||||||
+6
-1
@@ -1,8 +1,13 @@
|
|||||||
import jet.runtime.typeinfo.KotlinSignature;
|
import jet.runtime.typeinfo.KotlinSignature;
|
||||||
|
|
||||||
public class ClassWithWrongKotlinSignature {
|
public class ClassWithWrongKotlinSignatures {
|
||||||
@KotlinSignature("fun bar() : String")
|
@KotlinSignature("fun bar() : String")
|
||||||
public static String foo() {
|
public static String foo() {
|
||||||
throw new UnsupportedOperationException();
|
throw new UnsupportedOperationException();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@KotlinSignature("fun foo() : String")
|
||||||
|
public static String bar() {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user