Commit Graph

222 Commits

Author SHA1 Message Date
Troels Bjerre Lund 111bb461a9 CLI: Change kotlin reflection to java reflection
The command line argument parser is using between 0.25s and 0.5s
(depending on platform) on finding annotated properties. This fix
replaces the slow kotlin reflection with java reflection, which is an
order of magnitude faster.

 #KT-58183 Fixed
2023-06-27 08:34:40 +00:00
Alexander Udalov 60016d3e5b Remove obsolete compiler flag -Xuse-ir 2023-05-30 14:46:09 +00:00
Ilya Goncharov bcefa1cd66 [Gradle, Wasm] Add wasm platform kind
KTIJ-25583
2023-05-17 13:28:20 +00:00
Nikolay Krasko 0aaaa5b4fa [213] Fix 1.5.10-release-949 jdk 8 stdlib requirement in :jps-common:test
ERROR:
:jps:jps-common:test: Could not find org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.10-release-949.

The problem is in dependency:
com.jetbrains.intellij.platform:jps-model-serialization:213.7172.25 -- (runtime) ->
com.jetbrains.intellij.platform:util:213.7172.25 -- (runtime) ->
org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.10-release-949

Provide a jdk 8 stdlib that should make the resolution of the dependency
redundant.

KTI-1114
2023-04-24 21:58:31 +00:00
Yahor Berdnikau eb4e96a113 Add kotlin-build-tools-enum-compat workaround
It acts as a workaround for the case when build tools or dependencies
are compiled with latest 'kotlin-stdlib' version, but at a runtime older
 'kotlin-stdlib' is provided, which does not know about new
 `EnumEntries`.

 ^KT-57317 Fixed
2023-04-21 14:57:17 +00:00
Sebastian Sellmair 5d0bf2de24 [CLI] Restore K2JVMCompilerArguments.classpath and javaModulePath
to support IDEs < 2023.2

Reverts:
- 9dcd40d7b7
- fb66764c4d

KTIJ-25227
2023-04-18 09:18:10 +00:00
Sebastian Sellmair 7fe3c5c423 [Gradle] Demote FakeK2NativeCompilerArguments deprecation to 'WARNING'
KTIJ-25227
2023-04-18 09:18:10 +00:00
Sebastian Sellmair 9dcd40d7b7 [CLI] K2JVMCompilerArguments: Model classpath as Array<String>
to allow interning individual file-path arguments on the IDE

KTIJ-24976
2023-04-06 16:03:03 +00:00
Sebastian Sellmair 2b893365aa [Gradle] Replace FakeK2NativeCompilerArguments with K2NativeCompilerArguments
KTIJ-24976
2023-04-06 16:03:02 +00:00
Leonid Shalupov 7480befe32 Replace reflection-based compiler arguments copying with generated code
Using of Kotlin reflection for simple operations like bean management is very slow

First time initialization time: 261 ms for `copyBean(K2JVMCompilerArguments())`
Subsequent calls of `copyBean(K2JVMCompilerArguments())` take 1.7 ms per call

Unfortunately compiler argument handling is also used in Kotlin IntelliJ plugin
to parse facet settings. Big projects may have thousands of Kotlin facets

The same `ArgumentUtilsKt.copyProperties` frame is seen across various freezes:
IDEA-252440 2-3 minutes freeze on Kotlin project reimporting in last 203 eap
IDEA-253107 A lot of short freezes (1-3 sec) during Kotlin project development
KTIJ-23501 Make main run configuration detection lighter
KTIJ-22435 Unresponsive UI with 100% cpu

Reflection issue:
KT-56358 KClasses.getMemberProperties takes too much time

This commit replaces all reflection stuff with a simple code generation
Now `K2JVMCompilerArguments().clone()` goes to hard-to-measure time
2023-04-03 15:47:35 +02:00
Aleksei.Cherepanov 5c039e25fc Pin API and language version to 1.8 for Kotlin facet serialization used by IJ
Facet serialization is located in Kotlin repo, and it uses new(1.9.*) stdlib in compile dependencies. But when it is used by IJ it has previous runtime stdlib dependency (looks like 1.8.0). So here is workaround, that specifies apiVersion and languageVersion, that does not produce such problematic outputs.

