Add Show Kotlin Gradle DSL Logs Action (KT-31440)
Provide a label for this action in some script diagnostics from gradle dsl resolver ^KT-31440 Fixed
This commit is contained in:
+21
@@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@file:Suppress("PackageDirectoryMismatch")
|
||||
// TODO: move to scripting-idea module
|
||||
package org.jetbrains.kotlin.idea.script
|
||||
|
||||
import com.intellij.codeInsight.intention.IntentionAction
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import kotlin.script.experimental.api.ScriptDiagnostic
|
||||
|
||||
interface ScriptDiagnosticFixProvider {
|
||||
|
||||
fun provideFixes(annotation: ScriptDiagnostic): List<IntentionAction>
|
||||
|
||||
companion object {
|
||||
val EP_NAME = ExtensionPointName.create<ScriptDiagnosticFixProvider>("org.jetbrains.kotlin.scriptDiagnosticFixProvider")
|
||||
}
|
||||
}
|
||||
+12
-5
@@ -37,6 +37,7 @@ import com.intellij.openapi.wm.ex.StatusBarEx
|
||||
import com.intellij.psi.PsiFile
|
||||
import com.intellij.util.ui.UIUtil
|
||||
import org.jetbrains.kotlin.idea.core.script.IdeScriptReportSink
|
||||
import org.jetbrains.kotlin.idea.script.ScriptDiagnosticFixProvider
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import kotlin.script.experimental.api.ScriptDiagnostic
|
||||
import kotlin.script.experimental.api.SourceCode
|
||||
@@ -54,19 +55,25 @@ class ScriptExternalHighlightingPass(
|
||||
|
||||
val reports = IdeScriptReportSink.getReports(file.virtualFile)
|
||||
|
||||
val annotations = reports.mapNotNull { (message, severity, _ , location) ->
|
||||
val (startOffset, endOffset) = location?.let { computeOffsets(document, it) } ?: 0 to 0
|
||||
val annotations = reports.mapNotNull { scriptDiagnostic ->
|
||||
val (startOffset, endOffset) = scriptDiagnostic.location?.let { computeOffsets(document, it) } ?: 0 to 0
|
||||
val annotation = Annotation(
|
||||
startOffset,
|
||||
endOffset,
|
||||
severity.convertSeverity() ?: return@mapNotNull null,
|
||||
message,
|
||||
message
|
||||
scriptDiagnostic.severity.convertSeverity() ?: return@mapNotNull null,
|
||||
scriptDiagnostic.message,
|
||||
scriptDiagnostic.message
|
||||
)
|
||||
|
||||
// if range is empty, show notification panel in editor
|
||||
annotation.isFileLevelAnnotation = startOffset == endOffset
|
||||
|
||||
for (provider in ScriptDiagnosticFixProvider.EP_NAME.extensions) {
|
||||
provider.provideFixes(scriptDiagnostic).forEach {
|
||||
annotation.registerFix(it)
|
||||
}
|
||||
}
|
||||
|
||||
annotation
|
||||
}
|
||||
|
||||
|
||||
+12
-5
@@ -40,6 +40,7 @@ import org.jetbrains.kotlin.idea.core.script.IdeScriptReportSink
|
||||
import org.jetbrains.kotlin.idea.core.script.ScriptDefinitionsManager
|
||||
import org.jetbrains.kotlin.idea.core.script.ScriptDependenciesManager
|
||||
import org.jetbrains.kotlin.idea.core.script.ScriptsCompilationConfigurationUpdater
|
||||
import org.jetbrains.kotlin.idea.script.ScriptDiagnosticFixProvider
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import kotlin.script.experimental.api.ScriptDiagnostic
|
||||
import kotlin.script.experimental.api.SourceCode
|
||||
@@ -75,19 +76,25 @@ class ScriptExternalHighlightingPass(
|
||||
|
||||
val reports = IdeScriptReportSink.getReports(file.virtualFile)
|
||||
|
||||
val annotations = reports.mapNotNull { (message, severity, _ , location) ->
|
||||
val (startOffset, endOffset) = location?.let { computeOffsets(document, it) } ?: 0 to 0
|
||||
val annotations = reports.mapNotNull { scriptDiagnostic ->
|
||||
val (startOffset, endOffset) = scriptDiagnostic.location?.let { computeOffsets(document, it) } ?: 0 to 0
|
||||
val annotation = Annotation(
|
||||
startOffset,
|
||||
endOffset,
|
||||
severity.convertSeverity() ?: return@mapNotNull null,
|
||||
message,
|
||||
message
|
||||
scriptDiagnostic.severity.convertSeverity() ?: return@mapNotNull null,
|
||||
scriptDiagnostic.message,
|
||||
scriptDiagnostic.message
|
||||
)
|
||||
|
||||
// if range is empty, show notification panel in editor
|
||||
annotation.isFileLevelAnnotation = startOffset == endOffset
|
||||
|
||||
for (provider in ScriptDiagnosticFixProvider.EP_NAME.extensions) {
|
||||
provider.provideFixes(scriptDiagnostic).forEach {
|
||||
annotation.registerFix(it)
|
||||
}
|
||||
}
|
||||
|
||||
annotation
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user