[FIR] Render list of symbols with linebreaks as separators

#KT-61823 Fixed
This commit is contained in:
Kirill Rakhman
2024-02-15 12:32:59 +01:00
committed by Space Team
parent 4c9fc8f214
commit f231338cd6
27 changed files with 199 additions and 79 deletions
@@ -160,16 +160,16 @@ object FirJsErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
map.put(NAME_CONTAINS_ILLEGAL_CHARS, "Name contains illegal chars that cannot appear in JavaScript identifier.")
map.put(
JS_NAME_CLASH,
"JavaScript name ({0}) generated for this declaration clashes with another declarations: {1}",
"JavaScript name ''{0}'' generated for this declaration clashes with other declarations:{1}",
CommonRenderers.STRING,
FirDiagnosticRenderers.SYMBOLS
FirDiagnosticRenderers.SYMBOLS_ON_NEXT_LINES
)
map.put(
JS_FAKE_NAME_CLASH,
"JavaScript name {0} is generated for different inherited members: {1} and {2}",
"JavaScript name ''{0}'' is generated for different inherited members:\n{1}{2}",
CommonRenderers.STRING,
FirDiagnosticRenderers.SYMBOL,
FirDiagnosticRenderers.SYMBOLS
FirDiagnosticRenderers.SYMBOLS_ON_NEXT_LINES
)
map.put(JS_NAME_IS_NOT_ON_ALL_ACCESSORS, "'@JsName' should be on all the property accessors.")
@@ -10,7 +10,7 @@ import org.jetbrains.kotlin.diagnostics.KtDiagnosticRenderers.TO_STRING
import org.jetbrains.kotlin.diagnostics.rendering.BaseDiagnosticRendererFactory
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOL
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOLS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOLS_ON_NEXT_LINES
import org.jetbrains.kotlin.fir.analysis.diagnostics.native.FirNativeErrors.CANNOT_CHECK_FOR_FORWARD_DECLARATION
import org.jetbrains.kotlin.fir.analysis.diagnostics.native.FirNativeErrors.CONFLICTING_OBJC_OVERLOADS
import org.jetbrains.kotlin.fir.analysis.diagnostics.native.FirNativeErrors.CONSTRUCTOR_DOES_NOT_OVERRIDE_ANY_SUPER_CONSTRUCTOR
@@ -53,7 +53,7 @@ object FirNativeErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
override val MAP = KtDiagnosticFactoryToRendererMap("FIR").also { map ->
map.put(THROWS_LIST_EMPTY, "Throws must have a non-empty class list.")
map.put(INCOMPATIBLE_THROWS_OVERRIDE, "Member overrides different ''@Throws'' filter from ''{0}''.", SYMBOL)
map.put(INCOMPATIBLE_THROWS_INHERITED, "Member inherits different ''@Throws'' filters from ''{0}''.", SYMBOLS)
map.put(INCOMPATIBLE_THROWS_INHERITED, "Member inherits different ''@Throws'' filters from:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(
MISSING_EXCEPTION_IN_THROWS_ON_SUSPEND, "''@Throws'' on suspend declaration must have ''{0}'' (or any of its superclasses) listed.",
TO_STRING
@@ -72,9 +72,9 @@ object FirNativeErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
map.put(REDUNDANT_SWIFT_REFINEMENT, "ObjC refined declarations cannot be refined in Swift.")
map.put(
INCOMPATIBLE_OBJC_REFINEMENT_OVERRIDE,
"Refined declaration ''{0}'' overrides declarations with different or no refinement from ''{1}''.",
"Refined declaration ''{0}'' overrides declarations with different or no refinement from:{1}",
SYMBOL,
SYMBOLS
SYMBOLS_ON_NEXT_LINES
)
map.put(
INVALID_OBJC_HIDES_TARGETS,
@@ -89,7 +89,7 @@ object FirNativeErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
map.put(EMPTY_OBJC_NAME, "Empty '@ObjCName' names aren't supported.")
map.put(INVALID_OBJC_NAME_CHARS, "''@ObjCName'' contains illegal characters ''{0}''.", TO_STRING)
map.put(INVALID_OBJC_NAME_FIRST_CHAR, "''@ObjCName'' contains illegal first characters ''{0}''.", TO_STRING)
map.put(INCOMPATIBLE_OBJC_NAME_OVERRIDE, "Member ''{0}'' inherits inconsistent ''@ObjCName'' from ''{1}''.", SYMBOL, SYMBOLS)
map.put(INCOMPATIBLE_OBJC_NAME_OVERRIDE, "Member ''{0}'' inherits inconsistent ''@ObjCName'' from:{1}", SYMBOL, SYMBOLS_ON_NEXT_LINES)
map.put(INAPPLICABLE_EXACT_OBJC_NAME, "Exact '@ObjCName' is only applicable to classes, objects, and interfaces.")
map.put(MISSING_EXACT_OBJC_NAME, "Exact '@ObjCName' is required to have an ObjC name.")
map.put(NON_LITERAL_OBJC_NAME_ARG, "'@ObjCName' accepts only literal 'String' and 'Boolean' values.")
@@ -149,8 +149,8 @@ object FirNativeErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
)
map.put(
CONFLICTING_OBJC_OVERLOADS,
"Conflicting overloads: {0}. Add @ObjCSignatureOverride to allow collision for functions inherited from Objective-C.",
SYMBOLS
"Conflicting overloads:{0}\nAdd @ObjCSignatureOverride to allow collision for functions inherited from Objective-C.",
SYMBOLS_ON_NEXT_LINES
)
map.put(
INAPPLICABLE_OBJC_OVERRIDE,
@@ -53,7 +53,12 @@ object FirDiagnosticRenderers {
}
}
val SYMBOLS = KtDiagnosticRenderers.COLLECTION(SYMBOL)
/**
* Adds a line break before the list, then prints one symbol per line.
*/
val SYMBOLS_ON_NEXT_LINES = Renderer { symbols: Collection<FirBasedSymbol<*>> ->
symbols.joinToString(separator = "\n", prefix = "\n", transform = SYMBOL::render)
}
val SYMBOLS_ON_NEWLINE_WITH_INDENT = object : ContextIndependentParameterRenderer<Collection<FirCallableSymbol<*>>> {
private val mode = MultiplatformDiagnosticRenderingMode()
@@ -42,7 +42,7 @@ import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.REND
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.RENDER_TYPE
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.REQUIRE_KOTLIN_VERSION
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOL
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOLS
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOLS_ON_NEXT_LINES
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOLS_ON_NEWLINE_WITH_INDENT
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.SYMBOL_WITH_CONTAINING_DECLARATION
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirDiagnosticRenderers.VARIABLE_NAME
@@ -1126,8 +1126,8 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
)
map.put(
AMBIGUOUS_ANNOTATION_ARGUMENT,
"Resolution of the annotation argument is ambiguous between {0}. Please use a fully qualified name as argument.",
SYMBOLS,
"Resolution of the annotation argument is ambiguous between the following candidates:{0}\nPlease use a fully qualified name as argument.",
SYMBOLS_ON_NEXT_LINES,
)
// Exposed visibility group // #
@@ -1187,7 +1187,7 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
map.put(SUPERTYPE_NOT_INITIALIZED, "This type has a constructor, so it must be initialized here.")
// Applicability
map.put(NONE_APPLICABLE, "None of the following functions is applicable: {0}", SYMBOLS)
map.put(NONE_APPLICABLE, "None of the following candidates is applicable:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(INAPPLICABLE_CANDIDATE, "Inapplicable candidate(s): {0}", SYMBOL)
map.put(INAPPLICABLE_LATEINIT_MODIFIER, "''lateinit'' modifier ''{0}''.", TO_STRING)
map.put(VARARG_OUTSIDE_PARENTHESES, "Passing value as a vararg is allowed only inside a parenthesized argument list.")
@@ -1275,12 +1275,12 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
map.put(ITERATOR_MISSING, "For-loop range must have an 'iterator()' method.")
map.put(ITERATOR_ON_NULLABLE, "Non-nullable value required to call an 'iterator()' method in a for-loop.")
map.put(ITERATOR_AMBIGUITY, "Method ''iterator()'' is ambiguous for this expression: {0}", SYMBOLS)
map.put(ITERATOR_AMBIGUITY, "Method ''iterator()'' is ambiguous for this expression. Applicable candidates:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(NEXT_MISSING, "Method 'next()' cannot be called on 'iterator()'.")
map.put(NEXT_AMBIGUITY, "Method ''next()'' is ambiguous for this expression: {0}", SYMBOLS)
map.put(NEXT_AMBIGUITY, "Method ''next()'' is ambiguous for this expression. Applicable candidates:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(AMBIGUOUS_FUNCTION_TYPE_KIND, "Multiple function type conversions are prohibited for a single type. Detected type conversions: {0}", FUNCTIONAL_TYPE_KINDS)
map.put(NEXT_NONE_APPLICABLE, "None of the ''next()'' functions is applicable for ''iterator()'' of type ''{0}''.", SYMBOLS)
map.put(NEXT_NONE_APPLICABLE, "None of the ''next()'' functions is applicable for this expression. Candidates are:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(NO_CONTEXT_RECEIVER, "No context receiver for ''{0}'' found.", RENDER_TYPE)
map.put(
@@ -1306,15 +1306,15 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
)
// Ambiguity
map.put(OVERLOAD_RESOLUTION_AMBIGUITY, "Overload resolution ambiguity between candidates: {0}", SYMBOLS)
map.put(ASSIGN_OPERATOR_AMBIGUITY, "Ambiguity between assign operator candidates: {0}", SYMBOLS)
map.put(OVERLOAD_RESOLUTION_AMBIGUITY, "Overload resolution ambiguity between candidates:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(ASSIGN_OPERATOR_AMBIGUITY, "Ambiguity between assign operator candidates:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(HAS_NEXT_MISSING, "'hasNext()' cannot be called on 'iterator()'.")
map.put(HAS_NEXT_FUNCTION_AMBIGUITY, "Method ''hasNext()'' is ambiguous for this expression: {0}", SYMBOLS)
map.put(HAS_NEXT_FUNCTION_NONE_APPLICABLE, "None of the ''hasNext()'' functions is applicable for ''iterator()'' of type ''{0}''.", SYMBOLS)
map.put(HAS_NEXT_FUNCTION_AMBIGUITY, "Method ''hasNext()'' is ambiguous for this expression. Applicable candidates:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(HAS_NEXT_FUNCTION_NONE_APPLICABLE, "None of the ''hasNext()'' functions is applicable for this expression. Candidates are:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(
UNRESOLVED_REFERENCE_WRONG_RECEIVER,
"Unresolved reference. None of the following candidates is applicable because of receiver type mismatch: {0}",
SYMBOLS
"Unresolved reference. None of the following candidates is applicable because of a receiver type mismatch:{0}",
SYMBOLS_ON_NEXT_LINES
)
// Types & type parameters
@@ -1668,9 +1668,9 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
)
map.put(
ABSTRACT_MEMBER_NOT_IMPLEMENTED_BY_ENUM_ENTRY,
"{0} does not implement abstract members: {1}.",
"{0} does not implement abstract members:{1}",
RENDER_ENUM_ENTRY_QUOTED,
SYMBOLS,
SYMBOLS_ON_NEXT_LINES,
)
map.put(
ABSTRACT_CLASS_MEMBER_NOT_IMPLEMENTED,
@@ -1816,9 +1816,9 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
// Redeclarations
map.put(MANY_COMPANION_OBJECTS, "Only one companion object is allowed per class.")
map.put(CONFLICTING_OVERLOADS, "Conflicting overloads: {0}", SYMBOLS)
map.put(REDECLARATION, "Conflicting declarations: {0}", SYMBOLS)
map.put(PACKAGE_OR_CLASSIFIER_REDECLARATION, "Redeclaration: {0}", SYMBOLS)
map.put(CONFLICTING_OVERLOADS, "Conflicting overloads:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(REDECLARATION, "Conflicting declarations:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(PACKAGE_OR_CLASSIFIER_REDECLARATION, "Redeclaration:{0}", SYMBOLS_ON_NEXT_LINES)
map.put(EXPECT_AND_ACTUAL_IN_THE_SAME_MODULE, "{0}: expect and corresponding actual are declared in the same module", DECLARATION_NAME)
map.put(METHOD_OF_ANY_IMPLEMENTED_IN_INTERFACE, "Interfaces cannot implement a method of 'Any'.")
@@ -2305,15 +2305,15 @@ object FirErrorsDefaultMessages : BaseDiagnosticRendererFactory() {
)
map.put(
DELEGATE_SPECIAL_FUNCTION_AMBIGUITY,
"Overload resolution ambiguity on method ''{0}'': {1}",
"Overload resolution ambiguity on method ''{0}'':{1}",
TO_STRING,
SYMBOLS
SYMBOLS_ON_NEXT_LINES
)
map.put(
DELEGATE_SPECIAL_FUNCTION_NONE_APPLICABLE,
"Property delegate must have a ''{0}'' method. None of the following functions is suitable: {1}",
"Property delegate must have a ''{0}'' method. None of the following functions is applicable:{1}",
TO_STRING,
SYMBOLS
SYMBOLS_ON_NEXT_LINES
)
map.put(
DELEGATE_SPECIAL_FUNCTION_RETURN_TYPE_MISMATCH,