#KTIJ-24903 Fixed

Merge-request: KT-MR-9333
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
2023-04-03 09:24:21 +00:00
Konstantin Tskhovrebov aae0cf9e30 Restore a Kotlin facet version to keep serialized settings compatibility
And add a fallback for ExternalSystemTestRunTask serialization.
2023-02-13 16:07:56 +00:00
Konstantin Tskhovrebov bb0ddcbeba Add kotlin platform ID to imported gradle run tasks
It is necessary to determine a platform for the run tasks, for example, to hide run configurations for a some specific target.
2023-02-13 10:20:41 +00:00
Anna Kozlova f784628ebf [CLI] reduce memory usage for compiler settings
make write protection directly in properties
it creates no additional wrapper with the link to the containing class
for ij project, this reduces memory usage for ~15 mb

^KT-56351
2023-02-06 07:57:53 +00:00
Ilya Goncharov 1150ec6882 [JS] Implementation dependencies for JS klibs
^KT-56158 fixed
2023-01-27 13:31:59 +00:00
Artem Kobzar 71486a321c [K/JS] Add support of compilation with ES-classes 2023-01-17 18:14:17 +00:00
Alexander Udalov 3f2b51151f Remove -Xexclude-from-dumping
Apparently the underlying logic was removed in b07690fccf and no one
noticed.
2023-01-02 15:26:07 +00:00
Evgeniy.Zhelenskiy 25db5bf6e1 [IR] Enable -Xvalue-classes flag
Signed-off-by: Evgeniy.Zhelenskiy <Evgeniy.Zhelenskiy@jetbrains.com>

#KT-1179
2022-12-22 12:24:16 +00:00
Sebastian Sellmair 0f4e4ac20e KotlinFacetSettings: Serialize and deserialize additionalVisibleModuleNames
^KT-55145 Verification Pending
2022-11-28 18:00:48 +00:00
Jaebaek Seo 1a5a6474d6 Support TargetPlatform.isJs() for FIR 2022-11-15 16:50:17 +01:00
Alexander Korepanov d5e9e87538 [JS BE] Drop JS scripting support
JS scripting uses the old IR to JS transformer.
 The new IR to JS transformer can not be used for
 JS scripting out of the box. Patching the new transformer for
 JS scripting is potentially dangerous and requires a lot of effort.
 Dropping JS scripting and the old IR to JS transformer allows to
 refactor and simplify JS BE codebase.
2022-11-04 14:15:15 +00:00
Aleksei.Cherepanov dc57ccdf76 Clean up default additional compiler argument
Remove `-version` from additional compiler arguments of newly created facets

#KTIJ-22490 Fixed
2022-09-22 09:14:08 +00:00
Alexander Udalov 0569f429dd Report error on -Xuse-old-backend, remove Gradle option useOldBackend
Allow using old JVM backend only to compile kts.

 #KT-48532 Fixed
2022-09-16 00:16:31 +02:00
Alexander Udalov a76de14026 Remove obsolete compiler argument -Xsingle-module
#KT-51622
2022-08-31 20:54:50 +02:00
Nikita Bobko 0a6dadd04d 4/5 Replace source dependency on kotlin-reflect with binary dependency
Review: https://jetbrains.team/p/kt/reviews/6753

Meaningful semantic change was splitted into 5 commits to simplify the
change review. Sinle commit would be too big.

Why replace source to binary: to get rid of kotlin-reflect in Kotlin
plugin artifact KTIJ-22276
2022-08-22 15:43:53 +02:00
Nikita Bobko 8f79e833a8 Drop all redundant kotlin-reflect, kotlin-reflect-api dependencies
Review: https://jetbrains.team/p/kt/reviews/6753

All redundant I managed to find, of course.

Why: I'm going to process all reflect dependencies in the next commits.
Cleanup reflect dependency before processing.

They are redundant because:
1. if `compileOnly` then compilation didn't break after dropping the
   dependency
