From de8dd37e443aa53c0c633ef63b9d455b289868fa Mon Sep 17 00:00:00 2001 From: Alexander Udalov Date: Thu, 9 Feb 2017 15:51:37 +0300 Subject: [PATCH] Change DeserializedContainerSource.presentableFqName to String To allow outputting something other than "Class 'XXX'" in the diagnostic message for declarations deserialized from JS --- .../src/org/jetbrains/kotlin/diagnostics/Errors.java | 4 ++-- .../kotlin/diagnostics/rendering/DefaultErrorMessages.java | 4 ++-- .../resolve/checkers/MissingDependencyClassChecker.kt | 4 ++-- .../jetbrains/kotlin/load/kotlin/JvmPackagePartSource.kt | 7 +++---- .../kotlin/load/kotlin/KotlinJvmBinarySourceElement.kt | 7 +++---- .../descriptors/DeserializedMemberDescriptor.kt | 4 ++-- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 088fa89e36e..14c7aa0e286 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -99,8 +99,8 @@ public interface Errors { DiagnosticFactory2 API_NOT_AVAILABLE = DiagnosticFactory2.create(ERROR); DiagnosticFactory1 MISSING_DEPENDENCY_CLASS = DiagnosticFactory1.create(ERROR); - DiagnosticFactory1 PRE_RELEASE_CLASS = DiagnosticFactory1.create(ERROR); - DiagnosticFactory2> INCOMPATIBLE_CLASS = DiagnosticFactory2.create(ERROR); + DiagnosticFactory1 PRE_RELEASE_CLASS = DiagnosticFactory1.create(ERROR); + DiagnosticFactory2> INCOMPATIBLE_CLASS = DiagnosticFactory2.create(ERROR); //Elements with "INVISIBLE_REFERENCE" error are marked as unresolved, unlike elements with "INVISIBLE_MEMBER" error //"INVISIBLE_REFERENCE" is used for invisible classes references and references in import diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index e94d6d2634c..edb39ee3771 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -358,9 +358,9 @@ public class DefaultErrorMessages { MAP.put(API_NOT_AVAILABLE, "This declaration is only available since Kotlin {0} and cannot be used with the specified API version {1}", STRING, STRING); MAP.put(MISSING_DEPENDENCY_CLASS, "Cannot access class ''{0}''. Check your module classpath for missing or conflicting dependencies", TO_STRING); - MAP.put(PRE_RELEASE_CLASS, "Class ''{0}'' is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler", TO_STRING); + MAP.put(PRE_RELEASE_CLASS, "{0} is compiled by a pre-release version of Kotlin and cannot be loaded by this version of the compiler", TO_STRING); MAP.put(INCOMPATIBLE_CLASS, - "Class ''{0}'' was compiled with an incompatible version of Kotlin. {1}", + "{0} was compiled with an incompatible version of Kotlin. {1}", TO_STRING, new DiagnosticParameterRenderer>() { @NotNull @Override diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/MissingDependencyClassChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/MissingDependencyClassChecker.kt index 4fa4b91b9bd..78cd1aff5a0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/MissingDependencyClassChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/checkers/MissingDependencyClassChecker.kt @@ -59,10 +59,10 @@ object MissingDependencyClassChecker : CallChecker { if (source is DeserializedContainerSource) { val incompatibility = source.incompatibility if (incompatibility != null) { - return INCOMPATIBLE_CLASS.on(reportOn, source.presentableFqName, incompatibility) + return INCOMPATIBLE_CLASS.on(reportOn, source.presentableString, incompatibility) } if (source.isPreReleaseInvisible) { - return PRE_RELEASE_CLASS.on(reportOn, source.presentableFqName) + return PRE_RELEASE_CLASS.on(reportOn, source.presentableString) } } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmPackagePartSource.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmPackagePartSource.kt index f2c505a9fe0..ae3dd40999e 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmPackagePartSource.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/JvmPackagePartSource.kt @@ -18,7 +18,6 @@ package org.jetbrains.kotlin.load.kotlin import org.jetbrains.kotlin.descriptors.SourceFile import org.jetbrains.kotlin.name.ClassId -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.jvm.JvmClassName import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData @@ -43,14 +42,14 @@ class JvmPackagePartSource( isPreReleaseInvisible ) - override val presentableFqName: FqName - get() = classId.asSingleFqName() + override val presentableString: String + get() = "Class '${classId.asSingleFqName().asString()}'" val simpleName: Name get() = Name.identifier(className.internalName.substringAfterLast('/')) val classId: ClassId get() = ClassId(className.packageFqName, simpleName) - override fun toString() = "${javaClass.simpleName}: $className" + override fun toString() = "${this::class.java.simpleName}: $className" override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE } diff --git a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinarySourceElement.kt b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinarySourceElement.kt index afcab1a6a9b..daf3c035cbe 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinarySourceElement.kt +++ b/core/descriptor.loader.java/src/org/jetbrains/kotlin/load/kotlin/KotlinJvmBinarySourceElement.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.load.kotlin import org.jetbrains.kotlin.descriptors.SourceFile -import org.jetbrains.kotlin.name.FqName import org.jetbrains.kotlin.serialization.deserialization.IncompatibleVersionErrorData import org.jetbrains.kotlin.serialization.deserialization.descriptors.DeserializedContainerSource @@ -26,10 +25,10 @@ class KotlinJvmBinarySourceElement( override val incompatibility: IncompatibleVersionErrorData? = null, override val isPreReleaseInvisible: Boolean = false ) : DeserializedContainerSource { - override val presentableFqName: FqName - get() = binaryClass.classId.asSingleFqName() + override val presentableString: String + get() = "Class '${binaryClass.classId.asSingleFqName().asString()}'" override fun getContainingFile(): SourceFile = SourceFile.NO_SOURCE_FILE - override fun toString() = "${javaClass.simpleName}: $binaryClass" + override fun toString() = "${this::class.java.simpleName}: $binaryClass" } diff --git a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberDescriptor.kt b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberDescriptor.kt index 2cc4c95cfce..ab5b16d8d8a 100644 --- a/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberDescriptor.kt +++ b/core/deserialization/src/org/jetbrains/kotlin/serialization/deserialization/descriptors/DeserializedMemberDescriptor.kt @@ -55,8 +55,8 @@ interface DeserializedContainerSource : SourceElement { // True iff this is container is "invisible" because it's loaded from a pre-release class and this compiler is a release val isPreReleaseInvisible: Boolean - // This FQ name should only be used for error messages - val presentableFqName: FqName + // This string should only be used in error messages + val presentableString: String } interface DeserializedCallableMemberDescriptor : DeserializedMemberDescriptor, CallableMemberDescriptor