Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
690e0e1
enable nullability handling for scripts and make sure changes kotlin …
Nov 5, 2021
c366301
improve gradle build
Nov 6, 2021
7d02ac3
improve gradle build
Nov 6, 2021
99fe103
improve gradle build
Nov 7, 2021
19e5f77
improve gradle build
Nov 8, 2021
e73e046
improve gradle build
Nov 8, 2021
6e9fe06
fix warning
Nov 8, 2021
821f3cb
fix provided properties in scripts not with imports but with added pr…
Nov 21, 2021
7f975de
remove test property
Nov 21, 2021
5d20665
only unique classpath entries
Nov 21, 2021
cc89e17
Make the ScriptingContribution capable of deciding which classpath to…
Nov 23, 2021
95657d2
create console perproject as otherwise an error in the first project …
Dec 18, 2021
b3c77e4
Fixed search references did not find import alias references.
Mar 21, 2022
05e9801
Also find functions and properties in objects and companion objects.
Mar 21, 2022
b9ae950
enable find references to find delegated properties as reference to o…
Mar 23, 2022
1640594
adjust presentation of items, enable search for and reference resolut…
Mar 24, 2022
1cb5c05
extract context assist to separate processor as currently it gets sho…
Mar 24, 2022
593dbad
remove unused code
Mar 24, 2022
7a7db18
its just called fromone point where we can only open one possibility …
Mar 24, 2022
dbe381b
we don't need that function at all, we just need to order the returne…
Mar 24, 2022
0a42679
Add open super implementation to context popup menu.
Mar 25, 2022
3425fee
Optimize code
Mar 25, 2022
16116d9
add ability to search for implementations of classes / interfcaes, pr…
Mar 26, 2022
884a7c3
Add new wizards for data and annotation classes and for sealed classe…
Mar 27, 2022
71f0229
fix type name for provided properties preferes the actual kotlin type…
May 11, 2022
31630b5
sort completion proposals by machting name and after that by theire t…
May 23, 2022
24ae76f
Revert "sort completion proposals by machting name and after that by …
May 23, 2022
d9d6a5c
fixed autocompletion and merged sorting from newer branch into older …
May 31, 2021
e78b500
fixed double import suggestion.
May 23, 2022
a2786a1
convert java to kotlin
Jun 16, 2022
19c2bdd
Merge remote-tracking branch 'origin/kotlin/1.5.31/idea/2020.2' into …
Jun 16, 2022
adf645c
fix warnings
Jul 7, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions kotlin-bundled-compiler/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ Export-Package: com.google.common.collect,
kotlin.script.templates.standard,
kotlin.sequences,
kotlin.text,
kotlinx.coroutines,
org.jetbrains.annotations,
org.jetbrains.kotlin,
org.jetbrains.kotlin.analyzer,
Expand Down
28 changes: 19 additions & 9 deletions kotlin-bundled-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import com.intellij.buildsupport.dependencies.PackageListFromSimpleFile
import com.intellij.buildsupport.resolve.http.HttpArtifact
import com.intellij.buildsupport.resolve.http.HttpArtifactsResolver
import com.intellij.buildsupport.resolve.http.idea.IntellijIdeaArtifactsResolver
import com.intellij.buildsupport.resolve.tc.kotlin.KotlinCompilerTCArtifactsResolver
import com.intellij.buildsupport.utils.FileUtils

apply(plugin = "base")
Expand Down Expand Up @@ -78,6 +77,12 @@ tasks.named<Delete>("clean") {
}
}

val deleteLibrariesFromLibFolder by tasks.registering {
doFirst {
libDir.listFiles()?.filter { it.isFile }?.forEach { it.deleteRecursively() }
}
}