2. if `test*` then tests didn't break after dropping the dependency.
3. `analysis/analysis-api-fir/analysis-api-fir-generator/build.gradle.kts`
   `compiler/fir/checkers/checkers-component-generator/build.gradle.kts`
   Drop `implementation(project(":kotlin-reflect-api"))` because the
   module already depends on
   `implementation(project(":kotlin-reflect"))`
4. `compiler/daemon/daemon-client/build.gradle.kts`. Drop `runtimeOnly`
   because after dropping `compileOnly` compilation didn't break (so
   `runtimeOnly` looks suspicious). Less safe than 1-3
2022-08-22 15:42:57 +02:00
Yaroslav Chernyshev 0efca602a0 Invoke KotlinFacetSettings#updateMergedArguments after deserialization 2022-08-11 17:42:56 +02:00
Nikita Bobko 2c5bd4a065 Drop unused DefaultIdeTargetPlatformKindProvider class
KMA-455

This class was used in intellij but usages was dropped in
a55a62106e40f8545d654d5519576fa4e732d0fd (intellij repo).

DefaultIdeTargetPlatformKindProvider is useless because
`DefaultIdeTargetPlatformKindProvider.defaultPlatform` implementation
always returns `JvmPlatforms.defaultJvmPlatform`
2022-06-29 15:35:57 +02:00
Nikita Bobko 540164a691 Refactoring: Split compilerModulesForJps into "embedded" and "maven"
This small refactoring is needed for the next commit.

This commit doesn't change any semantic.
2022-05-30 17:13:56 +02:00
Nikita Bobko 3569cdda38 JPS plugin: use single source of truth for the classpath
Before this commit `jps/jps-*/build.gradle.kts` list of dependencies
were partially duplicated in the `compilerModulesForJps`

Right now, list of all JPS dependencies is the source of truth.
Actually, I wish I could it do it the other way around -- let the Gradle
do dependency management and correctly produce jars with as less as
possible other libraries being embedded, and as much as poosible
libraries being just dependencies in the pom.xml.

I tried to do so using `embedded` and self-made configurations but
desperately failed, because was getting to big
`kotlin-jps-plugin-classpath` jar. Probably, what I was getting is a
correct classpath, and currently hardcoded classpath may not be
correctly full. Well, at least current classpath is time-proven.
2022-05-30 17:13:56 +02:00
Nikita Bobko 0cb256a999 JPS plugin: Cleanup dependencies
- Some unnecessary dependencies are dropped
- `api` is replaced with `implementation` when it's more appropriate (in
  our case more appropriate everywhere). `implementation` makes it
  easier to analyze dependencies because it doesn't export the
  dependencies
- Regarding: `// Workaround for Gradle dependency resolution error`.
  Actually, it's not longer needed for the successful project import.
  Confirmed by Yahor and tested locally.
2022-05-30 17:13:56 +02:00
Nikita Bobko 74307ad434 JpsUtils.isJps: fix NoClassDefFoundError
This commit fixes:

    Caused by: java.lang.NoClassDefFoundError: com/intellij/openapi/components/ComponentManager
      at java.base/java.lang.ClassLoader.defineClass1(Native Method)
      at java.base/java.lang.ClassLoader.defineClass(ClassLoader.java:1017)
      at java.base/java.security.SecureClassLoader.defineClass(SecureClassLoader.java:174)
      at java.base/java.net.URLClassLoader.defineClass(URLClassLoader.java:555)
      at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:458)
      at java.base/java.net.URLClassLoader$1.run(URLClassLoader.java:452)
      at java.base/java.security.AccessController.doPrivileged(Native Method)
      at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:451)
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:589)
      at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:522)
      at java.base/java.lang.Class.getDeclaredMethods0(Native Method)
      at java.base/java.lang.Class.privateGetDeclaredMethods(Class.java:3166)
      at java.base/java.lang.Class.getMethodsRecursive(Class.java:3307)
      at java.base/java.lang.Class.getMethod0(Class.java:3293)
      at java.base/java.lang.Class.getMethod(Class.java:2106)
      at org.jetbrains.kotlin.config.JpsUtilsKt$isJps$2.invoke(JpsUtils.kt:17)

