Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to Kotlin 1.8.10 #146

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
46 changes: 11 additions & 35 deletions kotlin-bundled-compiler/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ val ideaSdkUrl = "https://www.jetbrains.com/intellij-repository/releases/com/jet
// properties that might/should be modifiable

//val kotlinCompilerTcBuildId: String = project.findProperty("kotlinCompilerTcBuildId") as String? ?: "3546752"
val kotlinPluginUpdateId = project.findProperty("kotlinPluginUpdateId") as String? ?: "169248" // Kotlin Plugin 1.6.21 for Idea 2021.3
val kotlinPluginUpdateId = project.findProperty("kotlinPluginUpdateId") as String? ?: "286278" // Kotlin Plugin 1.8.10 for Idea 2022.2

val kotlinCompilerVersion: String = project.findProperty("kotlinCompilerVersion") as String? ?: "1.6.21"
val kotlinxVersion: String = project.findProperty("kolinxVersion") as String? ?: "1.5.2"
val kotlinCompilerVersion: String = project.findProperty("kotlinCompilerVersion") as String? ?: "1.8.10"
val kotlinxVersion: String = project.findProperty("kolinxVersion") as String? ?: "1.6.3"
val tcArtifactsPath: String = project.findProperty("tcArtifactsPath") as String? ?: ""
val ideaVersion: String = project.findProperty("ideaVersion") as String? ?: "213.5744.223" //Idea 2021.3
val kotlinIdeaCompatibleVersionMinor: String = project.findProperty("kotlinIdeaCompatibleVersionMinor") as String? ?: "2021.3"
val ideaVersion: String = project.findProperty("ideaVersion") as String? ?: "222.4459.24" //Idea 2022.2
val kotlinIdeaCompatibleVersionMinor: String = project.findProperty("kotlinIdeaCompatibleVersionMinor") as String? ?: "2022.2"
val ignoreSources: Boolean = true//project.hasProperty("ignoreSources")

//directories
Expand Down Expand Up @@ -195,38 +195,17 @@ val extractPackagesFromKTCompiler by tasks.registering(Jar::class) {
}
}

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

doLast {
if(!locallyDownloadedIntellijCoreFile.exists()) {
ideaArtifactsResolver.downloadTo(ideaArtifactsResolver.INTELLIJ_CORE_ZIP, locallyDownloadedIntellijCoreFile)
}
copy {
from(zipTree(locallyDownloadedIntellijCoreFile))

setIncludes(setOf("intellij-core.jar"))

includeEmptyDirs = false

into(libDir)
}
}
}

val downloadIdeaDistributionZipAndExtractSelectedJars by tasks.registering {
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",
val chosenJars by extra { setOf(
"util",
"idea",
//"trove4j",
"platform-api",
"platform-impl") }
"util_rt",
"idea_rt",
"app"
)
}