val downloadTestData by tasks.registering {
val locallyDownloadedTestDataFile by extra {
if(localTCArtifacts){
Expand Down Expand Up @@ -106,9 +111,12 @@ val downloadTestFrameworkDependencies by tasks.registering(Copy::class) {
}

val downloadKotlinCompilerPluginAndExtractSelectedJars by tasks.registering {
dependsOn(deleteLibrariesFromLibFolder)

val kotlinDownloadDir = file("$downloadDir/kotlin-$kotlinCompilerVersion/$kotlinIdeaCompatibleVersionMinor")
val locallyDownloadedCompilerFile by extra {
file(downloadDir).listFiles()?.firstOrNull { it.name.startsWith("kotlin-plugin-") }
?: file("$downloadDir/kotlin-plugin.zip")
file(kotlinDownloadDir).listFiles()?.firstOrNull { it.name.startsWith("kotlin-plugin-") }
?: file("$kotlinDownloadDir/kotlin-plugin.zip")
}

doLast {
Expand Down Expand Up @@ -172,7 +180,9 @@ val extractPackagesFromPlugin by tasks.registering(Jar::class) {
}

val downloadIntellijCoreAndExtractSelectedJars by tasks.registering {
val locallyDownloadedIntellijCoreFile by extra { file("$downloadDir/intellij-core.zip") }
dependsOn(deleteLibrariesFromLibFolder)
val ideaDownloadDir = file("$downloadDir/idea-$ideaVersion")
val locallyDownloadedIntellijCoreFile by extra { file("$ideaDownloadDir/intellij-core.zip") }

doLast {
if(!locallyDownloadedIntellijCoreFile.exists()) {
Expand All @@ -191,7 +201,9 @@ val downloadIntellijCoreAndExtractSelectedJars by tasks.registering {
}

val downloadIdeaDistributionZipAndExtractSelectedJars by tasks.registering {
val locallyDownloadedIdeaZipFile by extra { file("$downloadDir/ideaIC.zip") }
dependsOn(deleteLibrariesFromLibFolder)
val ideaDownloadDir = file("$downloadDir/idea-$ideaVersion")
val locallyDownloadedIdeaZipFile by extra { file("$ideaDownloadDir/ideaIC.zip") }
val chosenJars by extra { setOf(//"openapi",
"platform-util-ui",
"util",
Expand Down Expand Up @@ -301,14 +313,12 @@ val repackageIdeaAndKotlinCompilerSources by tasks.registering(Zip::class) {

val downloadBundled by tasks.registering {
if (localTCArtifacts) {
dependsOn(downloadKotlinCompilerPluginAndExtractSelectedJars,
extractPackagesFromPlugin,
dependsOn(extractPackagesFromPlugin,
downloadIntellijCoreAndExtractSelectedJars,
createIdeDependenciesJar,
downloadKotlinxLibraries)
} else {
dependsOn(downloadKotlinCompilerPluginAndExtractSelectedJars,
extractPackagesFromPlugin,
dependsOn(extractPackagesFromPlugin,
downloadIntellijCoreAndExtractSelectedJars,
createIdeDependenciesJar,
downloadKotlinxLibraries)
Expand Down
10 changes: 5 additions & 5 deletions kotlin-bundled-compiler/buildSrc/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@ repositories {


dependencies {
compile 'org.jetbrains.teamcity:teamcity-rest-client:1.5.0'
implementation 'org.jetbrains.teamcity:teamcity-rest-client:1.5.0'

testCompile('org.spockframework.spock:spock-core:spock-1.3') {
testImplementation('org.spockframework.spock:spock-core:spock-1.3') {
exclude module : 'groovy-all'
}
testCompile 'com.github.stefanbirkner:system-rules:1.19.0'
testCompile 'org.apache.commons:commons-lang3:3.8.1'
testImplementation 'com.github.stefanbirkner:system-rules:1.19.0'
testImplementation 'org.apache.commons:commons-lang3:3.8.1'

}

test.enabled = false // otherwise integration tests will run always before the actual build
test.enabled = false // otherwise integration tests will run always before the actual build
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class HttpArtifactsResolver {
destinationFile.parentFile.mkdirs()

def ant = new AntBuilder()
if (!proxyProps.isEmpty()) {
if (!proxyProps.isEmpty() && proxyProps['https.proxyHost'] != null) {
if (proxyProps.get("https.proxyUser") == null) {
ant.setproxy(proxyHost: proxyProps['https.proxyHost'], proxyPort: proxyProps['https.proxyPort'])
} else {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ object KotlinLightClassGeneration {
return checkByInternalName(internalName, requestedClassName)
}

override fun shouldGeneratePackagePart(jetFile: KtFile): Boolean {
val internalName = JvmFileClassUtil.getFileClassInternalName(jetFile)
override fun shouldGeneratePackagePart(ktFile: KtFile): Boolean {
val internalName = JvmFileClassUtil.getFileClassInternalName(ktFile)
return checkByInternalName(internalName, requestedClassName)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,10 @@ private void saveJvmSignature(@NotNull JvmDeclarationOrigin origin, @NotNull Str
if (element != null) {
Set<Pair<String, String>> userData = element.getUserData(JVM_SIGNATURE);
if (userData == null) {
userData = Collections.newSetFromMap(new ConcurrentHashMap<Pair<String, String>, Boolean>());
userData = Collections.newSetFromMap(new ConcurrentHashMap<>());
element.putUserData(JVM_SIGNATURE, userData);
}
userData.add(new Pair<String, String>(desc, name));
userData.add(new Pair<>(desc, name));
}
}
};
Expand All @@ -77,4 +77,4 @@ public byte[] asBytes(ClassBuilder builder) {
@Override
public void close() {
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,68 +4,74 @@ import com.intellij.openapi.util.Disposer
import org.eclipse.jdt.core.IJavaProject
import org.jetbrains.kotlin.cli.common.CLIConfigurationKeys
import org.jetbrains.kotlin.cli.common.arguments.K2JVMCompilerArguments
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageLocation
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.ERROR
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSeverity.EXCEPTION
import org.jetbrains.kotlin.cli.common.messages.CompilerMessageSourceLocation
import org.jetbrains.kotlin.cli.common.messages.MessageCollector
import org.jetbrains.kotlin.cli.jvm.K2JVMCompiler
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCoreEnvironment
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.core.filesystem.KotlinLightClassManager.Companion.KOTLIN_TOUCHED_FILES_FILE_NAME
import org.jetbrains.kotlin.core.launch.CompilerOutputData
import org.jetbrains.kotlin.core.launch.CompilerOutputParser
import org.jetbrains.kotlin.core.launch.KotlinCLICompiler
import org.jetbrains.kotlin.core.model.KOTLIN_COMPILER_PATH
import org.jetbrains.kotlin.core.model.KotlinEnvironment
import org.jetbrains.kotlin.core.preferences.CompilerPlugin
import org.jetbrains.kotlin.core.utils.DependencyResolverException
import org.jetbrains.kotlin.core.utils.ProjectUtils
import org.jetbrains.kotlin.incremental.makeIncrementally
import java.io.BufferedReader
import java.io.ByteArrayOutputStream
import java.io.File
import java.io.PrintStream
import java.io.Reader
import java.io.StringReader
import java.io.*

object KotlinCompiler {

private fun compileKotlinFiles(
javaProject: IJavaProject,
compilation: (IJavaProject, File, List<File>) -> KotlinCompilerResult
javaProject: IJavaProject,
compilation: (IJavaProject, File, List<File>) -> KotlinCompilerResult
): KotlinCompilerResult =
ProjectUtils.getSrcOutDirectories(javaProject)
.groupingBy { it.second }.fold(mutableListOf<File>()) { list, key ->
list.apply { add(key.first) }
}.map { (out, sources) ->
compilation(javaProject, out, sources)
}.fold(KotlinCompilerResult(true, CompilerOutputData())) { previous, current ->
KotlinCompilerResult(previous.result and current.result, CompilerOutputData().apply {
previous.compilerOutput.list.union(current.compilerOutput.list).forEach {
add(it.messageSeverity, it.message, it.messageLocation)
ProjectUtils.getSrcOutDirectories(javaProject)
.groupingBy { it.second }.fold(mutableListOf<File>()) { list, key ->
list.apply { add(key.first) }
}.onEach { (out) ->
val tempFile = File(out, KOTLIN_TOUCHED_FILES_FILE_NAME).takeIf { it.exists() }
tempFile?.readLines()?.map(::File)?.flatMap { tempFileToDelete ->
val tempName = tempFileToDelete.nameWithoutExtension
val tempFiles = tempFileToDelete.parentFile?.listFiles(FileFilter { it.name == "$tempName.class" || (it.name.startsWith("$tempName$") && it.name.endsWith(".class")) })
tempFiles?.toList() ?: emptyList()
}?.distinct()?.forEach(File::delete)
tempFile?.delete()
out.walkTopDown().filter { it.extension == "kt" }.forEach { it.delete() }
}.map { (out, sources) ->
compilation(javaProject, out, sources)
}.fold(KotlinCompilerResult(true, CompilerOutputData())) { previous, current ->
KotlinCompilerResult(previous.result and current.result, CompilerOutputData().apply {
previous.compilerOutput.list.union(current.compilerOutput.list).forEach {
add(it.messageSeverity, it.message, it.messageLocation)
}
})
}
})
}

@JvmStatic
fun compileKotlinFiles(javaProject: IJavaProject): KotlinCompilerResult =
compileKotlinFiles(javaProject) { project, path, sources ->
execKotlinCompiler(configureCompilerArguments(project, path.absolutePath, sources))
}
compileKotlinFiles(javaProject) { project, path, sources ->
execKotlinCompiler(configureCompilerArguments(project, path.absolutePath, sources))
}

@JvmStatic
fun compileIncrementallyFiles(
javaProject: IJavaProject
javaProject: IJavaProject
): KotlinCompilerResult =
compileKotlinFiles(javaProject) { project, path, sources ->
execIncrementalKotlinCompiler(project, path.absoluteFile, sources)
}
compileKotlinFiles(javaProject) { project, path, sources ->
execIncrementalKotlinCompiler(project, path.absoluteFile, sources)
}

private fun execIncrementalKotlinCompiler(
javaProject: IJavaProject,
outputDir: File,
sourceDirs: List<File>
javaProject: IJavaProject,
outputDir: File,
sourceDirs: List<File>
): KotlinCompilerResult {
val arguments = getCompilerArguments(javaProject, outputDir)
val messageCollector = CompilerMessageCollector()
Expand All @@ -76,7 +82,7 @@ object KotlinCompiler {
put(CLIConfigurationKeys.INTELLIJ_PLUGIN_ROOT, KOTLIN_COMPILER_PATH)
}
KotlinCoreEnvironment.getOrCreateApplicationEnvironmentForProduction(disposable, config)
var cacheDir = File("${outputDir.parentFile.absolutePath}/cache").also { it.mkdirs() }
val cacheDir = File("${outputDir.parentFile.absolutePath}/cache").also { it.mkdirs() }
makeIncrementally(cacheDir, sourceDirs, arguments, messageCollector)
return messageCollector.getCompilerResult()
}
Expand All @@ -88,7 +94,7 @@ object KotlinCompiler {

private fun getCompilerArguments(javaProject: IJavaProject, outputDir: File) = K2JVMCompilerArguments().apply {
val kotlinProperties =
KotlinEnvironment.getEnvironment(javaProject.project).compilerProperties
KotlinEnvironment.getEnvironment(javaProject.project).compilerProperties

kotlinHome = ProjectUtils.ktHome
destination = outputDir.absolutePath
Expand Down Expand Up @@ -122,17 +128,20 @@ object KotlinCompiler {
pluginClasspaths = pluginClasspathsList.toTypedArray()
pluginOptions = pluginOptionsList.toTypedArray()

classpath = ProjectUtils.collectClasspathWithDependenciesForLaunch(javaProject, jdkUndefined)
.joinToString(separator = System.getProperty("path.separator")) { it.absolutePath }

val tempFiles = try {
ProjectUtils.collectClasspathWithDependenciesForLaunch(javaProject, jdkUndefined)
} catch (e: DependencyResolverException) {
e.resolvedFiles
}

classpath = tempFiles.joinToString(separator = System.getProperty("path.separator")) { it.absolutePath }
}

private fun configureCompilerArguments(
javaProject: IJavaProject, outputDir: String, sourceDirs: List<File>
javaProject: IJavaProject, outputDir: String, sourceDirs: List<File>
): Array<String> = with(mutableListOf<String>()) {
val kotlinProperties =
KotlinEnvironment.getEnvironment(javaProject.project).compilerProperties
KotlinEnvironment.getEnvironment(javaProject.project).compilerProperties

add("-kotlin-home")
add(ProjectUtils.ktHome)
Expand Down Expand Up @@ -164,9 +173,14 @@ object KotlinCompiler {
}

add("-classpath")
ProjectUtils.collectClasspathWithDependenciesForLaunch(javaProject, jdkUndefined)
.joinToString(separator = System.getProperty("path.separator")) { it.absolutePath }
.let { add(it) }

val tempFiles = try {
ProjectUtils.collectClasspathWithDependenciesForLaunch(javaProject, jdkUndefined)
} catch (e: DependencyResolverException) {
e.resolvedFiles
}

add(tempFiles.joinToString(separator = System.getProperty("path.separator")) { it.absolutePath })

add("-d")
add(outputDir)
Expand Down Expand Up @@ -194,9 +208,9 @@ object KotlinCompiler {
val compilerOutput = CompilerOutputData()

override fun report(
severity: CompilerMessageSeverity,
message: String,
location: CompilerMessageSourceLocation?
severity: CompilerMessageSeverity,
message: String,
location: CompilerMessageSourceLocation?
) {
hasErrors == hasErrors || severity.isError
severities.add(severity)
Expand All @@ -215,7 +229,7 @@ object KotlinCompiler {
}

fun getCompilerResult(): KotlinCompilerResult =
KotlinCompilerResult(severities.firstOrNull { it == ERROR || it == EXCEPTION } == null, compilerOutput)
KotlinCompilerResult(severities.firstOrNull { it == ERROR || it == EXCEPTION } == null, compilerOutput)
}

private fun parseCompilerOutput(reader: Reader): KotlinCompilerResult {
Expand Down

This file was deleted.

Loading