In c1f2d66ed8 I replaced
`ApplicationManager.getApplication() == null` with
`Class.forName("ApplicationManager").getMethod("getApplication").invoke(null)`.
It turned out that those two are not equivalent.

`getMethod` tries to match queried signatures with existing signatures
=> it tries to load classes in signatures => it tries to load
`com.intellij.openapi.application.Application` (and fails because
`Application` supertype isn't in the classpath).

Contrary, `ApplicationManager.getApplication() == null` doesn't try to
load `com.intellij.openapi.application.Application` class, so it doesn't
fail.

I use MethodHandles API because it forces me to write `Class.forName`
myself (compared to implicit `Class.forName("Application")` inside
`getMethod`) which I find a nice safety feature.
2022-05-04 09:15:17 +00:00
Nikita Bobko c1f2d66ed8 Kotlin JPS plugin: drop intellij-core dependency
Drop dependency because
https://youtrack.jetbrains.com/issue/IDEA-292483/UnsupportedClassVersionError-when-trying-to-run-JUnit5-unit-test#focus=Comments-27-6034750.0-0

IDEA plans to drop `PathUtil` from JPS classpath, we should prepare to
that

`KotlinFacetSettingsProvider` isn't used in jps so it was moved into
intellij repo. It was moved to
`community/plugins/kotlin/idea/src/org/jetbrains/kotlin/config/KotlinFacetSettingsProvider.kt`
path (so you can find it git history)

Review: KT-MR-6195
2022-04-29 14:51:03 +02:00
Simon Ogorodnik 58885a1b07 KT-52217 Rename 'use-fir' to 'use-k2', update message 2022-04-28 15:42:42 +00:00
Aleksei.Cherepanov bdf229bc5c [JPS] Ignore classpath from facets to exclude jars from gradle build
Reimport after `./gradlew build` adds jars from gradle's `build/libs` to facet's classpath. That causes problems with JPS build, because it doesn't see changes in out folder, but see unchanged jar, so changes don't apply.

#KT-51873 Fixed

Merge-request: KT-MR-6018
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
2022-04-18 11:20:40 +00:00
Mikhail Glukhikh 5798320e9e Drop usages of CompilerArguments::useExperimental 2022-01-27 11:48:21 +00:00
Nikita Bobko 47ed6dcfb4 CompilerArgumentsSerializerV5.serializeTo: fix NPE
NPE was happening on `?.takeIf { it.get(arguments) != it.get(newInstance) }` line.
It was happening because `it.get` could return `null`.

But the problem was only reproducible on TeamCity and not reproducible locally.

Test example (IJ repo): `org.jetbrains.kotlin.idea.fir.completion.HighLevelJvmBasicCompletionTestGenerated$Common$FromSmart.testArrayLiteralAnnotationConstructorAsDefaultValueForArray`
stacktrace:
```
java.lang.NullPointerException
  at org.jetbrains.kotlin.arguments.CompilerArgumentsSerializerV5.serializeTo(CompilerArgumentsSerializer.kt:23)
  at org.jetbrains.kotlin.config.FacetSerializationKt.writeLatestConfig(facetSerialization.kt:379)
  at org.jetbrains.kotlin.config.FacetSerializationKt.serializeFacetSettings(facetSerialization.kt:422)
  at org.jetbrains.kotlin.idea.facet.KotlinFacetConfigurationImpl.writeExternal(KotlinFacetConfigurationImpl.kt:24)
```
2022-01-13 10:11:44 +01:00
Mikhail Zarechenskiy 0f0fa4736a [CHERRY PICKED FROM IJ] [kotlin] configuration: allow API version 1.3 with 1.6.x compiler
Starting from 1.6.0 the compiler supports three previous API versions, i.e., 1.3, 1.4, 1.5. Note that it's only about API versions, two previous language versions are supported as previously. See KT-49006 for details.

 ^KTIJ-19978 Fixed

GitOrigin-RevId: e1ba99ac25135959d8b81287850798a222643c88
Original commit: https://github.com/JetBrains/intellij-community/commit/d256c4653ab5aa730e522d282aed49a83f0c99f8
2022-01-12 15:25:21 +01:00
Nikita Bobko a8d7f91252 Temporarily ignore some tests from CompilerArgumentsContentProspectorTest
KT-50594
2022-01-12 15:25:18 +01:00
Nikita Bobko fc9000d460 Adopt Kotlin JPS plugin modules Gradle model to kotlin/master
Recenlty, Kotlin repository started using Gradle 7.1.
Deprecated `compile`/`testCompile` Gradle API were dropped in that release
2022-01-12 15:25:17 +01:00
Nikita Bobko 3b3a7f4566 Add jps-common/test source root 2022-01-12 15:25:13 +01:00
Nikita Bobko 735d46efb4 Freezable.{frozen, unfrozen} refactoring: add type safety 2022-01-12 15:25:10 +01:00
Nikita Bobko 8a289440ce Kotlin JPS plugin: add "version" setting
Part of KTIJ-11633
2022-01-12 15:25:10 +01:00
Nikita Bobko a9cdca40c3 Compilation fixes 2022-01-12 15:25:09 +01:00
Yaroslav.Chernyshev 3556853347 [CHERRY PICKED FROM IJ] [Gradle, Importing] Fix missed optimization
GitOrigin-RevId: 4839fb3bd88b135992a4bd1963b566ed77225b28
Original commit: https://github.com/JetBrains/intellij-community/commit/08fe803d3a03a0a89e67a0b24c41d7494b981a5e
2022-01-12 15:11:05 +01:00
Yaroslav.Chernyshev 6cc7566b2e [CHERRY PICKED FROM IJ] [Gradle, Importing] Attach KotlinGradleSourceSetData nodes to KotlinGradleProjectData instead GradleProjectData
It fixes issues in AS, when GradleProjectData for variants are not created

GitOrigin-RevId: dbd023d0f4fba8b14870aa8952ac0b395a2e4096
Original commit: https://github.com/JetBrains/intellij-community/commit/1c9630cf220df2b380aaf54f28497e41245d8ed6
2022-01-12 15:11:05 +01:00
Nikita Bobko b252897a01 [CHERRY PICKED FROM IJ] [cleanup] Inline VersionView.RELEASED_VERSION
The variable is redundant

GitOrigin-RevId: 99e0e06f8eda6410c41a67b88db50d4d8b5f52ca
Original commit: https://github.com/JetBrains/intellij-community/commit/8b09416812def39f15cdcd7e836129ca6ccc2094
2022-01-12 15:11:02 +01:00
Yaroslav.Chernyshev 93d569d090 [CHERRY PICKED FROM IJ] Fix KotlinFacetSettings serialization issues for compiler arguments
GitOrigin-RevId: 29d3bab972fc797fab7244c16df21763055db0c4
Original commit: https://github.com/JetBrains/intellij-community/commit/4e9f0bfaef343536930276ba27f582a95613d121
2022-01-12 15:11:01 +01:00
Nikita Bobko 779a5c40c0 [CHERRY PICKED FROM IJ] [refactoring] IdePlatformKind: remove unnecessary generic parameter
It seems that it's not used anymore after 82906a0f35ea13673a8a3b3bfaee94a568eff215

GitOrigin-RevId: 229d3b0573873c2da661712f6fce194816436ca7
Original commit: https://github.com/JetBrains/intellij-community/commit/70e4b14a5a37b8d591df2663725fd1d2c6881628
2022-01-12 15:11:00 +01:00
Yaroslav Chernyshev f6d9e53b66 [CHERRY PICKED FROM IJ] [Import] Introduce new version of KotlinFacetSettings, improve serialization of compiler arguments
^KTIJ-13451 Fixed

GitOrigin-RevId: 17ff1ea6c947b7582b445004959c42e54819d31a
Original commit: https://github.com/JetBrains/intellij-community/commit/14bd2509ad37f0c818f6753b097d4c138fba5d89
2022-01-12 15:10:59 +01:00