Extension point for detecting build system type used in project
Now we use a non-deprecated way to detect Maven modules
This commit is contained in:
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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;
|
||||
@@ -20,9 +9,7 @@ import com.intellij.ide.plugins.IdeaPluginDescriptor;
|
||||
import com.intellij.ide.plugins.PluginManager;
|
||||
import com.intellij.ide.plugins.PluginManagerCore;
|
||||
import com.intellij.openapi.extensions.PluginId;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinModuleTypeManager;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@@ -40,18 +27,4 @@ public class KotlinPluginUtil {
|
||||
public static boolean isSnapshotVersion() {
|
||||
return "@snapshot@".equals(getPluginVersion());
|
||||
}
|
||||
|
||||
public static boolean isAndroidGradleModule(@NotNull Module module) {
|
||||
return KotlinModuleTypeManager.getInstance().isAndroidGradleModule(module);
|
||||
}
|
||||
|
||||
public static boolean isGradleModule(@NotNull Module module) {
|
||||
return KotlinModuleTypeManager.getInstance().isGradleModule(module);
|
||||
}
|
||||
|
||||
public static boolean isMavenModule(@NotNull Module module) {
|
||||
// This constant could be acquired from MavenProjectsManager, but we don't want to depend on the Maven plugin...
|
||||
// See MavenProjectsManager.isMavenizedModule()
|
||||
return "true".equals(module.getOptionValue("org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
|
||||
* that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
@@ -25,7 +25,8 @@ import org.jetbrains.kotlin.analyzer.ModuleInfo
|
||||
import org.jetbrains.kotlin.analyzer.TrackableModuleInfo
|
||||
import org.jetbrains.kotlin.caches.resolve.LibraryModuleInfo
|
||||
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
|
||||
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
|
||||
import org.jetbrains.kotlin.idea.framework.getLibraryPlatform
|
||||
import org.jetbrains.kotlin.idea.project.KotlinModuleModificationTracker
|
||||
import org.jetbrains.kotlin.idea.project.TargetPlatformDetector
|
||||
@@ -97,7 +98,7 @@ private fun ideaModelDependencies(module: Module, forProduction: Boolean): List<
|
||||
//NOTE: lib dependencies can be processed several times during recursive traversal
|
||||
val result = LinkedHashSet<IdeaModuleInfo>()
|
||||
val dependencyEnumerator = ModuleRootManager.getInstance(module).orderEntries().compileOnly().recursively().exportedOnly()
|
||||
if (forProduction && !(KotlinPluginUtil.isMavenModule(module) || KotlinPluginUtil.isGradleModule(module))) {
|
||||
if (forProduction && module.getBuildSystemType() == BuildSystemType.JPS) {
|
||||
dependencyEnumerator.productionOnly()
|
||||
}
|
||||
dependencyEnumerator.forEach { orderEntry ->
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.configuration
|
||||
|
||||
import com.intellij.openapi.extensions.ExtensionPointName
|
||||
import com.intellij.openapi.extensions.Extensions
|
||||
import com.intellij.openapi.module.Module
|
||||
|
||||
abstract class BuildSystemType {
|
||||
object JPS : BuildSystemType()
|
||||
}
|
||||
|
||||
interface BuildSystemTypeDetector {
|
||||
fun detectBuildSystemType(module: Module): BuildSystemType?
|
||||
|
||||
companion object {
|
||||
val EP_NAME = ExtensionPointName.create<BuildSystemTypeDetector>("org.jetbrains.kotlin.buildSystemTypeDetector")
|
||||
}
|
||||
}
|
||||
|
||||
fun Module.getBuildSystemType(): BuildSystemType {
|
||||
for (extension in Extensions.getExtensions(BuildSystemTypeDetector.EP_NAME)) {
|
||||
val result = extension.detectBuildSystemType(this)
|
||||
if (result != null) {
|
||||
return result
|
||||
}
|
||||
}
|
||||
return BuildSystemType.JPS
|
||||
}
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.configuration;
|
||||
|
||||
import com.intellij.openapi.components.ServiceManager;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
public abstract class KotlinModuleTypeManager {
|
||||
public static KotlinModuleTypeManager getInstance() {
|
||||
return ServiceManager.getService(KotlinModuleTypeManager.class);
|
||||
}
|
||||
|
||||
public abstract boolean isAndroidGradleModule(@NotNull Module module);
|
||||
public abstract boolean isGradleModule(@NotNull Module module);
|
||||
}
|
||||
+5
-17
@@ -1,33 +1,21 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.android.configure
|
||||
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.module.ModuleUtil
|
||||
import com.intellij.openapi.projectRoots.JavaSdk
|
||||
import com.intellij.openapi.projectRoots.JavaSdkVersion
|
||||
import com.intellij.openapi.projectRoots.Sdk
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.configuration.AndroidGradle
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinWithGradleConfigurator
|
||||
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.version
|
||||
import org.jetbrains.kotlin.idea.versions.MAVEN_STDLIB_ID_JDK7
|
||||
import org.jetbrains.kotlin.idea.versions.MAVEN_STDLIB_ID_JRE7
|
||||
import org.jetbrains.kotlin.idea.versions.hasJreSpecificRuntime
|
||||
import org.jetbrains.kotlin.resolve.TargetPlatform
|
||||
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
|
||||
@@ -40,7 +28,7 @@ class KotlinAndroidGradleModuleConfigurator internal constructor() : KotlinWithG
|
||||
|
||||
override val presentableText: String = "Android with Gradle"
|
||||
|
||||
public override fun isApplicable(module: Module): Boolean = KotlinPluginUtil.isAndroidGradleModule(module)
|
||||
public override fun isApplicable(module: Module): Boolean = module.getBuildSystemType() == AndroidGradle
|
||||
|
||||
override val kotlinPluginName: String = KOTLIN_ANDROID
|
||||
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.configuration
|
||||
|
||||
import com.intellij.facet.FacetManager
|
||||
import com.intellij.openapi.module.Module
|
||||
import org.jetbrains.kotlin.idea.framework.isGradleModule
|
||||
|
||||
object Gradle : BuildSystemType()
|
||||
object AndroidGradle : BuildSystemType()
|
||||
|
||||
class GradleDetector : BuildSystemTypeDetector {
|
||||
override fun detectBuildSystemType(module: Module): BuildSystemType? {
|
||||
if (module.isGradleModule()) {
|
||||
if (FacetManager.getInstance(module).allFacets.any { it.name == "Android" }) {
|
||||
return AndroidGradle
|
||||
}
|
||||
return Gradle
|
||||
}
|
||||
return null
|
||||
}
|
||||
}
|
||||
+4
-15
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.configuration
|
||||
@@ -90,7 +79,7 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
||||
}
|
||||
|
||||
protected open fun isApplicable(module: Module): Boolean =
|
||||
KotlinPluginUtil.isGradleModule(module) && !KotlinPluginUtil.isAndroidGradleModule(module)
|
||||
module.getBuildSystemType() == Gradle
|
||||
|
||||
protected open fun getMinimumSupportedVersion() = "1.0.0"
|
||||
|
||||
@@ -277,7 +266,7 @@ abstract class KotlinWithGradleConfigurator : KotlinProjectConfigurator {
|
||||
}
|
||||
|
||||
getManipulator(buildScript)
|
||||
.addKotlinLibraryToModuleBuildScript(scope, libraryDescriptor, KotlinPluginUtil.isAndroidGradleModule(module))
|
||||
.addKotlinLibraryToModuleBuildScript(scope, libraryDescriptor, module.getBuildSystemType() == AndroidGradle)
|
||||
|
||||
buildScript.virtualFile?.let {
|
||||
createConfigureKotlinNotificationCollector(buildScript.project)
|
||||
|
||||
+4
-15
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.inspections.gradle
|
||||
@@ -28,9 +17,9 @@ import com.intellij.openapi.module.ModuleUtilCore
|
||||
import com.intellij.openapi.roots.ProjectRootManager
|
||||
import com.intellij.openapi.util.io.FileUtilRt
|
||||
import com.intellij.psi.PsiFile
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinWithGradleConfigurator
|
||||
import org.jetbrains.kotlin.idea.framework.GRADLE_SYSTEM_ID
|
||||
import org.jetbrains.kotlin.idea.framework.isGradleModule
|
||||
import org.jetbrains.plugins.gradle.model.data.BuildScriptClasspathData
|
||||
import org.jetbrains.plugins.gradle.util.GradleConstants
|
||||
import org.jetbrains.plugins.groovy.codeInspection.BaseInspectionVisitor
|
||||
@@ -46,7 +35,7 @@ abstract class KotlinGradleInspectionVisitor : BaseInspectionVisitor() {
|
||||
|
||||
if (!ApplicationManager.getApplication().isUnitTestMode) {
|
||||
val module = fileIndex.getModuleForFile(file.virtualFile) ?: return
|
||||
if (!KotlinPluginUtil.isGradleModule(module)) return
|
||||
if (!module.isGradleModule()) return
|
||||
}
|
||||
|
||||
if (fileIndex.isExcluded(file.virtualFile)) return
|
||||
|
||||
+3
-15
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.actions
|
||||
@@ -21,7 +10,6 @@ import com.intellij.openapi.actionSystem.AnActionEvent
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.ui.Messages
|
||||
import com.intellij.util.PlatformUtils
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.configuration.*
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
||||
import org.jetbrains.kotlin.js.resolve.JsPlatform
|
||||
@@ -61,7 +49,7 @@ class ConfigureKotlinJsInProjectAction: ConfigureKotlinInProjectAction() {
|
||||
|
||||
override fun update(e: AnActionEvent) {
|
||||
val project = e.project
|
||||
if (!PlatformUtils.isIntelliJ() && (project == null || project.allModules().all(KotlinPluginUtil::isAndroidGradleModule))) {
|
||||
if (!PlatformUtils.isIntelliJ() && (project == null || project.allModules().all { it.getBuildSystemType() != BuildSystemType.JPS })) {
|
||||
e.presentation.isEnabledAndVisible = false
|
||||
}
|
||||
}
|
||||
|
||||
+3
-16
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.configuration
|
||||
@@ -343,9 +332,7 @@ abstract class KotlinWithLibraryConfigurator internal constructor() : KotlinProj
|
||||
protected open fun findAndFixBrokenKotlinLibrary(module: Module, collector: NotificationMessageCollector): Library? = null
|
||||
|
||||
protected open fun isApplicable(module: Module): Boolean {
|
||||
return !KotlinPluginUtil.isAndroidGradleModule(module) &&
|
||||
!KotlinPluginUtil.isMavenModule(module) &&
|
||||
!KotlinPluginUtil.isGradleModule(module)
|
||||
return module.getBuildSystemType() == BuildSystemType.JPS
|
||||
}
|
||||
|
||||
override fun changeCoroutineConfiguration(module: Module, state: LanguageFeature.State) {
|
||||
|
||||
+5
-17
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.framework
|
||||
@@ -27,7 +16,8 @@ import com.intellij.openapi.roots.ModifiableModelsProvider
|
||||
import com.intellij.openapi.roots.ModifiableRootModel
|
||||
import com.intellij.openapi.roots.ui.configuration.FacetsProvider
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
|
||||
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
|
||||
import javax.swing.JComponent
|
||||
|
||||
class JSFrameworkSupportProvider : FrameworkSupportInModuleProvider() {
|
||||
@@ -72,8 +62,6 @@ class JSFrameworkSupportProvider : FrameworkSupportInModuleProvider() {
|
||||
override fun isEnabledForModuleType(moduleType: ModuleType<*>): Boolean = moduleType is JavaModuleType
|
||||
|
||||
override fun canAddSupport(module: Module, facetsProvider: FacetsProvider): Boolean {
|
||||
return super.canAddSupport(module, facetsProvider) &&
|
||||
!KotlinPluginUtil.isMavenModule(module) &&
|
||||
!KotlinPluginUtil.isGradleModule(module)
|
||||
return super.canAddSupport(module, facetsProvider) && module.getBuildSystemType() == BuildSystemType.JPS
|
||||
}
|
||||
}
|
||||
|
||||
+5
-17
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.framework
|
||||
@@ -27,7 +16,8 @@ import com.intellij.openapi.roots.ModifiableModelsProvider
|
||||
import com.intellij.openapi.roots.ModifiableRootModel
|
||||
import com.intellij.openapi.roots.ui.configuration.FacetsProvider
|
||||
import com.intellij.openapi.roots.ui.configuration.libraries.CustomLibraryDescription
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
|
||||
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
|
||||
import javax.swing.JComponent
|
||||
|
||||
internal class JavaFrameworkSupportProvider : FrameworkSupportInModuleProvider() {
|
||||
@@ -72,8 +62,6 @@ internal class JavaFrameworkSupportProvider : FrameworkSupportInModuleProvider()
|
||||
override fun isEnabledForModuleType(moduleType: ModuleType<*>): Boolean = moduleType is JavaModuleType
|
||||
|
||||
override fun canAddSupport(module: Module, facetsProvider: FacetsProvider): Boolean {
|
||||
return super.canAddSupport(module, facetsProvider) &&
|
||||
!KotlinPluginUtil.isMavenModule(module) &&
|
||||
!KotlinPluginUtil.isGradleModule(module)
|
||||
return super.canAddSupport(module, facetsProvider) && module.getBuildSystemType() == BuildSystemType.JPS
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.quickfix
|
||||
@@ -26,9 +15,10 @@ import org.jetbrains.kotlin.cli.common.arguments.CommonCompilerArguments
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
|
||||
import org.jetbrains.kotlin.idea.configuration.findApplicableConfigurator
|
||||
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
|
||||
@@ -100,7 +90,7 @@ sealed class ChangeCoroutineSupportFix(
|
||||
val facetSettings = KotlinFacet.get(module)?.configuration?.settings
|
||||
|
||||
val configureInProject = (facetSettings == null || facetSettings.useProjectSettings) &&
|
||||
!KotlinPluginUtil.isGradleModule(module) && !KotlinPluginUtil.isMavenModule(module)
|
||||
module.getBuildSystemType() == BuildSystemType.JPS
|
||||
val quickFixConstructor: (PsiElement, LanguageFeature.State) -> ChangeCoroutineSupportFix =
|
||||
if (configureInProject) ::InProject else ::InModule
|
||||
return newCoroutineSupports.map { quickFixConstructor(diagnostic.psiElement, it) }
|
||||
|
||||
+5
-15
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.quickfix
|
||||
@@ -31,10 +20,11 @@ import org.jetbrains.kotlin.config.KotlinFacetSettingsProvider
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.diagnostics.Diagnostic
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.actions.internal.KotlinInternalMode
|
||||
import org.jetbrains.kotlin.idea.compiler.configuration.KotlinCommonCompilerArgumentsHolder
|
||||
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
|
||||
import org.jetbrains.kotlin.idea.configuration.findApplicableConfigurator
|
||||
import org.jetbrains.kotlin.idea.configuration.getBuildSystemType
|
||||
import org.jetbrains.kotlin.idea.facet.KotlinFacet
|
||||
import org.jetbrains.kotlin.idea.facet.getRuntimeLibraryVersion
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
||||
@@ -118,7 +108,7 @@ sealed class EnableUnsupportedFeatureFix(
|
||||
}
|
||||
|
||||
val module = ModuleUtilCore.findModuleForPsiElement(diagnostic.psiElement) ?: return null
|
||||
if (!KotlinPluginUtil.isGradleModule(module) && !KotlinPluginUtil.isMavenModule(module)) {
|
||||
if (module.getBuildSystemType() == BuildSystemType.JPS) {
|
||||
val facetSettings = KotlinFacet.get(module)?.configuration?.settings
|
||||
if (facetSettings == null || facetSettings.useProjectSettings) return InProject(diagnostic.psiElement, feature, apiVersionOnly)
|
||||
}
|
||||
|
||||
+10
-29
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.versions
|
||||
@@ -24,11 +13,7 @@ import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.openapi.vfs.JarFileSystem
|
||||
import com.intellij.openapi.vfs.LocalFileSystem
|
||||
import com.intellij.openapi.vfs.VirtualFile
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinJavaModuleConfigurator
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinJsModuleConfigurator
|
||||
import org.jetbrains.kotlin.idea.configuration.createConfigureKotlinNotificationCollector
|
||||
import org.jetbrains.kotlin.idea.configuration.getConfiguratorByName
|
||||
import org.jetbrains.kotlin.idea.configuration.*
|
||||
import org.jetbrains.kotlin.idea.framework.JavaRuntimeDetectionUtil
|
||||
import org.jetbrains.kotlin.idea.util.application.runWriteAction
|
||||
import org.jetbrains.kotlin.idea.util.projectStructure.allModules
|
||||
@@ -36,17 +21,13 @@ import java.io.File
|
||||
import java.io.IOException
|
||||
|
||||
fun updateLibraries(project: Project, libraries: Collection<Library>) {
|
||||
if (project.allModules().any { module -> KotlinPluginUtil.isMavenModule(module) }) {
|
||||
Messages.showMessageDialog(project, "Automatic library version update for Maven projects is currently unsupported. Please update your pom.xml manually.",
|
||||
"Update Kotlin Runtime Library",
|
||||
Messages.getErrorIcon())
|
||||
return
|
||||
}
|
||||
|
||||
if (project.allModules().any { module -> KotlinPluginUtil.isGradleModule(module) }) {
|
||||
Messages.showMessageDialog(project, "Automatic library version update for Gradle projects is currently unsupported. Please update your build.gradle manually.",
|
||||
"Update Kotlin Runtime Library",
|
||||
Messages.getErrorIcon())
|
||||
if (project.allModules().any { module -> module.getBuildSystemType() != BuildSystemType.JPS }) {
|
||||
Messages.showMessageDialog(
|
||||
project,
|
||||
"Automatic library version update for Maven and Gradle projects is currently unsupported. " +
|
||||
"Please update your build scripts manually.",
|
||||
"Update Kotlin Runtime Library",
|
||||
Messages.getErrorIcon())
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,22 @@
|
||||
/*
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.openapi.module.Module
|
||||
import org.jetbrains.idea.maven.project.MavenProjectsManager
|
||||
import org.jetbrains.kotlin.idea.configuration.BuildSystemType
|
||||
import org.jetbrains.kotlin.idea.configuration.BuildSystemTypeDetector
|
||||
|
||||
object Maven : BuildSystemType()
|
||||
|
||||
class MavenDetector : BuildSystemTypeDetector {
|
||||
override fun detectBuildSystemType(module: Module): BuildSystemType? {
|
||||
return if (MavenProjectsManager.getInstance(module.project).isMavenizedModule(module))
|
||||
Maven
|
||||
else
|
||||
null
|
||||
}
|
||||
}
|
||||
+3
-15
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.configuration
|
||||
@@ -43,7 +32,6 @@ import org.jetbrains.idea.maven.utils.MavenArtifactScope
|
||||
import org.jetbrains.kotlin.config.ApiVersion
|
||||
import org.jetbrains.kotlin.config.CoroutineSupport
|
||||
import org.jetbrains.kotlin.config.LanguageFeature
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.configuration.*
|
||||
import org.jetbrains.kotlin.idea.facet.getRuntimeLibraryVersion
|
||||
import org.jetbrains.kotlin.idea.framework.ui.ConfigureDialogWithModulesAndVersion
|
||||
@@ -60,7 +48,7 @@ abstract class KotlinMavenConfigurator
|
||||
|
||||
override fun getStatus(moduleSourceRootGroup: ModuleSourceRootGroup): ConfigureKotlinStatus {
|
||||
val module = moduleSourceRootGroup.baseModule
|
||||
if (!KotlinPluginUtil.isMavenModule(module))
|
||||
if (module.getBuildSystemType() != Maven)
|
||||
return ConfigureKotlinStatus.NON_APPLICABLE
|
||||
|
||||
val psi = runReadAction { findModulePomFile(module) }
|
||||
|
||||
@@ -26,6 +26,8 @@
|
||||
interface="org.jetbrains.kotlin.idea.actions.NewKotlinFileHook"/>
|
||||
<extensionPoint qualifiedName="org.jetbrains.kotlin.completionExtension"
|
||||
interface="org.jetbrains.kotlin.idea.completion.KotlinCompletionExtension"/>
|
||||
<extensionPoint qualifiedName="org.jetbrains.kotlin.buildSystemTypeDetector"
|
||||
interface="org.jetbrains.kotlin.idea.configuration.BuildSystemTypeDetector"/>
|
||||
</extensionPoints>
|
||||
|
||||
<extensions defaultExtensionNs="org.jetbrains.kotlin">
|
||||
|
||||
@@ -78,5 +78,6 @@
|
||||
<gradleFrameworkSupport implementation="org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.GradleKotlinDSLKotlinJavaFrameworkSupportProvider" />
|
||||
<gradleFrameworkSupport implementation="org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.GradleKotlinDSLKotlinJSFrameworkSupportProvider" />
|
||||
<gradleFrameworkSupport implementation="org.jetbrains.kotlin.gradle.kdsl.frameworkSupport.GradleGroovyFrameworkSupportProvider" />
|
||||
<buildSystemTypeDetector implementation="org.jetbrains.kotlin.idea.configuration.GradleDetector"/>
|
||||
</extensions>
|
||||
</idea-plugin>
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
<mavenProjectImportHandler implementation="org.jetbrains.kotlin.allopen.ide.AllOpenMavenProjectImportHandler"/>
|
||||
<mavenProjectImportHandler implementation="org.jetbrains.kotlin.noarg.ide.NoArgMavenProjectImportHandler"/>
|
||||
<mavenProjectImportHandler implementation="org.jetbrains.kotlin.samWithReceiver.ide.SamWithReceiverMavenProjectImportHandler"/>
|
||||
<buildSystemTypeDetector implementation="org.jetbrains.kotlin.idea.maven.MavenDetector"/>
|
||||
</extensions>
|
||||
|
||||
<extensions defaultExtensionNs="org.jetbrains.idea.maven">
|
||||
|
||||
@@ -211,9 +211,6 @@
|
||||
<applicationService serviceInterface="org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache"
|
||||
serviceImplementation="org.jetbrains.kotlin.load.kotlin.KotlinBinaryClassCache"/>
|
||||
|
||||
<applicationService serviceInterface="org.jetbrains.kotlin.idea.configuration.KotlinModuleTypeManager"
|
||||
serviceImplementation="org.jetbrains.kotlin.idea.KotlinModuleTypeManagerImpl"/>
|
||||
|
||||
<applicationService serviceInterface="org.jetbrains.kotlin.idea.quickfix.QuickFixes"
|
||||
serviceImplementation="org.jetbrains.kotlin.idea.quickfix.QuickFixes"/>
|
||||
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright 2010-2015 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea;
|
||||
|
||||
import com.intellij.facet.Facet;
|
||||
import com.intellij.facet.FacetManager;
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil;
|
||||
import com.intellij.openapi.module.Module;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.idea.configuration.KotlinModuleTypeManager;
|
||||
import org.jetbrains.kotlin.idea.framework.KotlinLibraryUtilKt;
|
||||
|
||||
public class KotlinModuleTypeManagerImpl extends KotlinModuleTypeManager {
|
||||
@Override
|
||||
public boolean isAndroidGradleModule(@NotNull Module module) {
|
||||
return hasAndroidFacet(module) && isGradleModule(module);
|
||||
}
|
||||
|
||||
private static boolean hasAndroidFacet(@NotNull Module module) {
|
||||
for (Facet facet : FacetManager.getInstance(module).getAllFacets()) {
|
||||
if (facet.getName().equals("Android")) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGradleModule(@NotNull Module module) {
|
||||
return ExternalSystemApiUtil.isExternalSystemAwareModule(KotlinLibraryUtilKt.getGRADLE_SYSTEM_ID(), module);
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,13 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.framework
|
||||
|
||||
import com.intellij.openapi.externalSystem.model.ProjectSystemId
|
||||
import com.intellij.openapi.externalSystem.util.ExternalSystemApiUtil
|
||||
import com.intellij.openapi.module.Module
|
||||
import com.intellij.openapi.roots.libraries.Library
|
||||
|
||||
private val MAVEN_SYSTEM_ID = ProjectSystemId("MAVEN")
|
||||
@@ -29,3 +19,6 @@ fun isExternalLibrary(library: Library): Boolean {
|
||||
ExternalSystemApiUtil.isExternalSystemLibrary(library, MAVEN_SYSTEM_ID)
|
||||
}
|
||||
|
||||
|
||||
fun Module.isGradleModule() =
|
||||
ExternalSystemApiUtil.isExternalSystemAwareModule(GRADLE_SYSTEM_ID, this)
|
||||
|
||||
@@ -1,17 +1,6 @@
|
||||
/*
|
||||
* Copyright 2010-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* Copyright 2000-2018 JetBrains s.r.o. 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.nodejs
|
||||
@@ -24,7 +13,7 @@ import com.intellij.openapi.roots.CompilerModuleExtension
|
||||
import com.intellij.openapi.roots.ModuleRootManager
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.util.PathUtil
|
||||
import org.jetbrains.kotlin.idea.KotlinPluginUtil
|
||||
import org.jetbrains.kotlin.idea.framework.isGradleModule
|
||||
import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.plugins.gradle.model.ExternalProject
|
||||
import org.jetbrains.plugins.gradle.service.project.data.ExternalProjectDataCache
|
||||
@@ -57,7 +46,7 @@ private fun ExternalProject.findProjectById(id: String): ExternalProject? {
|
||||
}
|
||||
|
||||
private fun getNodeJsClasspath(module: Module): List<String> {
|
||||
if (KotlinPluginUtil.isGradleModule(module)) {
|
||||
if (module.isGradleModule()) {
|
||||
val gradleProjectPath = ExternalSystemModulePropertyManager.getInstance(module).getRootProjectPath()
|
||||
val projectCache = ExternalProjectDataCache.getInstance(module.project)
|
||||
val rootProject = projectCache.getRootExternalProject(GradleConstants.SYSTEM_ID, File(gradleProjectPath)) ?: return listOf()
|
||||
|
||||
Reference in New Issue
Block a user