[FE 1.0] Add compiler flag for rendering internal diagnostic names in error messages
This commit is contained in:
committed by
TeamCityServer
parent
b9c22a5e5e
commit
dd953908df
+3
@@ -407,6 +407,9 @@ abstract class CommonCompilerArguments : CommonToolArguments() {
|
|||||||
@Argument(value = "-Xenable-incremental-compilation", description = "Enable incremental compilation")
|
@Argument(value = "-Xenable-incremental-compilation", description = "Enable incremental compilation")
|
||||||
var incrementalCompilation: Boolean? by FreezableVar(null)
|
var incrementalCompilation: Boolean? by FreezableVar(null)
|
||||||
|
|
||||||
|
@Argument(value = "-Xrender-internal-diagnostic-names", description = "Render internal names of warnings and errors")
|
||||||
|
var renderInternalDiagnosticNames: Boolean by FreezableVar(false)
|
||||||
|
|
||||||
open fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap<AnalysisFlag<*>, Any> {
|
open fun configureAnalysisFlags(collector: MessageCollector, languageVersion: LanguageVersion): MutableMap<AnalysisFlag<*>, Any> {
|
||||||
return HashMap<AnalysisFlag<*>, Any>().apply {
|
return HashMap<AnalysisFlag<*>, Any>().apply {
|
||||||
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
put(AnalysisFlags.skipMetadataVersionCheck, skipMetadataVersionCheck)
|
||||||
|
|||||||
@@ -208,6 +208,8 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
|||||||
List<KtFile> sourcesFiles = environmentForJS.getSourceFiles();
|
List<KtFile> sourcesFiles = environmentForJS.getSourceFiles();
|
||||||
|
|
||||||
environmentForJS.getConfiguration().put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.getAllowKotlinPackage());
|
environmentForJS.getConfiguration().put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.getAllowKotlinPackage());
|
||||||
|
environmentForJS.getConfiguration().put(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME, arguments.getRenderInternalDiagnosticNames());
|
||||||
|
|
||||||
|
|
||||||
if (!UtilsKt.checkKotlinPackageUsage(environmentForJS.getConfiguration(), sourcesFiles)) return ExitCode.COMPILATION_ERROR;
|
if (!UtilsKt.checkKotlinPackageUsage(environmentForJS.getConfiguration(), sourcesFiles)) return ExitCode.COMPILATION_ERROR;
|
||||||
|
|
||||||
@@ -252,7 +254,9 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
|||||||
AnalysisResult analysisResult;
|
AnalysisResult analysisResult;
|
||||||
do {
|
do {
|
||||||
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(
|
AnalyzerWithCompilerReport analyzerWithCompilerReport = new AnalyzerWithCompilerReport(
|
||||||
messageCollector, CommonConfigurationKeysKt.getLanguageVersionSettings(configuration)
|
messageCollector,
|
||||||
|
CommonConfigurationKeysKt.getLanguageVersionSettings(configuration),
|
||||||
|
configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)
|
||||||
);
|
);
|
||||||
List<KtFile> sources = environmentForJS.getSourceFiles();
|
List<KtFile> sources = environmentForJS.getSourceFiles();
|
||||||
analyzerWithCompilerReport.analyzeAndReport(sourcesFiles, () -> TopDownAnalyzerFacadeForJS.analyzeFiles(sources, config));
|
analyzerWithCompilerReport.analyzeAndReport(sourcesFiles, () -> TopDownAnalyzerFacadeForJS.analyzeFiles(sources, config));
|
||||||
@@ -321,7 +325,7 @@ public class K2JSCompiler extends CLICompiler<K2JSCompilerArguments> {
|
|||||||
|
|
||||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
|
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled();
|
||||||
|
|
||||||
AnalyzerWithCompilerReport.Companion.reportDiagnostics(translationResult.getDiagnostics(), messageCollector);
|
AnalyzerWithCompilerReport.Companion.reportDiagnostics(translationResult.getDiagnostics(), messageCollector, configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME));
|
||||||
|
|
||||||
if (translationResult instanceof TranslationResult.Fail) return ExitCode.COMPILATION_ERROR;
|
if (translationResult instanceof TranslationResult.Fail) return ExitCode.COMPILATION_ERROR;
|
||||||
|
|
||||||
|
|||||||
@@ -153,6 +153,7 @@ class K2JsIrCompiler : CLICompiler<K2JSCompilerArguments>() {
|
|||||||
val sourcesFiles = environmentForJS.getSourceFiles()
|
val sourcesFiles = environmentForJS.getSourceFiles()
|
||||||
|
|
||||||
configurationJs.put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
|
configurationJs.put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
|
||||||
|
configurationJs.put(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME, arguments.renderInternalDiagnosticNames)
|
||||||
configurationJs.put(JSConfigurationKeys.PROPERTY_LAZY_INITIALIZATION, arguments.irPropertyLazyInitialization)
|
configurationJs.put(JSConfigurationKeys.PROPERTY_LAZY_INITIALIZATION, arguments.irPropertyLazyInitialization)
|
||||||
|
|
||||||
if (!checkKotlinPackageUsage(environmentForJS.configuration, sourcesFiles)) return ExitCode.COMPILATION_ERROR
|
if (!checkKotlinPackageUsage(environmentForJS.configuration, sourcesFiles)) return ExitCode.COMPILATION_ERROR
|
||||||
|
|||||||
@@ -36,6 +36,9 @@ public class CLIConfigurationKeys {
|
|||||||
public static final CompilerConfigurationKey<MessageCollector> ORIGINAL_MESSAGE_COLLECTOR_KEY =
|
public static final CompilerConfigurationKey<MessageCollector> ORIGINAL_MESSAGE_COLLECTOR_KEY =
|
||||||
CompilerConfigurationKey.create("original message collector");
|
CompilerConfigurationKey.create("original message collector");
|
||||||
|
|
||||||
|
public static final CompilerConfigurationKey<Boolean> RENDER_DIAGNOSTIC_INTERNAL_NAME =
|
||||||
|
CompilerConfigurationKey.create("render diagnostic internal name");
|
||||||
|
|
||||||
public static final CompilerConfigurationKey<Boolean> ALLOW_KOTLIN_PACKAGE =
|
public static final CompilerConfigurationKey<Boolean> ALLOW_KOTLIN_PACKAGE =
|
||||||
CompilerConfigurationKey.create("allow kotlin package");
|
CompilerConfigurationKey.create("allow kotlin package");
|
||||||
public static final CompilerConfigurationKey<CommonCompilerPerformanceManager> PERF_MANAGER =
|
public static final CompilerConfigurationKey<CommonCompilerPerformanceManager> PERF_MANAGER =
|
||||||
|
|||||||
+26
-10
@@ -38,7 +38,8 @@ import org.jetbrains.kotlin.resolve.jvm.JvmBindingContextSlices
|
|||||||
|
|
||||||
class AnalyzerWithCompilerReport(
|
class AnalyzerWithCompilerReport(
|
||||||
private val messageCollector: MessageCollector,
|
private val messageCollector: MessageCollector,
|
||||||
private val languageVersionSettings: LanguageVersionSettings
|
private val languageVersionSettings: LanguageVersionSettings,
|
||||||
|
private val renderDiagnosticName: Boolean
|
||||||
) : AbstractAnalyzerWithCompilerReport {
|
) : AbstractAnalyzerWithCompilerReport {
|
||||||
override val targetEnvironment: TargetEnvironment
|
override val targetEnvironment: TargetEnvironment
|
||||||
get() = CompilerEnvironment
|
get() = CompilerEnvironment
|
||||||
@@ -47,7 +48,8 @@ class AnalyzerWithCompilerReport(
|
|||||||
|
|
||||||
constructor(configuration: CompilerConfiguration) : this(
|
constructor(configuration: CompilerConfiguration) : this(
|
||||||
configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY) ?: MessageCollector.NONE,
|
configuration.get(CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY) ?: MessageCollector.NONE,
|
||||||
configuration.languageVersionSettings
|
configuration.languageVersionSettings,
|
||||||
|
configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun reportIncompleteHierarchies() {
|
private fun reportIncompleteHierarchies() {
|
||||||
@@ -117,7 +119,7 @@ class AnalyzerWithCompilerReport(
|
|||||||
reportWarning = { message -> messageCollector.report(WARNING, message) }
|
reportWarning = { message -> messageCollector.report(WARNING, message) }
|
||||||
)
|
)
|
||||||
reportSyntaxErrors(files)
|
reportSyntaxErrors(files)
|
||||||
reportDiagnostics(analysisResult.bindingContext.diagnostics, messageCollector)
|
reportDiagnostics(analysisResult.bindingContext.diagnostics, messageCollector, renderDiagnosticName)
|
||||||
reportIncompleteHierarchies()
|
reportIncompleteHierarchies()
|
||||||
reportAlternativeSignatureErrors()
|
reportAlternativeSignatureErrors()
|
||||||
}
|
}
|
||||||
@@ -140,29 +142,43 @@ class AnalyzerWithCompilerReport(
|
|||||||
|
|
||||||
private val SYNTAX_ERROR_FACTORY = DiagnosticFactory0.create<PsiErrorElement>(Severity.ERROR)
|
private val SYNTAX_ERROR_FACTORY = DiagnosticFactory0.create<PsiErrorElement>(Severity.ERROR)
|
||||||
|
|
||||||
private fun reportDiagnostic(diagnostic: Diagnostic, reporter: DiagnosticMessageReporter): Boolean {
|
private fun reportDiagnostic(diagnostic: Diagnostic, reporter: DiagnosticMessageReporter, renderDiagnosticName: Boolean): Boolean {
|
||||||
if (!diagnostic.isValid) return false
|
if (!diagnostic.isValid) return false
|
||||||
|
|
||||||
|
val message = (diagnostic as? MyDiagnostic<*>)?.message ?: DefaultErrorMessages.render(diagnostic)
|
||||||
|
val textToRender = when (renderDiagnosticName) {
|
||||||
|
true -> "[${diagnostic.factoryName}] $message"
|
||||||
|
false -> message
|
||||||
|
}
|
||||||
|
|
||||||
reporter.report(
|
reporter.report(
|
||||||
diagnostic,
|
diagnostic,
|
||||||
diagnostic.psiFile,
|
diagnostic.psiFile,
|
||||||
(diagnostic as? MyDiagnostic<*>)?.message ?: DefaultErrorMessages.render(diagnostic)
|
textToRender
|
||||||
)
|
)
|
||||||
|
|
||||||
return diagnostic.severity == Severity.ERROR
|
return diagnostic.severity == Severity.ERROR
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reportDiagnostics(unsortedDiagnostics: GenericDiagnostics<*>, reporter: DiagnosticMessageReporter): Boolean {
|
fun reportDiagnostics(
|
||||||
|
unsortedDiagnostics: GenericDiagnostics<*>,
|
||||||
|
reporter: DiagnosticMessageReporter,
|
||||||
|
renderDiagnosticName: Boolean
|
||||||
|
): Boolean {
|
||||||
var hasErrors = false
|
var hasErrors = false
|
||||||
val diagnostics = sortedDiagnostics(unsortedDiagnostics.all().filterIsInstance<Diagnostic>())
|
val diagnostics = sortedDiagnostics(unsortedDiagnostics.all().filterIsInstance<Diagnostic>())
|
||||||
for (diagnostic in diagnostics) {
|
for (diagnostic in diagnostics) {
|
||||||
hasErrors = hasErrors or reportDiagnostic(diagnostic, reporter)
|
hasErrors = hasErrors or reportDiagnostic(diagnostic, reporter, renderDiagnosticName)
|
||||||
}
|
}
|
||||||
return hasErrors
|
return hasErrors
|
||||||
}
|
}
|
||||||
|
|
||||||
fun reportDiagnostics(diagnostics: GenericDiagnostics<*>, messageCollector: MessageCollector): Boolean {
|
fun reportDiagnostics(
|
||||||
val hasErrors = reportDiagnostics(diagnostics, DefaultDiagnosticReporter(messageCollector))
|
diagnostics: GenericDiagnostics<*>,
|
||||||
|
messageCollector: MessageCollector,
|
||||||
|
renderInternalDiagnosticName: Boolean
|
||||||
|
): Boolean {
|
||||||
|
val hasErrors = reportDiagnostics(diagnostics, DefaultDiagnosticReporter(messageCollector), renderInternalDiagnosticName)
|
||||||
|
|
||||||
if (diagnostics.any { it.factory == Errors.INCOMPATIBLE_CLASS }) {
|
if (diagnostics.any { it.factory == Errors.INCOMPATIBLE_CLASS }) {
|
||||||
messageCollector.report(
|
messageCollector.report(
|
||||||
@@ -207,7 +223,7 @@ class AnalyzerWithCompilerReport(
|
|||||||
|
|
||||||
private fun <E : PsiElement> reportDiagnostic(element: E, factory: DiagnosticFactory0<E>, message: String) {
|
private fun <E : PsiElement> reportDiagnostic(element: E, factory: DiagnosticFactory0<E>, message: String) {
|
||||||
val diagnostic = MyDiagnostic(element, factory, message)
|
val diagnostic = MyDiagnostic(element, factory, message)
|
||||||
AnalyzerWithCompilerReport.reportDiagnostic(diagnostic, reporter)
|
AnalyzerWithCompilerReport.reportDiagnostic(diagnostic, reporter, renderDiagnosticName = false)
|
||||||
if (allErrorsAtEof && !element.isAtEof()) {
|
if (allErrorsAtEof && !element.isAtEof()) {
|
||||||
allErrorsAtEof = false
|
allErrorsAtEof = false
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-1
@@ -98,6 +98,7 @@ object FirKotlinToJvmBytecodeCompiler {
|
|||||||
),
|
),
|
||||||
projectEnvironment,
|
projectEnvironment,
|
||||||
messageCollector,
|
messageCollector,
|
||||||
|
moduleConfiguration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME),
|
||||||
moduleConfiguration,
|
moduleConfiguration,
|
||||||
performanceManager,
|
performanceManager,
|
||||||
targetIds,
|
targetIds,
|
||||||
@@ -337,7 +338,8 @@ object FirKotlinToJvmBytecodeCompiler {
|
|||||||
generationState.collectedExtraJvmDiagnostics,
|
generationState.collectedExtraJvmDiagnostics,
|
||||||
dummyBindingContext.diagnostics
|
dummyBindingContext.diagnostics
|
||||||
),
|
),
|
||||||
messageCollector
|
messageCollector,
|
||||||
|
renderDiagnosticName
|
||||||
)
|
)
|
||||||
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
ProgressIndicatorAndCompilationCanceledStatus.checkCanceled()
|
||||||
|
|
||||||
@@ -349,6 +351,7 @@ object FirKotlinToJvmBytecodeCompiler {
|
|||||||
val allSources: List<KtFile>,
|
val allSources: List<KtFile>,
|
||||||
val projectEnvironment: AbstractProjectEnvironment,
|
val projectEnvironment: AbstractProjectEnvironment,
|
||||||
val messageCollector: MessageCollector,
|
val messageCollector: MessageCollector,
|
||||||
|
val renderDiagnosticName: Boolean,
|
||||||
val moduleConfiguration: CompilerConfiguration,
|
val moduleConfiguration: CompilerConfiguration,
|
||||||
val performanceManager: CommonCompilerPerformanceManager?,
|
val performanceManager: CommonCompilerPerformanceManager?,
|
||||||
val targetIds: List<TargetId>?,
|
val targetIds: List<TargetId>?,
|
||||||
|
|||||||
+7
-2
@@ -288,7 +288,11 @@ object KotlinToJVMBytecodeCompiler {
|
|||||||
jvmResolveLibraries(klibPaths, collector.toLogger())
|
jvmResolveLibraries(klibPaths, collector.toLogger())
|
||||||
}?.getFullList() ?: emptyList()
|
}?.getFullList() ?: emptyList()
|
||||||
|
|
||||||
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(collector, environment.configuration.languageVersionSettings)
|
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(
|
||||||
|
collector,
|
||||||
|
environment.configuration.languageVersionSettings,
|
||||||
|
environment.configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)
|
||||||
|
)
|
||||||
analyzerWithCompilerReport.analyzeAndReport(sourceFiles) {
|
analyzerWithCompilerReport.analyzeAndReport(sourceFiles) {
|
||||||
val project = environment.project
|
val project = environment.project
|
||||||
val moduleOutputs = environment.configuration.get(JVMConfigurationKeys.MODULES)?.mapNotNullTo(hashSetOf()) { module ->
|
val moduleOutputs = environment.configuration.get(JVMConfigurationKeys.MODULES)?.mapNotNullTo(hashSetOf()) { module ->
|
||||||
@@ -396,7 +400,8 @@ object KotlinToJVMBytecodeCompiler {
|
|||||||
state.collectedExtraJvmDiagnostics,
|
state.collectedExtraJvmDiagnostics,
|
||||||
bindingContext.diagnostics
|
bindingContext.diagnostics
|
||||||
),
|
),
|
||||||
messageCollector
|
messageCollector,
|
||||||
|
configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)
|
||||||
)
|
)
|
||||||
FirDiagnosticsCompilerResultsReporter.reportToMessageCollector(diagnosticsReporter, messageCollector)
|
FirDiagnosticsCompilerResultsReporter.reportToMessageCollector(diagnosticsReporter, messageCollector)
|
||||||
|
|
||||||
|
|||||||
@@ -311,6 +311,7 @@ fun CompilerConfiguration.configureAdvancedJvmOptions(arguments: K2JVMCompilerAr
|
|||||||
}
|
}
|
||||||
|
|
||||||
put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
|
put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
|
||||||
|
put(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME, arguments.renderInternalDiagnosticNames)
|
||||||
put(JVMConfigurationKeys.USE_SINGLE_MODULE, arguments.singleModule)
|
put(JVMConfigurationKeys.USE_SINGLE_MODULE, arguments.singleModule)
|
||||||
put(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME, arguments.useOldInlineClassesManglingScheme)
|
put(JVMConfigurationKeys.USE_OLD_INLINE_CLASSES_MANGLING_SCHEME, arguments.useOldInlineClassesManglingScheme)
|
||||||
put(JVMConfigurationKeys.ENABLE_JVM_PREVIEW, arguments.enableJvmPreview)
|
put(JVMConfigurationKeys.ENABLE_JVM_PREVIEW, arguments.enableJvmPreview)
|
||||||
|
|||||||
@@ -56,7 +56,11 @@ private fun runCommonAnalysis(
|
|||||||
val files = environment.getSourceFiles()
|
val files = environment.getSourceFiles()
|
||||||
val moduleName = Name.special("<${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>")
|
val moduleName = Name.special("<${configuration.getNotNull(CommonConfigurationKeys.MODULE_NAME)}>")
|
||||||
|
|
||||||
val analyzer = AnalyzerWithCompilerReport(messageCollector, configuration.languageVersionSettings)
|
val analyzer = AnalyzerWithCompilerReport(
|
||||||
|
messageCollector,
|
||||||
|
configuration.languageVersionSettings,
|
||||||
|
configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)
|
||||||
|
)
|
||||||
|
|
||||||
analyzer.analyzeAndReport(files) {
|
analyzer.analyzeAndReport(files) {
|
||||||
CommonResolverForModuleFactory.analyzeFiles(
|
CommonResolverForModuleFactory.analyzeFiles(
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ class K2MetadataCompiler : CLICompiler<K2MetadataCompilerArguments>() {
|
|||||||
configuration.put(CommonConfigurationKeys.MODULE_NAME, moduleName)
|
configuration.put(CommonConfigurationKeys.MODULE_NAME, moduleName)
|
||||||
|
|
||||||
configuration.put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
|
configuration.put(CLIConfigurationKeys.ALLOW_KOTLIN_PACKAGE, arguments.allowKotlinPackage)
|
||||||
|
configuration.put(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME, arguments.renderInternalDiagnosticNames)
|
||||||
|
|
||||||
configuration.putIfNotNull(K2MetadataConfigurationKeys.FRIEND_PATHS, arguments.friendPaths?.toList())
|
configuration.putIfNotNull(K2MetadataConfigurationKeys.FRIEND_PATHS, arguments.friendPaths?.toList())
|
||||||
configuration.putIfNotNull(K2MetadataConfigurationKeys.REFINES_PATHS, arguments.refinesPaths?.toList())
|
configuration.putIfNotNull(K2MetadataConfigurationKeys.REFINES_PATHS, arguments.refinesPaths?.toList())
|
||||||
|
|||||||
+2
@@ -91,6 +91,8 @@ where advanced options include:
|
|||||||
-Xproper-ieee754-comparisons Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types
|
-Xproper-ieee754-comparisons Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types
|
||||||
-Xread-deserialized-contracts Enable reading of contracts from metadata
|
-Xread-deserialized-contracts Enable reading of contracts from metadata
|
||||||
-Xklib-relative-path-base Provide a base paths to compute source's relative paths in klib (default is empty)
|
-Xklib-relative-path-base Provide a base paths to compute source's relative paths in klib (default is empty)
|
||||||
|
-Xrender-internal-diagnostic-names
|
||||||
|
Render internal names of warnings and errors
|
||||||
-Xreport-output-files Report source to output files mapping
|
-Xreport-output-files Report source to output files mapping
|
||||||
-Xreport-perf Report detailed performance statistics
|
-Xreport-perf Report detailed performance statistics
|
||||||
-Xself-upper-bound-inference Support inferring type arguments based on only self upper bounds of the corresponding type parameters
|
-Xself-upper-bound-inference Support inferring type arguments based on only self upper bounds of the corresponding type parameters
|
||||||
|
|||||||
+2
@@ -196,6 +196,8 @@ where advanced options include:
|
|||||||
-Xproper-ieee754-comparisons Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types
|
-Xproper-ieee754-comparisons Generate proper IEEE 754 comparisons in all cases if values are statically known to be of primitive numeric types
|
||||||
-Xread-deserialized-contracts Enable reading of contracts from metadata
|
-Xread-deserialized-contracts Enable reading of contracts from metadata
|
||||||
-Xklib-relative-path-base Provide a base paths to compute source's relative paths in klib (default is empty)
|
-Xklib-relative-path-base Provide a base paths to compute source's relative paths in klib (default is empty)
|
||||||
|
-Xrender-internal-diagnostic-names
|
||||||
|
Render internal names of warnings and errors
|
||||||
-Xreport-output-files Report source to output files mapping
|
-Xreport-output-files Report source to output files mapping
|
||||||
-Xreport-perf Report detailed performance statistics
|
-Xreport-perf Report detailed performance statistics
|
||||||
-Xself-upper-bound-inference Support inferring type arguments based on only self upper bounds of the corresponding type parameters
|
-Xself-upper-bound-inference Support inferring type arguments based on only self upper bounds of the corresponding type parameters
|
||||||
|
|||||||
@@ -0,0 +1,4 @@
|
|||||||
|
$TESTDATA_DIR$/reportInternalDiagnosticNames.kt
|
||||||
|
-Xrender-internal-diagnostic-names
|
||||||
|
-d
|
||||||
|
$TEMP_DIR$
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun test_2(): String {
|
||||||
|
val x: String = 1
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
compiler/testData/cli/jvm/reportInternalDiagnosticNames.kt:2:21: error: [CONSTANT_EXPECTED_TYPE_MISMATCH] The integer literal does not conform to the expected type String
|
||||||
|
val x: String = 1
|
||||||
|
^
|
||||||
|
compiler/testData/cli/jvm/reportInternalDiagnosticNames.kt:3:1: error: [NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY] A 'return' expression required in a function with a block body ('{...}')
|
||||||
|
}
|
||||||
|
^
|
||||||
|
COMPILATION_ERROR
|
||||||
+5
-1
@@ -49,7 +49,11 @@ class DiagnosticMessagesTextHandler(
|
|||||||
false
|
false
|
||||||
)
|
)
|
||||||
|
|
||||||
AnalyzerWithCompilerReport.reportDiagnostics(info.analysisResult.bindingContext.diagnostics, diagnosticsFullTextCollector)
|
AnalyzerWithCompilerReport.reportDiagnostics(
|
||||||
|
info.analysisResult.bindingContext.diagnostics,
|
||||||
|
diagnosticsFullTextCollector,
|
||||||
|
renderInternalDiagnosticName = false
|
||||||
|
)
|
||||||
|
|
||||||
diagnosticsFullTextCollector.flush()
|
diagnosticsFullTextCollector.flush()
|
||||||
diagnosticsFullTextPrintStream.flush()
|
diagnosticsFullTextPrintStream.flush()
|
||||||
|
|||||||
+5
-1
@@ -212,7 +212,11 @@ abstract class AbstractDiagnosticsTest : BaseDiagnosticsTest() {
|
|||||||
|
|
||||||
if (testFile.renderDiagnosticsFullText) {
|
if (testFile.renderDiagnosticsFullText) {
|
||||||
shouldCheckDiagnosticsFullText = true
|
shouldCheckDiagnosticsFullText = true
|
||||||
AnalyzerWithCompilerReport.reportDiagnostics(moduleBindingContext.diagnostics, diagnosticsFullTextCollector)
|
AnalyzerWithCompilerReport.reportDiagnostics(
|
||||||
|
moduleBindingContext.diagnostics,
|
||||||
|
diagnosticsFullTextCollector,
|
||||||
|
renderInternalDiagnosticName = false
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -776,6 +776,11 @@ public class CliTestGenerated extends AbstractCliTest {
|
|||||||
runTest("compiler/testData/cli/jvm/recordAsSingleFileRoot.args");
|
runTest("compiler/testData/cli/jvm/recordAsSingleFileRoot.args");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("reportInternalDiagnosticNames.args")
|
||||||
|
public void testReportInternalDiagnosticNames() throws Exception {
|
||||||
|
runTest("compiler/testData/cli/jvm/reportInternalDiagnosticNames.args");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("requireKotlinCompilerVersion.args")
|
@TestMetadata("requireKotlinCompilerVersion.args")
|
||||||
public void testRequireKotlinCompilerVersion() throws Exception {
|
public void testRequireKotlinCompilerVersion() throws Exception {
|
||||||
runTest("compiler/testData/cli/jvm/requireKotlinCompilerVersion.args");
|
runTest("compiler/testData/cli/jvm/requireKotlinCompilerVersion.args");
|
||||||
|
|||||||
+2
-1
@@ -188,7 +188,8 @@ class CompileKotlinAgainstCustomBinariesTest : AbstractKotlinCompilerIntegration
|
|||||||
|
|
||||||
AnalyzerWithCompilerReport.reportDiagnostics(
|
AnalyzerWithCompilerReport.reportDiagnostics(
|
||||||
result.bindingContext.diagnostics,
|
result.bindingContext.diagnostics,
|
||||||
PrintingMessageCollector(System.err, MessageRenderer.PLAIN_FULL_PATHS, false)
|
PrintingMessageCollector(System.err, MessageRenderer.PLAIN_FULL_PATHS, false),
|
||||||
|
renderInternalDiagnosticName = false
|
||||||
)
|
)
|
||||||
|
|
||||||
assertEquals("There should be no diagnostics", 0, result.bindingContext.diagnostics.count())
|
assertEquals("There should be no diagnostics", 0, result.bindingContext.diagnostics.count())
|
||||||
|
|||||||
+1
-1
@@ -27,7 +27,7 @@ class JsTranslationResultHandler(testServices: TestServices) : JsBinaryArtifactH
|
|||||||
if (result !is TranslationResult.Success) {
|
if (result !is TranslationResult.Success) {
|
||||||
val outputStream = ByteArrayOutputStream()
|
val outputStream = ByteArrayOutputStream()
|
||||||
val collector = PrintingMessageCollector(PrintStream(outputStream), MessageRenderer.PLAIN_FULL_PATHS, true)
|
val collector = PrintingMessageCollector(PrintStream(outputStream), MessageRenderer.PLAIN_FULL_PATHS, true)
|
||||||
AnalyzerWithCompilerReport.reportDiagnostics(result.diagnostics, collector)
|
AnalyzerWithCompilerReport.reportDiagnostics(result.diagnostics, collector, renderInternalDiagnosticName = false)
|
||||||
val messages = outputStream.toByteArray().toString(Charset.forName("UTF-8"))
|
val messages = outputStream.toByteArray().toString(Charset.forName("UTF-8"))
|
||||||
throw AssertionError("The following errors occurred compiling test:\n$messages")
|
throw AssertionError("The following errors occurred compiling test:\n$messages")
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ abstract class AbstractJsLineNumberTest : KotlinTestWithEnvironment() {
|
|||||||
if (translationResult !is TranslationResult.Success) {
|
if (translationResult !is TranslationResult.Success) {
|
||||||
val outputStream = ByteArrayOutputStream()
|
val outputStream = ByteArrayOutputStream()
|
||||||
val collector = PrintingMessageCollector(PrintStream(outputStream), MessageRenderer.PLAIN_FULL_PATHS, true)
|
val collector = PrintingMessageCollector(PrintStream(outputStream), MessageRenderer.PLAIN_FULL_PATHS, true)
|
||||||
AnalyzerWithCompilerReport.reportDiagnostics(translationResult.diagnostics, collector)
|
AnalyzerWithCompilerReport.reportDiagnostics(translationResult.diagnostics, collector, renderInternalDiagnosticName = false)
|
||||||
val messages = outputStream.toByteArray().toString(Charset.forName("UTF-8"))
|
val messages = outputStream.toByteArray().toString(Charset.forName("UTF-8"))
|
||||||
throw AssertionError("The following errors occurred compiling test:\n" + messages)
|
throw AssertionError("The following errors occurred compiling test:\n" + messages)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -81,6 +81,7 @@ class K2Native : CLICompiler<K2NativeCompilerArguments>() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
configuration.put(CommonConfigurationKeys.KLIB_NORMALIZE_ABSOLUTE_PATH, arguments.normalizeAbsolutePath)
|
configuration.put(CommonConfigurationKeys.KLIB_NORMALIZE_ABSOLUTE_PATH, arguments.normalizeAbsolutePath)
|
||||||
|
configuration.put(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME, arguments.renderInternalDiagnosticNames)
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val konanConfig = KonanConfig(project, configuration)
|
val konanConfig = KonanConfig(project, configuration)
|
||||||
|
|||||||
+8
-3
@@ -9,8 +9,10 @@ import kotlinx.cinterop.usingJvmCInteropCallbacks
|
|||||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
||||||
import org.jetbrains.kotlin.backend.common.phaser.CompilerPhase
|
import org.jetbrains.kotlin.backend.common.phaser.CompilerPhase
|
||||||
import org.jetbrains.kotlin.backend.common.phaser.invokeToplevel
|
import org.jetbrains.kotlin.backend.common.phaser.invokeToplevel
|
||||||
|
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
|
||||||
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
|
||||||
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
|
||||||
|
import org.jetbrains.kotlin.config.CommonConfigurationKeys
|
||||||
import org.jetbrains.kotlin.config.languageVersionSettings
|
import org.jetbrains.kotlin.config.languageVersionSettings
|
||||||
import org.jetbrains.kotlin.konan.util.usingNativeMemoryAllocator
|
import org.jetbrains.kotlin.konan.util.usingNativeMemoryAllocator
|
||||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||||
@@ -48,8 +50,11 @@ internal fun Context.frontendPhase(): Boolean {
|
|||||||
lateinit var analysisResult: AnalysisResult
|
lateinit var analysisResult: AnalysisResult
|
||||||
|
|
||||||
do {
|
do {
|
||||||
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(messageCollector,
|
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(
|
||||||
environment.configuration.languageVersionSettings)
|
messageCollector,
|
||||||
|
environment.configuration.languageVersionSettings,
|
||||||
|
environment.configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)
|
||||||
|
)
|
||||||
|
|
||||||
// Build AST and binding info.
|
// Build AST and binding info.
|
||||||
analyzerWithCompilerReport.analyzeAndReport(environment.getSourceFiles()) {
|
analyzerWithCompilerReport.analyzeAndReport(environment.getSourceFiles()) {
|
||||||
@@ -68,4 +73,4 @@ internal fun Context.frontendPhase(): Boolean {
|
|||||||
bindingContext = analysisResult.bindingContext
|
bindingContext = analysisResult.bindingContext
|
||||||
|
|
||||||
return analysisResult.shouldGenerateCode
|
return analysisResult.shouldGenerateCode
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -59,7 +59,7 @@ class JsCoreScriptingCompiler(
|
|||||||
|
|
||||||
val analyzerEngine = JsReplCodeAnalyzer(environment, dependencyDescriptors, analyzerState)
|
val analyzerEngine = JsReplCodeAnalyzer(environment, dependencyDescriptors, analyzerState)
|
||||||
val analysisResult = analyzerEngine.analyzeReplLine(snippetKtFile, codeLine).also {
|
val analysisResult = analyzerEngine.analyzeReplLine(snippetKtFile, codeLine).also {
|
||||||
AnalyzerWithCompilerReport.reportDiagnostics(it.bindingContext.diagnostics, messageCollector)
|
AnalyzerWithCompilerReport.reportDiagnostics(it.bindingContext.diagnostics, messageCollector, renderInternalDiagnosticName = false)
|
||||||
if (messageCollector.hasErrors()) return ReplCompileResult.Error("Error while analysis")
|
if (messageCollector.hasErrors()) return ReplCompileResult.Error("Error while analysis")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -111,7 +111,7 @@ open class KJvmReplCompilerBase<AnalyzerT : ReplCodeAnalyzerBase>(
|
|||||||
snippet,
|
snippet,
|
||||||
snippetNo
|
snippetNo
|
||||||
)
|
)
|
||||||
AnalyzerWithCompilerReport.reportDiagnostics(analysisResult.diagnostics, errorHolder)
|
AnalyzerWithCompilerReport.reportDiagnostics(analysisResult.diagnostics, errorHolder, renderDiagnosticName = false)
|
||||||
|
|
||||||
val scriptDescriptor = when (analysisResult) {
|
val scriptDescriptor = when (analysisResult) {
|
||||||
is ReplCodeAnalyzerBase.ReplLineAnalysisResult.WithErrors -> return failure(messageCollector)
|
is ReplCodeAnalyzerBase.ReplLineAnalysisResult.WithErrors -> return failure(messageCollector)
|
||||||
|
|||||||
+5
-1
@@ -215,7 +215,11 @@ private fun doCompile(
|
|||||||
private fun analyze(sourceFiles: Collection<KtFile>, environment: KotlinCoreEnvironment): AnalysisResult {
|
private fun analyze(sourceFiles: Collection<KtFile>, environment: KotlinCoreEnvironment): AnalysisResult {
|
||||||
val messageCollector = environment.configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY]!!
|
val messageCollector = environment.configuration[CLIConfigurationKeys.MESSAGE_COLLECTOR_KEY]!!
|
||||||
|
|
||||||
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(messageCollector, environment.configuration.languageVersionSettings)
|
val analyzerWithCompilerReport = AnalyzerWithCompilerReport(
|
||||||
|
messageCollector,
|
||||||
|
environment.configuration.languageVersionSettings,
|
||||||
|
environment.configuration.getBoolean(CLIConfigurationKeys.RENDER_DIAGNOSTIC_INTERNAL_NAME)
|
||||||
|
)
|
||||||
|
|
||||||
analyzerWithCompilerReport.analyzeAndReport(sourceFiles) {
|
analyzerWithCompilerReport.analyzeAndReport(sourceFiles) {
|
||||||
val project = environment.project
|
val project = environment.project
|
||||||
|
|||||||
+1
-1
@@ -79,7 +79,7 @@ open class GenericReplCompiler(
|
|||||||
}
|
}
|
||||||
|
|
||||||
val analysisResult = compilerState.analyzerEngine.analyzeReplLine(psiFile, codeLine)
|
val analysisResult = compilerState.analyzerEngine.analyzeReplLine(psiFile, codeLine)
|
||||||
AnalyzerWithCompilerReport.reportDiagnostics(analysisResult.diagnostics, errorHolder)
|
AnalyzerWithCompilerReport.reportDiagnostics(analysisResult.diagnostics, errorHolder, renderDiagnosticName = false)
|
||||||
val scriptDescriptor = when (analysisResult) {
|
val scriptDescriptor = when (analysisResult) {
|
||||||
is ReplCodeAnalyzerBase.ReplLineAnalysisResult.WithErrors -> {
|
is ReplCodeAnalyzerBase.ReplLineAnalysisResult.WithErrors -> {
|
||||||
return ReplCompileResult.Error(errorHolder.renderMessage())
|
return ReplCompileResult.Error(errorHolder.renderMessage())
|
||||||
|
|||||||
+1
-1
@@ -129,7 +129,7 @@ class KJvmReplCompilerWithIdeServices(hostConfiguration: ScriptingHostConfigurat
|
|||||||
val analyzerEngine = compilationState.analyzerEngine as IdeLikeReplCodeAnalyzer
|
val analyzerEngine = compilationState.analyzerEngine as IdeLikeReplCodeAnalyzer
|
||||||
val analysisResult =
|
val analysisResult =
|
||||||
analyzerEngine.statelessAnalyzeWithImportedScripts(snippetKtFile, emptyList(), state.getNextLineNo() + 1)
|
analyzerEngine.statelessAnalyzeWithImportedScripts(snippetKtFile, emptyList(), state.getNextLineNo() + 1)
|
||||||
AnalyzerWithCompilerReport.reportDiagnostics(analysisResult.diagnostics, errorHolder)
|
AnalyzerWithCompilerReport.reportDiagnostics(analysisResult.diagnostics, errorHolder, renderDiagnosticName = false)
|
||||||
|
|
||||||
val (_, bindingContext, resolutionFacade, moduleDescriptor, resultProperty) = when (analysisResult) {
|
val (_, bindingContext, resolutionFacade, moduleDescriptor, resultProperty) = when (analysisResult) {
|
||||||
is IdeLikeReplCodeAnalyzer.ReplLineAnalysisResultWithStateless.Stateless -> {
|
is IdeLikeReplCodeAnalyzer.ReplLineAnalysisResultWithStateless.Stateless -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user