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:
Generated
-1
@@ -228,7 +228,6 @@
|
||||
<option name="WHILE_BRACE_FORCE" value="1" />
|
||||
<option name="FOR_BRACE_FORCE" value="1" />
|
||||
<option name="FIELD_ANNOTATION_WRAP" value="0" />
|
||||
<option name="PARENT_SETTINGS_INSTALLED" value="true" />
|
||||
</codeStyleSettings>
|
||||
<codeStyleSettings language="TypeScript">
|
||||
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||
|
||||
@@ -1,13 +1,17 @@
|
||||
@file:Suppress("unused") // usages in build scripts are not tracked properly
|
||||
|
||||
import groovy.lang.Closure
|
||||
import org.gradle.api.*
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.kotlin.dsl.*
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.Task
|
||||
import org.gradle.api.file.SourceDirectorySet
|
||||
import org.gradle.api.internal.AbstractTask
|
||||
import org.gradle.jvm.tasks.Jar
|
||||
import org.gradle.api.plugins.JavaPluginConvention
|
||||
import org.gradle.api.tasks.JavaExec
|
||||
import org.gradle.api.tasks.SourceSetOutput
|
||||
import org.gradle.kotlin.dsl.creating
|
||||
import org.gradle.kotlin.dsl.extra
|
||||
import org.gradle.kotlin.dsl.get
|
||||
import org.gradle.kotlin.dsl.the
|
||||
import java.io.File
|
||||
|
||||
inline fun <reified T : Task> Project.task(noinline configuration: T.() -> Unit) = tasks.creating(T::class, configuration)
|
||||
|
||||
@@ -7,7 +7,6 @@ dependencies {
|
||||
compile(projectDist(":kotlin-stdlib"))
|
||||
compile(project(":core:deserialization"))
|
||||
compile(ideaSdkCoreDeps(*(rootProject.extra["ideaCoreSdkJars"] as Array<String>)))
|
||||
compile(ideaSdkDeps("jps-model.jar", subdir = "jps"))
|
||||
}
|
||||
|
||||
sourceSets {
|
||||
|
||||
@@ -0,0 +1,134 @@
|
||||
/*
|
||||
* 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.utils;
|
||||
|
||||
import com.intellij.openapi.util.SystemInfo;
|
||||
import com.intellij.openapi.util.io.FileFilters;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.io.FileUtilRt;
|
||||
import com.intellij.openapi.util.registry.Registry;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileFilter;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
import static com.intellij.util.ObjectUtils.notNull;
|
||||
|
||||
//todo[Alefas]: copypaste from org.jetbrains.jps.model.java.impl.JavaSdkUtil
|
||||
/**
|
||||
* @author nik
|
||||
*/
|
||||
public class JavaSdkUtil {
|
||||
@NotNull
|
||||
public static List<File> getJdkClassesRoots(@NotNull File home, boolean isJre) {
|
||||
File[] jarDirs;
|
||||
if (SystemInfo.isMac && !home.getName().startsWith("mockJDK")) {
|
||||
File openJdkRtJar = new File(home, "jre/lib/rt.jar");
|
||||
if (openJdkRtJar.isFile()) {
|
||||
File libDir = new File(home, "lib");
|
||||
File classesDir = openJdkRtJar.getParentFile();
|
||||
File libExtDir = new File(openJdkRtJar.getParentFile(), "ext");
|
||||
File libEndorsedDir = new File(libDir, "endorsed");
|
||||
jarDirs = new File[]{libEndorsedDir, libDir, classesDir, libExtDir};
|
||||
}
|
||||
else {
|
||||
File libDir = new File(home, "lib");
|
||||
File classesDir = new File(home, "../Classes");
|
||||
File libExtDir = new File(libDir, "ext");
|
||||
File libEndorsedDir = new File(libDir, "endorsed");
|
||||
jarDirs = new File[]{libEndorsedDir, libDir, classesDir, libExtDir};
|
||||
}
|
||||
}
|
||||
else if (new File(home, "lib/jrt-fs.jar").exists()) {
|
||||
jarDirs = ArrayUtil.EMPTY_FILE_ARRAY;
|
||||
}
|
||||
else {
|
||||
File libDir = new File(home, isJre ? "lib" : "jre/lib");
|
||||
File libExtDir = new File(libDir, "ext");
|
||||
File libEndorsedDir = new File(libDir, "endorsed");
|
||||
jarDirs = new File[]{libEndorsedDir, libDir, libExtDir};
|
||||
}
|
||||
|
||||
FileFilter jarFileFilter = FileFilters.filesWithExtension("jar");
|
||||
Set<String> pathFilter = ContainerUtil.newTroveSet(FileUtil.PATH_HASHING_STRATEGY);
|
||||
List<File> rootFiles = ContainerUtil.newArrayList();
|
||||
if (Registry.is("project.structure.add.tools.jar.to.new.jdk")) {
|
||||
File toolsJar = new File(home, "lib/tools.jar");
|
||||
if (toolsJar.isFile()) {
|
||||
rootFiles.add(toolsJar);
|
||||
}
|
||||
}
|
||||
for (File jarDir : jarDirs) {
|
||||
if (jarDir != null && jarDir.isDirectory()) {
|
||||
File[] jarFiles = notNull(jarDir.listFiles(jarFileFilter), ArrayUtil.EMPTY_FILE_ARRAY);
|
||||
for (File jarFile : jarFiles) {
|
||||
String jarFileName = jarFile.getName();
|
||||
if (jarFileName.equals("alt-rt.jar") || jarFileName.equals("alt-string.jar")) {
|
||||
continue; // filter out alternative implementations
|
||||
}
|
||||
String canonicalPath = getCanonicalPath(jarFile);
|
||||
if (canonicalPath == null || !pathFilter.add(canonicalPath)) {
|
||||
continue; // filter out duplicate (symbolically linked) .jar files commonly found in OS X JDK distributions
|
||||
}
|
||||
rootFiles.add(jarFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
String[] ibmJdkVmJarDirs = {"bin/default", "lib/i386/default", "lib/amd64/default"};
|
||||
for (String relativePath : ibmJdkVmJarDirs) {
|
||||
File libDir = new File(home, isJre ? relativePath : "jre/" + relativePath);
|
||||
File[] vmJarDirs = notNull(libDir.listFiles(FileUtilRt.ALL_DIRECTORIES), ArrayUtil.EMPTY_FILE_ARRAY);
|
||||
for (File dir : vmJarDirs) {
|
||||
if (dir.getName().startsWith("jclSC")) {
|
||||
File vmJar = new File(dir, "vm.jar");
|
||||
if (vmJar.isFile()) {
|
||||
rootFiles.add(vmJar);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
File classesZip = new File(home, "lib/classes.zip");
|
||||
if (classesZip.isFile()) {
|
||||
rootFiles.add(classesZip);
|
||||
}
|
||||
|
||||
if (rootFiles.isEmpty()) {
|
||||
File classesDir = new File(home, "classes");
|
||||
if (classesDir.isDirectory()) {
|
||||
rootFiles.add(classesDir);
|
||||
}
|
||||
}
|
||||
|
||||
return rootFiles;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static String getCanonicalPath(File file) {
|
||||
try {
|
||||
return file.getCanonicalPath();
|
||||
}
|
||||
catch (IOException e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -18,7 +18,6 @@ package org.jetbrains.kotlin.utils
|
||||
|
||||
import com.intellij.openapi.application.ApplicationManager
|
||||
import com.intellij.openapi.application.PathManager
|
||||
import org.jetbrains.jps.model.java.impl.JavaSdkUtil
|
||||
|
||||
import java.io.File
|
||||
import java.util.regex.Pattern
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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"))
|
||||
|
||||
+13
-1
@@ -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")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-4
@@ -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(
|
||||
|
||||
@@ -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() {}
|
||||
}
|
||||
+26
@@ -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);
|
||||
}
|
||||
}
|
||||
+1
-4
@@ -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")
|
||||
}
|
||||
+1
-1
@@ -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)
|
||||
}
|
||||
+27
@@ -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)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user