doLast {
if(!locallyDownloadedIdeaZipFile.exists()) {
Expand Down Expand Up @@ -328,17 +307,14 @@ val repackageIdeaAndKotlinCompilerSources by tasks.registering(Zip::class) {
}

val downloadBundled by tasks.registering {
libDir.listFiles()?.filter { it.isFile }?.forEach { it.deleteRecursively() }
if (localTCArtifacts) {
dependsOn(extractPackagesFromPlugin,
extractPackagesFromKTCompiler,
downloadIntellijCoreAndExtractSelectedJars,
createIdeDependenciesJar,
downloadKotlinxLibraries)
} else {
dependsOn(extractPackagesFromPlugin,
extractPackagesFromKTCompiler,
downloadIntellijCoreAndExtractSelectedJars,
createIdeDependenciesJar,
downloadKotlinxLibraries)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,15 @@ public final int get(@NotNull K key) {
return this.get(key, -1);
}

@Override
public int getOrDefault(@NotNull K k, int i) {
if(contains(k)) {
return get(k);
} else {
return i;
}
}

@Override
public @NotNull
Set<K> keySet() {
Expand Down
2 changes: 1 addition & 1 deletion kotlin-eclipse-core/preferences.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
jvmTarget=JVM_1_6
jvmTarget=JVM_1_8
compilerPlugins/all-open/active=false
compilerPlugins/all-open/jarPath=$KOTLIN_HOME/lib/allopen-compiler-plugin.jar
compilerPlugins/spring/active=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,8 @@ private fun findApplicableCallables(

return searchCallableByName(element)
.let { module.accept(visitor, it) }
.map { FunctionCandidate(it) }
?.map { FunctionCandidate(it) }
?: emptyList()
}

private fun CallableDescriptor.isReceiverTypeMatching(type: KotlinType): Boolean =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ import com.intellij.psi.JavaModuleSystem
import com.intellij.psi.PsiElementFinder
import com.intellij.psi.PsiManager
import com.intellij.psi.augment.PsiAugmentProvider
import com.intellij.psi.codeStyle.CodeStyleManager
import com.intellij.psi.codeStyle.CodeStyleSettingsProvider
import com.intellij.psi.codeStyle.LanguageCodeStyleSettingsProvider
import com.intellij.psi.compiled.ClassFileDecompilers
import com.intellij.psi.codeStyle.*
import com.intellij.psi.impl.PsiElementFinderImpl
import com.intellij.psi.impl.PsiTreeChangePreprocessor
import com.intellij.psi.impl.compiled.ClsCustomNavigationPolicy
Expand Down Expand Up @@ -93,8 +90,6 @@ import org.jetbrains.kotlin.scripting.definitions.ScriptDefinitionProvider
import org.jetbrains.kotlin.scripting.extensions.ScriptingResolveExtension
import java.io.File
import kotlin.reflect.KClass
import com.intellij.psi.codeStyle.CodeStyleSettingsService
import com.intellij.psi.codeStyle.CodeStyleSettingsServiceImpl

private fun setIdeaIoUseFallback() {
if (SystemInfo.isWindows) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,12 @@
* limitations under the License.
*
*******************************************************************************/
@file:OptIn(ExperimentalCompilerApi::class)

package org.jetbrains.kotlin.core.model

import com.intellij.core.CoreJavaFileManager
import com.intellij.openapi.Disposable
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.components.ServiceManager
import com.intellij.openapi.project.Project
import com.intellij.openapi.util.Disposer
Expand All @@ -35,15 +36,11 @@ import org.eclipse.jdt.core.IJavaProject
import org.eclipse.jdt.core.JavaCore
import org.eclipse.jdt.internal.core.JavaProject
import org.eclipse.osgi.internal.loader.EquinoxClassLoader
import org.jetbrains.kotlin.asJava.classes.FacadeCache
import org.jetbrains.kotlin.cli.jvm.compiler.CliVirtualFileFinderFactory
import org.jetbrains.kotlin.cli.jvm.compiler.KotlinCliJavaFileManagerImpl
import org.jetbrains.kotlin.cli.jvm.index.JvmDependenciesIndexImpl
import org.jetbrains.kotlin.cli.jvm.index.SingleJavaFileRootsIndex
import org.jetbrains.kotlin.compiler.plugin.CliOptionValue
import org.jetbrains.kotlin.compiler.plugin.CommandLineProcessor
import org.jetbrains.kotlin.compiler.plugin.ComponentRegistrar
import org.jetbrains.kotlin.compiler.plugin.parsePluginOption
import org.jetbrains.kotlin.compiler.plugin.*
import org.jetbrains.kotlin.config.CompilerConfiguration
import org.jetbrains.kotlin.config.JVMConfigurationKeys
import org.jetbrains.kotlin.container.ComponentProvider
Expand Down Expand Up @@ -156,11 +153,10 @@ class KotlinScriptEnvironment private constructor(
SingleJavaFileRootsIndex(singleJavaFileRoots),
configuration.getBoolean(JVMConfigurationKeys.USE_PSI_CLASS_FILES_READING))

val finderFactory = CliVirtualFileFinderFactory(index)
val finderFactory = CliVirtualFileFinderFactory(index, false)
project.registerService(MetadataFinderFactory::class.java, finderFactory)
project.registerService(VirtualFileFinderFactory::class.java, finderFactory)

project.registerService(FacadeCache::class.java, FacadeCache(project))
project.registerService(KotlinLightClassManager::class.java, KotlinLightClassManager(javaProject.project))

// definition?.dependencyResolver?.also { project.registerService(DependenciesResolver::class.java, it) }
Expand Down Expand Up @@ -343,10 +339,6 @@ class KotlinEnvironment private constructor(val eclipseProject: IProject, dispos
registerProjectDependenServices(javaProject)
configureClasspath(javaProject)

with(project) {
registerService(FacadeCache::class.java, FacadeCache(project))
}

registerCompilerPlugins()

cachedEnvironment.putEnvironment(eclipseProject, this)
Expand Down Expand Up @@ -388,7 +380,7 @@ class KotlinEnvironment private constructor(val eclipseProject: IProject, dispos

private fun parseOptions(args: List<String>): Map<String, List<String>> =
args.asSequence()
.map { parsePluginOption("plugin:$it") }
.map { parseLegacyPluginOption("plugin:$it") }
.filterNotNull()
.groupBy(CliOptionValue::optionName, CliOptionValue::value)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ class KotlinBuildingProperties(scope: IScopeContext = InstanceScope.INSTANCE) :

var useIncremental by BooleanPreference()

var alwaysRealBuild by BooleanPreference()

companion object {
val workspaceInstance by lazy { KotlinBuildingProperties() }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ public class EclipseJavaClass(javaElement: ITypeBinding) : EclipseJavaClassifier

override val isFinal: Boolean = Modifier.isFinal(binding.getModifiers())

override val isFromSource: Boolean get() = binding.isFromSource

override val visibility: Visibility = EclipseJavaElementUtil.getVisibility(binding)

override val typeParameters: List<JavaTypeParameter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,8 @@ public List<JavaValueParameter> getValueParameters() {
return EclipseJavaElementUtil.getValueParameters(getBinding());
}

@Override
public boolean isFromSource() {
return getBinding().getDeclaringClass().isFromSource();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ public class EclipseJavaField(private val javaField: IVariableBinding) : Eclipse
override val initializerValue: Any? = binding.constantValue

override val isEnumEntry: Boolean = binding.isEnumConstant()


override val isFromSource: Boolean
get() = binding.declaringClass.isFromSource

override val type: JavaType
get() = EclipseJavaType.create(binding.getType())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,7 @@ class EclipseJavaMethod(method: IMethodBinding) : EclipseJavaMember<IMethodBindi

override val containingClass: JavaClass
get() = EclipseJavaClass(binding.declaringClass)

override val isFromSource: Boolean
get() = binding.declaringClass.isFromSource
}
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.name.SpecialNames

public class EclipseJavaTypeParameter(binding: ITypeBinding) : EclipseJavaClassifier<ITypeBinding>(binding), JavaTypeParameter {
override val isFromSource: Boolean
get() = binding.isFromSource

override val name: Name = SpecialNames.safeIdentifier(binding.getName())

override val upperBounds: Collection<JavaClassifierType>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,4 +78,9 @@ public boolean isVararg() {
public boolean isDeprecatedInJavaDoc() {
return getBinding().isDeprecated();
}

@Override
public boolean isFromSource() {
return getBinding().isFromSource();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,10 @@ class EclipseOptimizedJavaClass(val eclipseClass: IType) : JavaClass {

override val isFinal: Boolean
get() = throw UnsupportedOperationException()


override val isFromSource: Boolean
get() = !eclipseClass.isBinary

override val isStatic: Boolean
get() = throw UnsupportedOperationException()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import java.io.File

class ProjectScriptTemplateContribution : ScriptTemplateContribution() {

override val priority: Int get() = Int.MAX_VALUE
override val priority: Int get() = Int.MIN_VALUE

override fun loadTemplate() = ProjectScriptTemplate::class

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ import org.jetbrains.kotlin.config.LanguageFeature.DefaultImportOfPackageKotlinC
import org.jetbrains.kotlin.config.LanguageVersion
import org.jetbrains.kotlin.config.LanguageVersionSettingsImpl
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor
import org.jetbrains.kotlin.idea.util.ActionRunningMode
import org.jetbrains.kotlin.idea.util.ImportDescriptorResult
import org.jetbrains.kotlin.idea.util.ImportInsertHelper
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.resolve.ImportPath
Expand All @@ -38,20 +38,11 @@ class KotlinImportInserterHelper : ImportInsertHelper() {
return importSortComparator
}

override fun importDescriptor(
element: KtElement,
descriptor: DeclarationDescriptor,
actionRunningMode: ActionRunningMode,
forceAllUnderImport: Boolean
): ImportDescriptorResult {
override fun importDescriptor(element: KtElement, descriptor: DeclarationDescriptor, runImmediately: Boolean, forceAllUnderImport: Boolean, aliasName: Name?): ImportDescriptorResult {
throw UnsupportedOperationException()
}

override fun importPsiClass(
element: KtElement,
psiClass: PsiClass,
actionRunningMode: ActionRunningMode
): ImportDescriptorResult {
override fun importPsiClass(element: KtElement, psiClass: PsiClass, runImmediately: Boolean): ImportDescriptorResult {
throw UnsupportedOperationException()
}

Expand Down
2 changes: 1 addition & 1 deletion kotlin-eclipse-feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
provider-name="JetBrains">

<description url="http://kotlinlang.org/">
Kotlin language support for Kotlin 1.6.21
Kotlin language support for Kotlin 1.8.10
</description>

<copyright url="http://www.jetbrains.com/">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,14 @@ class BuildingPropertiesView(
kotlinBuildingProperties.useIncremental = value
}

private var alwaysRealBuild by Delegates.observable(kotlinBuildingProperties.alwaysRealBuild) { _, _, value ->
kotlinBuildingProperties.alwaysRealBuild = value
}

init {
control = parent.gridContainer {
checkbox(::useIncremental, "Use incremental compiler (experimental)")
checkbox(::alwaysRealBuild, "Always build real class files")
}.control
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ abstract class BaseKotlinBuilderElement {

private val fileFilters = listOf(ScriptFileFilter, FileFromOutputFolderFilter, FileFromKotlinBinFolderFilter)

abstract fun build(project: IProject, delta: IResourceDelta?, kind: Int): Array<IProject>?
abstract fun build(project: IProject, delta: IResourceDelta?, kind: Int)

protected fun isAllFilesApplicableForFilters(files: Set<IFile>, javaProject: IJavaProject): Boolean {
return files.all { file ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,35 +3,26 @@ package org.jetbrains.kotlin.ui.builder
import org.eclipse.core.resources.IProject
import org.eclipse.core.resources.IResourceDelta
import org.eclipse.core.resources.IncrementalProjectBuilder
import org.eclipse.core.runtime.Status
import org.eclipse.core.runtime.jobs.Job
import org.eclipse.jdt.core.IJavaProject
import org.eclipse.jdt.core.JavaCore
import org.jetbrains.kotlin.core.asJava.KotlinLightClassGeneration
import org.jetbrains.kotlin.core.builder.KotlinPsiManager
import org.jetbrains.kotlin.core.compiler.KotlinCompilerResult
import org.jetbrains.kotlin.core.compiler.KotlinCompilerUtils
import org.jetbrains.kotlin.core.model.runJob
import org.jetbrains.kotlin.core.resolve.KotlinAnalyzer
import org.jetbrains.kotlin.ui.KotlinPluginUpdater
import org.jetbrains.kotlin.ui.launch.removeKotlinConsoles

class IncrementalKotlinBuilderElement : BaseKotlinBuilderElement() {

override fun build(project: IProject, delta: IResourceDelta?, kind: Int): Array<IProject>? {
override fun build(project: IProject, delta: IResourceDelta?, kind: Int) {
val javaProject = JavaCore.create(project)

if (kind == IncrementalProjectBuilder.FULL_BUILD) {
makeClean(javaProject)
return null
return
}

removeKotlinConsoles(javaProject)
compileKotlinFilesIncrementally(javaProject)

postBuild(delta, javaProject)

return null
}

private fun compileKotlinFilesIncrementally(javaProject: IJavaProject) {
Expand Down
Loading