i18n: Add bundle for idea-maven
This commit is contained in:
committed by
Dmitry Gridin
parent
830c7cef07
commit
2702be564a
+54
@@ -0,0 +1,54 @@
|
|||||||
|
configure.title=Configure Kotlin-Maven plugin
|
||||||
|
configure.java.with.maven=Java with Maven
|
||||||
|
configure.javascript.with.maven=JavaScript with Maven
|
||||||
|
|
||||||
|
version.different.maven.ide=Kotlin version that is used for building with Maven ({0}) differs from the one bundled into the IDE plugin ({1})
|
||||||
|
version.different.plugin.library=Plugin version ({0}) is not the same as library version ({1})
|
||||||
|
|
||||||
|
change.version=Change version
|
||||||
|
change.version.to=Change version to {0}
|
||||||
|
change.version.to.resolved=Change version to {0} ({1})
|
||||||
|
|
||||||
|
error.cant.find.pom.for.module=Cannot find pom.xml for module ''{0}''
|
||||||
|
|
||||||
|
file.was.modified={0} was modified
|
||||||
|
|
||||||
|
update.language.version.title=Update Language Version
|
||||||
|
update.language.version.feature=This language feature requires version ''{0}'' or later of the Kotlin runtime library. Please update the version in your build script.
|
||||||
|
update.language.version.feature.support={0} support requires version ''{1}'' or later of the Kotlin runtime library. Please update the version in your build script.
|
||||||
|
update.language.version.coroutines=Coroutines support requires version ''1.1'' or later of the Kotlin runtime library. Please update the version in your build script.
|
||||||
|
|
||||||
|
error.failed.update.pom=Failed to update pom.xml. Please update the file manually.
|
||||||
|
error.cant.configure.maven.automatically=Couldn't configure kotlin-maven plugin automatically.
|
||||||
|
error.see.installation.instructions=See manual installation instructions <a href="https://kotlinlang.org/docs/reference/using-maven.html#KotlinBuildTools-Maven">here</a>.
|
||||||
|
|
||||||
|
inspection.description=Reports kotlin-maven-plugin configuration issues
|
||||||
|
inspection.no.executions=Kotlin plugin has no compile executions
|
||||||
|
inspection.should.run.before.javac=Kotlin plugin should run before javac so kotlin classes could be visible from Java
|
||||||
|
inspection.javascript.in.java.module=JavaScript goal configured for module with Java files
|
||||||
|
inspection.jvm.no.stdlib.dependency=Kotlin/JVM compiler configured but no ''{0}'' dependency
|
||||||
|
inspection.javascript.no.stdlib.dependency=Kotlin/JavaScript compiler configured but no ''{0}'' dependency
|
||||||
|
inspection.configured.no.execution=You have {0} configured but no corresponding plugin execution
|
||||||
|
inspection.same.execution.compile.test=It is not recommended to have both ''compile'' and ''test'' goals in the same execution
|
||||||
|
|
||||||
|
fix.create.execution.name="Create {0} execution
|
||||||
|
fix.create.execution.family="Create Kotlin execution
|
||||||
|
|
||||||
|
fix.change.phase.name=Change phase to {0}
|
||||||
|
fix.change.phase.family=Change phase
|
||||||
|
|
||||||
|
fix.configure.right.order=Configure maven-compiler-plugin executions in the right order
|
||||||
|
|
||||||
|
fix.add.dependency.name=Add ''{0}'' dependency
|
||||||
|
fix.add.dependency.family=Add dependency
|
||||||
|
|
||||||
|
fix.create.execution.compiler.name=Create ''{0}'' execution of kotlin-maven-compiler
|
||||||
|
fix.create.execution.compiler.family=Create Kotlin execution
|
||||||
|
|
||||||
|
fix.add.maven.dependency.name=Add Maven dependency…
|
||||||
|
|
||||||
|
fix.kotlin.test.junit.is.recommended=''kotlin-test-junit'' is recommended
|
||||||
|
fix.kotlin.test.junit.replace=Replace with ''kotlin-test-junit''
|
||||||
|
|
||||||
|
fix.move.to.compile.execution=Move to ''compile'' execution
|
||||||
|
fix.move.to.build.sourceDirectory.tag=Move to ''build'' > ''sourceDirectory'' tag
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2020 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.maven
|
||||||
|
|
||||||
|
import com.intellij.CommonBundle
|
||||||
|
import org.jetbrains.annotations.NonNls
|
||||||
|
import org.jetbrains.annotations.PropertyKey
|
||||||
|
import org.jetbrains.kotlin.idea.core.util.KotlinBundleBase
|
||||||
|
import java.util.*
|
||||||
|
|
||||||
|
object KotlinMavenBundle : KotlinBundleBase() {
|
||||||
|
@NonNls
|
||||||
|
private const val BUNDLE = "org.jetbrains.kotlin.idea.maven.KotlinMavenBundle"
|
||||||
|
|
||||||
|
override fun createBundle(): ResourceBundle = ResourceBundle.getBundle(BUNDLE)
|
||||||
|
|
||||||
|
@JvmStatic
|
||||||
|
fun message(@NonNls @PropertyKey(resourceBundle = BUNDLE) key: String, vararg params: Any?): String {
|
||||||
|
return CommonBundle.message(bundle, key, *params)
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-2
@@ -28,12 +28,13 @@ import com.intellij.util.xml.GenericDomValue
|
|||||||
import org.jetbrains.idea.maven.dom.MavenDomUtil
|
import org.jetbrains.idea.maven.dom.MavenDomUtil
|
||||||
import org.jetbrains.idea.maven.dom.model.MavenDomBuild
|
import org.jetbrains.idea.maven.dom.model.MavenDomBuild
|
||||||
import org.jetbrains.idea.maven.dom.model.MavenDomPluginExecution
|
import org.jetbrains.idea.maven.dom.model.MavenDomPluginExecution
|
||||||
|
import org.jetbrains.kotlin.idea.maven.KotlinMavenBundle
|
||||||
import org.jetbrains.kotlin.idea.maven.PomFile
|
import org.jetbrains.kotlin.idea.maven.PomFile
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
import org.jetbrains.kotlin.psi.psiUtil.getParentOfType
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf
|
||||||
|
|
||||||
class MavenPluginSourcesMoveToExecutionIntention : PsiElementBaseIntentionAction() {
|
class MavenPluginSourcesMoveToExecutionIntention : PsiElementBaseIntentionAction() {
|
||||||
override fun getFamilyName() = "Move to compile execution"
|
override fun getFamilyName() = KotlinMavenBundle.message("fix.move.to.compile.execution")
|
||||||
override fun getText() = familyName
|
override fun getText() = familyName
|
||||||
|
|
||||||
override fun isAvailable(project: Project, editor: Editor, element: PsiElement): Boolean {
|
override fun isAvailable(project: Project, editor: Editor, element: PsiElement): Boolean {
|
||||||
@@ -95,7 +96,7 @@ class MavenPluginSourcesMoveToExecutionIntention : PsiElementBaseIntentionAction
|
|||||||
}
|
}
|
||||||
|
|
||||||
class MavenPluginSourcesMoveToBuild : PsiElementBaseIntentionAction() {
|
class MavenPluginSourcesMoveToBuild : PsiElementBaseIntentionAction() {
|
||||||
override fun getFamilyName() = "Move to build>sourceDirectory tag"
|
override fun getFamilyName() = KotlinMavenBundle.message("fix.move.to.build.sourceDirectory.tag")
|
||||||
override fun getText() = familyName
|
override fun getText() = familyName
|
||||||
|
|
||||||
override fun isAvailable(project: Project, editor: Editor, element: PsiElement): Boolean {
|
override fun isAvailable(project: Project, editor: Editor, element: PsiElement): Boolean {
|
||||||
|
|||||||
+2
-1
@@ -23,6 +23,7 @@ import org.jetbrains.idea.maven.dom.model.MavenDomPlugin
|
|||||||
import org.jetbrains.kotlin.idea.configuration.NotificationMessageCollector
|
import org.jetbrains.kotlin.idea.configuration.NotificationMessageCollector
|
||||||
import org.jetbrains.kotlin.idea.configuration.addStdlibToJavaModuleInfo
|
import org.jetbrains.kotlin.idea.configuration.addStdlibToJavaModuleInfo
|
||||||
import org.jetbrains.kotlin.idea.configuration.hasKotlinJvmRuntimeInScope
|
import org.jetbrains.kotlin.idea.configuration.hasKotlinJvmRuntimeInScope
|
||||||
|
import org.jetbrains.kotlin.idea.maven.KotlinMavenBundle
|
||||||
import org.jetbrains.kotlin.idea.maven.PomFile
|
import org.jetbrains.kotlin.idea.maven.PomFile
|
||||||
import org.jetbrains.kotlin.idea.versions.getDefaultJvmTarget
|
import org.jetbrains.kotlin.idea.versions.getDefaultJvmTarget
|
||||||
import org.jetbrains.kotlin.idea.versions.getStdlibArtifactId
|
import org.jetbrains.kotlin.idea.versions.getStdlibArtifactId
|
||||||
@@ -76,6 +77,6 @@ class KotlinJavaMavenConfigurator : KotlinMavenConfigurator(
|
|||||||
companion object {
|
companion object {
|
||||||
private const val NAME = "maven"
|
private const val NAME = "maven"
|
||||||
const val TEST_LIB_ID = "kotlin-test"
|
const val TEST_LIB_ID = "kotlin-test"
|
||||||
private const val PRESENTABLE_TEXT = "Java with Maven"
|
private val PRESENTABLE_TEXT = KotlinMavenBundle.message("configure.java.with.maven")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-1
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.maven.configuration
|
|||||||
import com.intellij.openapi.module.Module
|
import com.intellij.openapi.module.Module
|
||||||
import org.jetbrains.idea.maven.dom.model.MavenDomPlugin
|
import org.jetbrains.idea.maven.dom.model.MavenDomPlugin
|
||||||
import org.jetbrains.kotlin.idea.configuration.hasKotlinJsRuntimeInScope
|
import org.jetbrains.kotlin.idea.configuration.hasKotlinJsRuntimeInScope
|
||||||
|
import org.jetbrains.kotlin.idea.maven.KotlinMavenBundle
|
||||||
import org.jetbrains.kotlin.idea.maven.PomFile
|
import org.jetbrains.kotlin.idea.maven.PomFile
|
||||||
import org.jetbrains.kotlin.idea.versions.MAVEN_JS_STDLIB_ID
|
import org.jetbrains.kotlin.idea.versions.MAVEN_JS_STDLIB_ID
|
||||||
import org.jetbrains.kotlin.platform.TargetPlatform
|
import org.jetbrains.kotlin.platform.TargetPlatform
|
||||||
@@ -52,6 +53,6 @@ class KotlinJavascriptMavenConfigurator :
|
|||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
private const val NAME = "js maven"
|
private const val NAME = "js maven"
|
||||||
private const val PRESENTABLE_TEXT = "JavaScript with Maven"
|
private val PRESENTABLE_TEXT = KotlinMavenBundle.message("configure.javascript.with.maven")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+15
-17
@@ -114,7 +114,7 @@ protected constructor(
|
|||||||
configureModule(module, file, dialog.kotlinVersion, collector)
|
configureModule(module, file, dialog.kotlinVersion, collector)
|
||||||
OpenFileAction.openFile(file.virtualFile, project)
|
OpenFileAction.openFile(file.virtualFile, project)
|
||||||
} else {
|
} else {
|
||||||
showErrorMessage(project, "Cannot find pom.xml for module " + module.name)
|
showErrorMessage(project, KotlinMavenBundle.message("error.cant.find.pom.for.module", module.name))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
collector.showNotification()
|
collector.showNotification()
|
||||||
@@ -176,7 +176,7 @@ protected constructor(
|
|||||||
|
|
||||||
CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement<PsiFile>(file)
|
CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement<PsiFile>(file)
|
||||||
|
|
||||||
collector.addMessage(virtualFile.path + " was modified")
|
collector.addMessage(KotlinMavenBundle.message("file.was.modified", virtualFile.path))
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -221,9 +221,8 @@ protected constructor(
|
|||||||
if (runtimeUpdateRequired) {
|
if (runtimeUpdateRequired) {
|
||||||
Messages.showErrorDialog(
|
Messages.showErrorDialog(
|
||||||
module.project,
|
module.project,
|
||||||
"This language feature requires version $requiredStdlibVersion or later of the Kotlin runtime library. " +
|
KotlinMavenBundle.message("update.language.version.feature", requiredStdlibVersion),
|
||||||
"Please update the version in your build script.",
|
KotlinMavenBundle.message("update.language.version.title")
|
||||||
"Update Language Version"
|
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -232,8 +231,8 @@ protected constructor(
|
|||||||
if (element == null) {
|
if (element == null) {
|
||||||
Messages.showErrorDialog(
|
Messages.showErrorDialog(
|
||||||
module.project,
|
module.project,
|
||||||
"Failed to update.pom.xml. Please update the file manually.",
|
KotlinMavenBundle.message("error.failed.update.pom"),
|
||||||
"Update Language Version"
|
KotlinMavenBundle.message("update.language.version.title")
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
OpenFileDescriptor(module.project, element.containingFile.virtualFile, element.textRange.startOffset).navigate(true)
|
OpenFileDescriptor(module.project, element.containingFile.virtualFile, element.textRange.startOffset).navigate(true)
|
||||||
@@ -258,8 +257,7 @@ protected constructor(
|
|||||||
if (runtimeUpdateRequired) {
|
if (runtimeUpdateRequired) {
|
||||||
Messages.showErrorDialog(
|
Messages.showErrorDialog(
|
||||||
module.project,
|
module.project,
|
||||||
"Coroutines support requires version 1.1 or later of the Kotlin runtime library. " +
|
KotlinMavenBundle.message("update.language.version.coroutines"),
|
||||||
"Please update the version in your build script.",
|
|
||||||
messageTitle
|
messageTitle
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@@ -285,8 +283,7 @@ protected constructor(
|
|||||||
if (state != LanguageFeature.State.DISABLED && getRuntimeLibraryVersion(module).toApiVersion() < sinceVersion) {
|
if (state != LanguageFeature.State.DISABLED && getRuntimeLibraryVersion(module).toApiVersion() < sinceVersion) {
|
||||||
Messages.showErrorDialog(
|
Messages.showErrorDialog(
|
||||||
module.project,
|
module.project,
|
||||||
"${feature.presentableName} support requires version $sinceVersion or later of the Kotlin runtime library. " +
|
KotlinMavenBundle.message("update.language.version.feature.support", feature.presentableName, sinceVersion),
|
||||||
"Please update the version in your build script.",
|
|
||||||
messageTitle
|
messageTitle
|
||||||
)
|
)
|
||||||
return
|
return
|
||||||
@@ -317,7 +314,7 @@ protected constructor(
|
|||||||
if (element == null) {
|
if (element == null) {
|
||||||
Messages.showErrorDialog(
|
Messages.showErrorDialog(
|
||||||
module.project,
|
module.project,
|
||||||
"Failed to update.pom.xml. Please update the file manually.",
|
KotlinMavenBundle.message("error.failed.update.pom"),
|
||||||
messageTitle
|
messageTitle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -336,7 +333,7 @@ protected constructor(
|
|||||||
if (element == null) {
|
if (element == null) {
|
||||||
Messages.showErrorDialog(
|
Messages.showErrorDialog(
|
||||||
module.project,
|
module.project,
|
||||||
"Failed to update.pom.xml. Please update the file manually.",
|
KotlinMavenBundle.message("error.failed.update.pom"),
|
||||||
messageTitle
|
messageTitle
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -369,12 +366,13 @@ protected constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun showErrorMessage(project: Project, message: String?) {
|
private fun showErrorMessage(project: Project, message: String?) {
|
||||||
|
val cantConfigureAutomatically = KotlinMavenBundle.message("error.cant.configure.maven.automatically")
|
||||||
|
val seeInstructions = KotlinMavenBundle.message("error.see.installation.instructions")
|
||||||
|
|
||||||
Messages.showErrorDialog(
|
Messages.showErrorDialog(
|
||||||
project,
|
project,
|
||||||
"<html>Couldn't configure kotlin-maven plugin automatically.<br/>" +
|
"<html>$cantConfigureAutomatically<br/>${if (message != null) "$message</br>" else ""}$seeInstructions</html>",
|
||||||
(if (message != null) "$message</br>" else "") +
|
KotlinMavenBundle.message("configure.title")
|
||||||
"See manual installation instructions <a href=\"https://confluence.jetbrains.com/display/Kotlin/Kotlin+Build+Tools#KotlinBuildTools-Maven\">here</a>.</html>",
|
|
||||||
"Configure Kotlin-Maven Plugin"
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-3
@@ -14,6 +14,7 @@ import org.jetbrains.idea.maven.dom.model.MavenDomPlugin
|
|||||||
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel
|
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel
|
||||||
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
||||||
import org.jetbrains.kotlin.idea.inspections.PluginVersionDependentInspection
|
import org.jetbrains.kotlin.idea.inspections.PluginVersionDependentInspection
|
||||||
|
import org.jetbrains.kotlin.idea.maven.KotlinMavenBundle
|
||||||
import org.jetbrains.kotlin.idea.maven.PomFile
|
import org.jetbrains.kotlin.idea.maven.PomFile
|
||||||
import org.jetbrains.kotlin.idea.versions.bundledRuntimeVersion
|
import org.jetbrains.kotlin.idea.versions.bundledRuntimeVersion
|
||||||
|
|
||||||
@@ -43,12 +44,13 @@ class DifferentKotlinMavenVersionInspection : DomElementsInspection<MavenDomProj
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun createProblem(holder: DomElementAnnotationHolder, plugin: MavenDomPlugin) {
|
private fun createProblem(holder: DomElementAnnotationHolder, plugin: MavenDomPlugin) {
|
||||||
|
val versionFromMaven = plugin.version.stringValue
|
||||||
|
val versionFromIde = testVersionMessage ?: idePluginVersion
|
||||||
|
|
||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
plugin.version,
|
plugin.version,
|
||||||
HighlightSeverity.WARNING,
|
HighlightSeverity.WARNING,
|
||||||
"Kotlin version that is used for building with Maven (${plugin.version
|
KotlinMavenBundle.message("version.different.maven.ide", versionFromMaven, versionFromIde)
|
||||||
.stringValue}) differs from the one bundled into the IDE plugin (${testVersionMessage
|
|
||||||
?: idePluginVersion})"
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+8
-5
@@ -18,6 +18,7 @@ import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel
|
|||||||
import org.jetbrains.idea.maven.model.MavenId
|
import org.jetbrains.idea.maven.model.MavenId
|
||||||
import org.jetbrains.idea.maven.project.MavenProject
|
import org.jetbrains.idea.maven.project.MavenProject
|
||||||
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
||||||
|
import org.jetbrains.kotlin.idea.maven.KotlinMavenBundle
|
||||||
import org.jetbrains.kotlin.idea.maven.PomFile
|
import org.jetbrains.kotlin.idea.maven.PomFile
|
||||||
import org.jetbrains.kotlin.idea.maven.configuration.KotlinMavenConfigurator
|
import org.jetbrains.kotlin.idea.maven.configuration.KotlinMavenConfigurator
|
||||||
import org.jetbrains.kotlin.utils.PathUtil
|
import org.jetbrains.kotlin.utils.PathUtil
|
||||||
@@ -50,7 +51,7 @@ class DifferentMavenStdlibVersionInspection : DomElementsInspection<MavenDomProj
|
|||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
plugin.version,
|
plugin.version,
|
||||||
HighlightSeverity.WARNING,
|
HighlightSeverity.WARNING,
|
||||||
"Plugin version (${plugin.version}) is not the same as library version (${stdlibVersion.joinToString(",", "", "")})",
|
KotlinMavenBundle.message("version.different.plugin.library", plugin.version, stdlibVersion.joinToString(",", "", "")),
|
||||||
*fixes.toTypedArray()
|
*fixes.toTypedArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -65,7 +66,7 @@ class DifferentMavenStdlibVersionInspection : DomElementsInspection<MavenDomProj
|
|||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
dependency.version,
|
dependency.version,
|
||||||
HighlightSeverity.WARNING,
|
HighlightSeverity.WARNING,
|
||||||
"Plugin version ($pluginVersion) is not the same as library version (${dependency.version})",
|
KotlinMavenBundle.message("version.different.plugin.library", pluginVersion, dependency.version),
|
||||||
*fixes.toTypedArray()
|
*fixes.toTypedArray()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -85,10 +86,12 @@ class DifferentMavenStdlibVersionInspection : DomElementsInspection<MavenDomProj
|
|||||||
|
|
||||||
private class SetVersionQuickFix(val versionElement: GenericDomValue<*>, val newVersion: String, val versionResolved: String?) :
|
private class SetVersionQuickFix(val versionElement: GenericDomValue<*>, val newVersion: String, val versionResolved: String?) :
|
||||||
LocalQuickFix {
|
LocalQuickFix {
|
||||||
override fun getName() =
|
override fun getName() = when (versionResolved) {
|
||||||
if (versionResolved == null) "Change version to $newVersion" else "Change version to $newVersion ($versionResolved)"
|
null -> KotlinMavenBundle.message("change.version.to", newVersion)
|
||||||
|
else -> KotlinMavenBundle.message("change.version.to.resolved", newVersion, versionResolved)
|
||||||
|
}
|
||||||
|
|
||||||
override fun getFamilyName() = "Change version"
|
override fun getFamilyName() = KotlinMavenBundle.message("change.version")
|
||||||
|
|
||||||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
||||||
versionElement.value = newVersion
|
versionElement.value = newVersion
|
||||||
|
|||||||
+19
-18
@@ -25,6 +25,7 @@ import org.jetbrains.idea.maven.model.MavenId
|
|||||||
import org.jetbrains.idea.maven.model.MavenPlugin
|
import org.jetbrains.idea.maven.model.MavenPlugin
|
||||||
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
||||||
import org.jetbrains.idea.maven.utils.MavenArtifactScope
|
import org.jetbrains.idea.maven.utils.MavenArtifactScope
|
||||||
|
import org.jetbrains.kotlin.idea.maven.KotlinMavenBundle
|
||||||
import org.jetbrains.kotlin.idea.maven.PomFile
|
import org.jetbrains.kotlin.idea.maven.PomFile
|
||||||
import org.jetbrains.kotlin.idea.maven.configuration.KotlinMavenConfigurator
|
import org.jetbrains.kotlin.idea.maven.configuration.KotlinMavenConfigurator
|
||||||
import org.jetbrains.kotlin.idea.platform.tooling
|
import org.jetbrains.kotlin.idea.platform.tooling
|
||||||
@@ -42,7 +43,7 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
private val JS_STDLIB_MAVEN_ID = MavenId(KotlinMavenConfigurator.GROUP_ID, MAVEN_JS_STDLIB_ID, null)
|
private val JS_STDLIB_MAVEN_ID = MavenId(KotlinMavenConfigurator.GROUP_ID, MAVEN_JS_STDLIB_ID, null)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getStaticDescription() = "Reports kotlin-maven-plugin configuration issues"
|
override fun getStaticDescription() = KotlinMavenBundle.message("inspection.description")
|
||||||
|
|
||||||
override fun checkFileElement(domFileElement: DomFileElement<MavenDomProjectModel>?, holder: DomElementAnnotationHolder?) {
|
override fun checkFileElement(domFileElement: DomFileElement<MavenDomProjectModel>?, holder: DomElementAnnotationHolder?) {
|
||||||
if (domFileElement == null || holder == null) {
|
if (domFileElement == null || holder == null) {
|
||||||
@@ -80,7 +81,7 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
kotlinPlugin.artifactId.createStableCopy(),
|
kotlinPlugin.artifactId.createStableCopy(),
|
||||||
HighlightSeverity.WARNING,
|
HighlightSeverity.WARNING,
|
||||||
"Kotlin plugin has no compile executions",
|
KotlinMavenBundle.message("inspection.no.executions"),
|
||||||
*fixes
|
*fixes
|
||||||
)
|
)
|
||||||
} else {
|
} else {
|
||||||
@@ -104,7 +105,7 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
badExecution.phase.createStableCopy(),
|
badExecution.phase.createStableCopy(),
|
||||||
HighlightSeverity.WARNING,
|
HighlightSeverity.WARNING,
|
||||||
"Kotlin plugin should run before javac so kotlin classes could be visible from Java",
|
KotlinMavenBundle.message("inspection.should.run.before.javac"),
|
||||||
FixExecutionPhaseLocalFix(badExecution, PomFile.DefaultPhases.ProcessSources),
|
FixExecutionPhaseLocalFix(badExecution, PomFile.DefaultPhases.ProcessSources),
|
||||||
AddJavaExecutionsLocalFix(module, domFileElement.file, kotlinPlugin)
|
AddJavaExecutionsLocalFix(module, domFileElement.file, kotlinPlugin)
|
||||||
)
|
)
|
||||||
@@ -115,7 +116,7 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
badExecution.goals.goals.first { it.isJsGoal() }.createStableCopy(),
|
badExecution.goals.goals.first { it.isJsGoal() }.createStableCopy(),
|
||||||
HighlightSeverity.WARNING,
|
HighlightSeverity.WARNING,
|
||||||
"JavaScript goal configured for module with Java files"
|
KotlinMavenBundle.message("inspection.javascript.in.java.module")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -126,7 +127,7 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
kotlinPlugin.artifactId.createStableCopy(),
|
kotlinPlugin.artifactId.createStableCopy(),
|
||||||
HighlightSeverity.WARNING,
|
HighlightSeverity.WARNING,
|
||||||
"Kotlin JVM compiler configured but no $MAVEN_STDLIB_ID dependency",
|
KotlinMavenBundle.message("inspection.jvm.no.stdlib.dependency", MAVEN_STDLIB_ID),
|
||||||
FixAddStdlibLocalFix(domFileElement.file, MAVEN_STDLIB_ID, kotlinPlugin.version.rawText)
|
FixAddStdlibLocalFix(domFileElement.file, MAVEN_STDLIB_ID, kotlinPlugin.version.rawText)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -138,7 +139,7 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
kotlinPlugin.artifactId.createStableCopy(),
|
kotlinPlugin.artifactId.createStableCopy(),
|
||||||
HighlightSeverity.WARNING,
|
HighlightSeverity.WARNING,
|
||||||
"Kotlin JavaScript compiler configured but no $MAVEN_JS_STDLIB_ID dependency",
|
KotlinMavenBundle.message("inspection.javascript.no.stdlib.dependency", MAVEN_JS_STDLIB_ID),
|
||||||
FixAddStdlibLocalFix(domFileElement.file, MAVEN_JS_STDLIB_ID, kotlinPlugin.version.rawText)
|
FixAddStdlibLocalFix(domFileElement.file, MAVEN_JS_STDLIB_ID, kotlinPlugin.version.rawText)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -152,7 +153,7 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
dep.artifactId.createStableCopy(),
|
dep.artifactId.createStableCopy(),
|
||||||
HighlightSeverity.WARNING,
|
HighlightSeverity.WARNING,
|
||||||
"You have ${dep.artifactId} configured but no corresponding plugin execution",
|
KotlinMavenBundle.message("inspection.configured.no.execution", dep.artifactId),
|
||||||
ConfigurePluginExecutionLocalFix(module, domFileElement.file, PomFile.KotlinGoals.Compile, dep.version.rawText)
|
ConfigurePluginExecutionLocalFix(module, domFileElement.file, PomFile.KotlinGoals.Compile, dep.version.rawText)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -164,7 +165,7 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
dep.artifactId.createStableCopy(),
|
dep.artifactId.createStableCopy(),
|
||||||
HighlightSeverity.WARNING,
|
HighlightSeverity.WARNING,
|
||||||
"You have ${dep.artifactId} configured but no corresponding plugin execution",
|
KotlinMavenBundle.message("inspection.configured.no.execution", dep.artifactId),
|
||||||
ConfigurePluginExecutionLocalFix(module, domFileElement.file, PomFile.KotlinGoals.Js, dep.version.rawText)
|
ConfigurePluginExecutionLocalFix(module, domFileElement.file, PomFile.KotlinGoals.Js, dep.version.rawText)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -180,7 +181,7 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
badExecution.goals.createStableCopy(),
|
badExecution.goals.createStableCopy(),
|
||||||
HighlightSeverity.WEAK_WARNING,
|
HighlightSeverity.WEAK_WARNING,
|
||||||
"It is not recommended to have both test and compile goals in the same execution"
|
KotlinMavenBundle.message("inspection.same.execution.compile.test")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,9 +194,9 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
) : LocalQuickFix {
|
) : LocalQuickFix {
|
||||||
private val pointer = file.createSmartPointer()
|
private val pointer = file.createSmartPointer()
|
||||||
|
|
||||||
override fun getName() = "Create $goal execution"
|
override fun getName() = KotlinMavenBundle.message("fix.create.execution.name", goal)
|
||||||
|
|
||||||
override fun getFamilyName() = "Create kotlin execution"
|
override fun getFamilyName() = KotlinMavenBundle.message("fix.create.execution.family")
|
||||||
|
|
||||||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
||||||
val file = pointer.element ?: return
|
val file = pointer.element ?: return
|
||||||
@@ -205,9 +206,9 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
}
|
}
|
||||||
|
|
||||||
private class FixExecutionPhaseLocalFix(val execution: MavenDomPluginExecution, val newPhase: String) : LocalQuickFix {
|
private class FixExecutionPhaseLocalFix(val execution: MavenDomPluginExecution, val newPhase: String) : LocalQuickFix {
|
||||||
override fun getName() = "Change phase to $newPhase"
|
override fun getName() = KotlinMavenBundle.message("fix.change.phase.name", newPhase)
|
||||||
|
|
||||||
override fun getFamilyName() = "Change phase"
|
override fun getFamilyName() = KotlinMavenBundle.message("fix.change.phase.family")
|
||||||
|
|
||||||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
||||||
execution.phase.value = newPhase
|
execution.phase.value = newPhase
|
||||||
@@ -217,7 +218,7 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
private class AddJavaExecutionsLocalFix(val module: Module, file: XmlFile, val kotlinPlugin: MavenDomPlugin) : LocalQuickFix {
|
private class AddJavaExecutionsLocalFix(val module: Module, file: XmlFile, val kotlinPlugin: MavenDomPlugin) : LocalQuickFix {
|
||||||
private val pointer = file.createSmartPointer()
|
private val pointer = file.createSmartPointer()
|
||||||
|
|
||||||
override fun getName() = "Configure maven-compiler-plugin executions in the right order"
|
override fun getName() = KotlinMavenBundle.message("fix.configure.right.order")
|
||||||
override fun getFamilyName() = name
|
override fun getFamilyName() = name
|
||||||
|
|
||||||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
||||||
@@ -229,8 +230,8 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
private class FixAddStdlibLocalFix(pomFile: XmlFile, val id: String, val version: String?) : LocalQuickFix {
|
private class FixAddStdlibLocalFix(pomFile: XmlFile, val id: String, val version: String?) : LocalQuickFix {
|
||||||
private val pointer = pomFile.createSmartPointer()
|
private val pointer = pomFile.createSmartPointer()
|
||||||
|
|
||||||
override fun getName() = "Add $id dependency"
|
override fun getName() = KotlinMavenBundle.message("fix.add.dependency.name", id)
|
||||||
override fun getFamilyName() = "Add dependency"
|
override fun getFamilyName() = KotlinMavenBundle.message("fix.add.dependency.family")
|
||||||
|
|
||||||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
||||||
val file = pointer.element ?: return
|
val file = pointer.element ?: return
|
||||||
@@ -246,8 +247,8 @@ class KotlinMavenPluginPhaseInspection : DomElementsInspection<MavenDomProjectMo
|
|||||||
) : LocalQuickFix {
|
) : LocalQuickFix {
|
||||||
private val pointer = xmlFile.createSmartPointer()
|
private val pointer = xmlFile.createSmartPointer()
|
||||||
|
|
||||||
override fun getName() = "Create $goal execution of kotlin-maven-compiler"
|
override fun getName() = KotlinMavenBundle.message("fix.create.execution.compiler.name", goal)
|
||||||
override fun getFamilyName() = "Create kotlin execution"
|
override fun getFamilyName() = KotlinMavenBundle.message("fix.create.execution.compiler.family")
|
||||||
|
|
||||||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
||||||
val file = pointer.element ?: return
|
val file = pointer.element ?: return
|
||||||
|
|||||||
+2
-1
@@ -22,6 +22,7 @@ import org.jetbrains.idea.maven.indices.MavenArtifactSearchDialog
|
|||||||
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
||||||
import org.jetbrains.idea.maven.utils.MavenArtifactScope
|
import org.jetbrains.idea.maven.utils.MavenArtifactScope
|
||||||
import org.jetbrains.kotlin.idea.core.isInTestSourceContentKotlinAware
|
import org.jetbrains.kotlin.idea.core.isInTestSourceContentKotlinAware
|
||||||
|
import org.jetbrains.kotlin.idea.maven.KotlinMavenBundle
|
||||||
import org.jetbrains.kotlin.idea.maven.PomFile
|
import org.jetbrains.kotlin.idea.maven.PomFile
|
||||||
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
import org.jetbrains.kotlin.idea.references.KtSimpleNameReference
|
||||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||||
@@ -71,7 +72,7 @@ class AddMavenDependencyQuickFix(
|
|||||||
private val smartPsiElementPointer: SmartPsiElementPointer<KtSimpleNameExpression>
|
private val smartPsiElementPointer: SmartPsiElementPointer<KtSimpleNameExpression>
|
||||||
) :
|
) :
|
||||||
IntentionAction, LowPriorityAction {
|
IntentionAction, LowPriorityAction {
|
||||||
override fun getText() = "Add Maven dependency..."
|
override fun getText() = KotlinMavenBundle.message("fix.add.maven.dependency.name")
|
||||||
override fun getFamilyName() = text
|
override fun getFamilyName() = text
|
||||||
override fun startInWriteAction() = false
|
override fun startInWriteAction() = false
|
||||||
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?) =
|
override fun isAvailable(project: Project, editor: Editor?, file: PsiFile?) =
|
||||||
|
|||||||
+3
-2
@@ -15,6 +15,7 @@ import com.intellij.util.xml.highlighting.DomElementsInspection
|
|||||||
import org.jetbrains.idea.maven.dom.model.MavenDomDependency
|
import org.jetbrains.idea.maven.dom.model.MavenDomDependency
|
||||||
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel
|
import org.jetbrains.idea.maven.dom.model.MavenDomProjectModel
|
||||||
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
||||||
|
import org.jetbrains.kotlin.idea.maven.KotlinMavenBundle
|
||||||
import org.jetbrains.kotlin.idea.maven.configuration.KotlinJavaMavenConfigurator
|
import org.jetbrains.kotlin.idea.maven.configuration.KotlinJavaMavenConfigurator
|
||||||
import org.jetbrains.kotlin.idea.maven.configuration.KotlinMavenConfigurator
|
import org.jetbrains.kotlin.idea.maven.configuration.KotlinMavenConfigurator
|
||||||
|
|
||||||
@@ -41,14 +42,14 @@ class KotlinTestJUnitInspection : DomElementsInspection<MavenDomProjectModel>(Ma
|
|||||||
holder.createProblem(
|
holder.createProblem(
|
||||||
it.artifactId,
|
it.artifactId,
|
||||||
HighlightSeverity.WEAK_WARNING,
|
HighlightSeverity.WEAK_WARNING,
|
||||||
"kotlin-test-junit is better with junit",
|
KotlinMavenBundle.message("fix.kotlin.test.junit.is.recommended"),
|
||||||
ReplaceToKotlinTest(it)
|
ReplaceToKotlinTest(it)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private class ReplaceToKotlinTest(val dependency: MavenDomDependency) : LocalQuickFix {
|
private class ReplaceToKotlinTest(val dependency: MavenDomDependency) : LocalQuickFix {
|
||||||
override fun getName() = "Replace with kotlin-test-junit"
|
override fun getName() = KotlinMavenBundle.message("fix.kotlin.test.junit.replace")
|
||||||
override fun getFamilyName() = name
|
override fun getFamilyName() = name
|
||||||
|
|
||||||
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
override fun applyFix(project: Project, descriptor: ProblemDescriptor) {
|
||||||
|
|||||||
Reference in New Issue
Block a user