Extracted Kotlin.JVM IDE into separate module

This change is required to have possibility to build plugin against
minor IDEs, which don't have Java. So we want to extract idea-jvm
This commit is contained in:
Alexander Podkhalyuzin
2017-12-21 15:34:44 +03:00
parent 2bb02beb84
commit 8203d1c3fe
195 changed files with 862 additions and 337 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ dependencies {
testRuntime(ideaSdkDeps("*.jar"))
testRuntime(ideaPluginDeps("*.jar", plugin = "junit"))
testRuntime(ideaPluginDeps("resources_en", plugin = "properties"))
testRuntime(ideaPluginDeps("*.jar", plugin = "properties"))
testRuntime(ideaPluginDeps("*.jar", plugin = "gradle"))
testRuntime(ideaPluginDeps("*.jar", plugin = "Groovy"))
testRuntime(ideaPluginDeps("*.jar", plugin = "coverage"))
@@ -19,6 +19,7 @@ package org.jetbrains.kotlin.idea.util
import com.intellij.ide.highlighter.ArchiveFileType
import com.intellij.ide.highlighter.JavaClassFileType
import com.intellij.injected.editor.VirtualFileWindow
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.fileTypes.FileType
import com.intellij.openapi.module.Module
import com.intellij.openapi.module.ModuleUtilCore
@@ -38,9 +39,22 @@ import org.jetbrains.kotlin.idea.core.script.ScriptDependenciesManager
import org.jetbrains.kotlin.idea.decompiler.builtIns.KotlinBuiltInFileType
import org.jetbrains.kotlin.idea.util.application.runReadAction
private val kotlinBinaries = listOf(JavaClassFileType.INSTANCE, KotlinBuiltInFileType, KotlinModuleFileType.INSTANCE)
abstract class KotlinBinaryExtension(val fileType: FileType) {
companion object {
val EP_NAME: ExtensionPointName<KotlinBinaryExtension> =
ExtensionPointName.create<KotlinBinaryExtension>("org.jetbrains.kotlin.binaryExtension")
fun FileType.isKotlinBinary(): Boolean = this in kotlinBinaries
val kotlinBinaries: List<FileType> by lazy(LazyThreadSafetyMode.NONE) {
EP_NAME.extensions.map { it.fileType }
}
}
}
class JavaClassBinary: KotlinBinaryExtension(JavaClassFileType.INSTANCE)
class KotlinBuiltInBinary: KotlinBinaryExtension(KotlinBuiltInFileType)
class KotlinModuleBinary: KotlinBinaryExtension(KotlinModuleFileType.INSTANCE)
fun FileType.isKotlinBinary(): Boolean = this in KotlinBinaryExtension.kotlinBinaries
fun FileIndex.isInSourceContentWithoutInjected(file: VirtualFile): Boolean {
return file !is VirtualFileWindow && isInSourceContent(file)
+1
View File
@@ -8,6 +8,7 @@ dependencies {
compile(project(":compiler:frontend"))
compile(project(":compiler:frontend.java"))
compile(project(":idea"))
compile(project(":idea:idea-jvm"))
compile(project(":idea:idea-core"))
compile(project(":idea:ide-common"))
compile(project(":idea:idea-gradle"))
@@ -20,6 +20,7 @@ import com.intellij.codeInsight.completion.*
import com.intellij.codeInsight.lookup.LookupElement
import com.intellij.codeInsight.lookup.LookupElementDecorator
import com.intellij.openapi.editor.Document
import com.intellij.openapi.extensions.ExtensionPointName
import com.intellij.openapi.util.Key
import com.intellij.patterns.PlatformPatterns
import com.intellij.patterns.PsiJavaPatterns.elementType
@@ -279,7 +280,9 @@ class KotlinCompletionContributor : CompletionContributor() {
return
}
if (PropertyKeyCompletion.perform(parameters, result)) return
for (extension in KotlinCompletionExtension.EP_NAME.getExtensions()) {
if (extension.perform(parameters, result)) return
}
fun addPostProcessor(session: CompletionSession) {
if (lookupElementPostProcessor != null) {
@@ -467,3 +470,12 @@ class KotlinCompletionContributor : CompletionContributor() {
return tokenBefore?.parents?.firstIsInstanceOrNull<KtStringTemplateExpression>()?.isPlain() ?: false
}
}
abstract class KotlinCompletionExtension {
abstract fun perform(parameters: CompletionParameters, result: CompletionResultSet): Boolean
companion object {
val EP_NAME: ExtensionPointName<KotlinCompletionExtension> =
ExtensionPointName.create<KotlinCompletionExtension>("org.jetbrains.kotlin.completionExtension")
}
}
@@ -27,10 +27,7 @@ import org.jetbrains.kotlin.idea.configuration.*
import org.jetbrains.kotlin.idea.configuration.KotlinBuildScriptManipulator.Companion.GSK_KOTLIN_VERSION_PROPERTY_NAME
import org.jetbrains.kotlin.idea.configuration.KotlinBuildScriptManipulator.Companion.getCompileDependencySnippet
import org.jetbrains.kotlin.idea.configuration.KotlinBuildScriptManipulator.Companion.getKotlinGradlePluginClassPathSnippet
import org.jetbrains.kotlin.idea.versions.MAVEN_JS_STDLIB_ID
import org.jetbrains.kotlin.idea.versions.bundledRuntimeVersion
import org.jetbrains.kotlin.idea.versions.getDefaultJvmTarget
import org.jetbrains.kotlin.idea.versions.getStdlibArtifactId
import org.jetbrains.kotlin.idea.versions.*
import javax.swing.Icon
abstract class GradleKotlinDSLKotlinFrameworkSupportProvider(
+3 -1
View File
@@ -6,7 +6,7 @@ dependencies {
compile(project(":compiler:light-classes"))
compile(project(":compiler:frontend.java"))
compileOnly(ideaSdkDeps("openapi", "idea"))
compileOnly(ideaSdkDeps("openapi", "idea", "velocity", "boot", "gson", "swingx-core", "jsr305", "forms_rt"))
compile(ideaPluginDeps("idea-junit", plugin = "junit"))
compile(ideaPluginDeps("testng", "testng-plugin", plugin = "testng"))
@@ -20,3 +20,5 @@ sourceSets {
"main" { projectDefault() }
"test" { none() }
}
configureInstrumentation()
@@ -0,0 +1,46 @@
/*
* 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.
*/
package org.jetbrains.kotlin.idea;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.components.ApplicationComponent;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.debugger.filter.DebuggerFiltersUtilKt;
public class JvmPluginStartupComponent implements ApplicationComponent {
public static JvmPluginStartupComponent getInstance() {
return ApplicationManager.getApplication().getComponent(JvmPluginStartupComponent.class);
}
@Override
@NotNull
public String getComponentName() {
return JvmPluginStartupComponent.class.getName();
}
@Override
public void initComponent() {
if (ApplicationManager.getApplication().isUnitTestMode()) {
ThreadTrackerPatcherForTeamCityTesting.INSTANCE.patchThreadTracker();
}
DebuggerFiltersUtilKt.addKotlinStdlibDebugFilterIfNeeded();
}
@Override
public void disposeComponent() {}
}
@@ -0,0 +1,26 @@
/*
* 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.
*/
package org.jetbrains.kotlin.idea.compiler.configuration
import com.intellij.compiler.server.BuildManager
import com.intellij.openapi.project.Project
class ClearBuildManagerState : ClearBuildStateExtension() {
override fun clearState(project: Project) {
BuildManager.getInstance().clearState(project);
}
}
@@ -47,6 +47,7 @@ import org.jetbrains.kotlin.idea.util.projectStructure.version
import org.jetbrains.kotlin.idea.versions.SuppressNotificationState
import org.jetbrains.kotlin.idea.versions.getKotlinJvmRuntimeMarkerClass
import org.jetbrains.kotlin.idea.versions.hasKotlinJsKjsmFile
import org.jetbrains.kotlin.idea.versions.isSnapshot
import org.jetbrains.kotlin.idea.vfilefinder.IDEVirtualFileFinder
import org.jetbrains.kotlin.resolve.jvm.modules.KOTLIN_STDLIB_MODULE_NAME
import org.jetbrains.kotlin.utils.ifEmpty
@@ -257,10 +258,6 @@ fun hasKotlinFilesInSources(module: Module): Boolean {
return FileTypeIndex.containsFileOfType(KotlinFileType.INSTANCE, module.getModuleScope(false))
}
fun isSnapshot(version: String): Boolean {
return version.contains("SNAPSHOT", ignoreCase = true)
}
fun isEap(version: String): Boolean {
return version.contains("rc") || version.contains("eap")
}
@@ -41,7 +41,7 @@ import org.jetbrains.kotlin.idea.versions.isKotlinJavaRuntime
import org.jetbrains.kotlin.resolve.TargetPlatform
import org.jetbrains.kotlin.resolve.jvm.platform.JvmPlatform
open class KotlinJavaModuleConfigurator internal constructor() : KotlinWithLibraryConfigurator() {
open class KotlinJavaModuleConfigurator protected constructor() : KotlinWithLibraryConfigurator() {
override fun isApplicable(module: Module): Boolean {
return super.isApplicable(module) && !hasBrokenJsRuntime(module)
}
@@ -0,0 +1,27 @@
/*
* 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.
*/
package org.jetbrains.kotlin.idea.configuration
import com.intellij.openapi.module.Module
import org.jetbrains.kotlin.idea.actions.NewKotlinFileHook
import org.jetbrains.kotlin.psi.KtFile
class NewKotlinFileConfigurationHook : NewKotlinFileHook() {
override fun postProcess(createdElement: KtFile, module: Module) {
showConfigureKotlinNotificationIfNeeded(module)
}
}
@@ -0,0 +1,34 @@
/*
* 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.
*/
package org.jetbrains.kotlin.idea.debugger.surroundWith;
import com.intellij.lang.surroundWith.Surrounder;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.kotlin.idea.codeInsight.surroundWith.expression.KotlinExpressionSurroundDescriptor;
public class KotlinDebuggerExpressionSurroundDescriptor extends KotlinExpressionSurroundDescriptor {
private static final Surrounder[] SURROUNDERS = {
new KotlinRuntimeTypeCastSurrounder()
};
@Override
@NotNull
public Surrounder[] getSurrounders() {
return SURROUNDERS;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* 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.
@@ -14,7 +14,7 @@
* limitations under the License.
*/
package org.jetbrains.kotlin.idea.codeInsight.surroundWith.expression
package org.jetbrains.kotlin.idea.debugger.surroundWith
import com.intellij.codeInsight.CodeInsightBundle
import com.intellij.debugger.DebuggerBundle
@@ -31,8 +31,9 @@ import com.intellij.openapi.project.Project
import com.intellij.openapi.util.TextRange
import org.jetbrains.kotlin.idea.KotlinBundle
import org.jetbrains.kotlin.idea.caches.resolve.analyze
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.idea.codeInsight.surroundWith.expression.KotlinExpressionSurrounder
import org.jetbrains.kotlin.idea.debugger.evaluate.KotlinRuntimeTypeEvaluator
import org.jetbrains.kotlin.idea.core.ShortenReferences
import org.jetbrains.kotlin.psi.*
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.lazy.BodyResolveMode

Some files were not shown because too many files have changed in this diff Show More