Commit Graph

362 Commits

Author SHA1 Message Date
Jinseong Jeon
5819959cce Consolidate arrayOf call names 2021-08-18 16:04:36 +03:00
Hung Nguyen
170184dce4 KT-45777: Refactor RuntimeModuleData to support classpath snapshotting
We are working on a feature in the Kotlin Gradle plugin called
`kotlin.incremental.useClasspathSnapshot` to improve incremental
Kotlin compilation.

In this feature, we need to extract ABI information from a .class file.
If the .class file is a Kotlin class, this info can be found in the
class header data. But if the .class file is a Java class, this info is
not readily available.

The RuntimeModuleData class in the ':core:descriptors.runtime' project
can help with that: It uses reflection to generate `ClassDescriptor`s.

However, reflection requires a full classpath to work correctly, whereas
we want to generate a `ClassDescriptor` directly for each class file
(also, reflection is probably slow).

To address that, this commit refactors RuntimeModuleData so that it can
support a generic Kotlin/JavaClassFinder, which can be based on either
reflection or bytecode analysis. The existing code continues to use
reflection while the new feature will use bytecode analysis (e.g., using
the existing BinaryJavaClass).

Bug: KT-45777
Test: Existing tests should pass (this is a refactoring-only change)
2021-08-10 12:29:44 +03:00
Ilya Chernikov
df9a3c0300 Restore scripting-ide-services testing, fix coroutines dependency 2021-07-26 21:16:50 +03:00
Denis.Zharkov
ea5157cadc Change type of KotlinCoreEnvironment::projectEnvironment type 2021-07-23 21:38:45 +03:00
Nikita Bobko
39fa2b0baf Delete Kotlin IntelliJ IDEA plugin sources
Kotlin plugin sources were migrated to intellij-community:
https://github.com/JetBrains/intellij-community/tree/master/plugins/kotlin

Preserve `jps-plugin/testData/incremental`
because it's used in `compiler/incremental-compilation-impl/test`

Preserve `idea/testData/multiModuleHighlighting/multiplatform`
because it's used in `MppHighlightingTestDataWithGradleIT`
2021-07-21 11:23:43 +02:00
Ilya Muradyan
46bbe5b1cb Replace Ivy resolver with Maven resolver in all places 2021-07-19 21:31:49 +03:00
Ilya Chernikov
0cd29adcc7 Get rid of kotlinx-coroutines usage in scripting libs and plugins
the dependency on the coroutines library caused various problems like
KT-30778, or stdlib/runtime version conflicts.
The only function used was `runBlocking`, so this change replaces it
with the internal implementation based on the similar internal thing
from the stdlib.
#KT-30778 fixed
2021-07-19 16:35:36 +03:00
Ilya Chernikov
dee0487185 IR: Refactor IrBuiltIns to abstract it from descriptors 2021-07-16 02:24:18 +03:00
Georgy Bronnikov
20b76d4149 JVM_IR: reorganize initialization of JvmGeneratorExtensionsImpl
CachedFields are now created at initialization.
Therefore we need CompilerConfiguration as a constructor parameter.
2021-07-14 21:20:30 +03:00
Alexander Udalov
7a42f603f2 JVM IR: rename mangler implementation classes 2021-07-13 01:54:41 +02:00
Ilya Muradyan
55ec6729b0 [REPL] Fix completion after final expressions 2021-07-09 04:06:53 +03:00
Ilya Muradyan
787ce6335c Change nestedClasses logic to accept classes with nested type aliases
#KT-47650 fixed
2021-07-08 21:04:53 +03:00
Nikita Bobko
3ca0e11dab Add README to scripting-ide-common
Originally, we though that we would move classes from `ide-common` from Kotlin plugin to this
module but it turns that these classes are heavily used in Kotlin plugin and it's better to
keep them with the rest of Kotlin plugin. So now classes in `scripting-ide-common` are copy-pasted
2021-07-08 10:01:34 +00:00
Nikita Bobko
fbe062ee64 [refactoring] Move files in scripting-ide-common into unique subpackage
I am afraid of FQN clashes with classes in `ide-common` in kotlin-ide
2021-07-07 16:51:45 +02:00
Nikita Bobko
339231b05e Move KtFunctionLiteral.findLabelAndCall from kotlin-ide.frontend-independent to compiler.psi
I want to be able to use this function in `:kotlin-scripting-ide-common` & `frontend-independent`

This commit also allows to remove copy-pasted `findLabelAndCall` in `scripting-ide-services` module
2021-07-07 16:51:44 +02:00
Dmitry Gridin
a8a6f51a0e [common] fix flexible type approximation in renders
^KTIJ-3030 Fixed

(cherry picked from commit 4855d88a9f6fbce9aeeea6fe1f29dd099a833aed)

KT-CR-2373
2021-07-07 16:51:44 +02:00
Matthew Gharrity
958b0ff24a Ignore diagnostics in ShadowedDeclarationsFilter
During code completion, ShadowedDeclarationsFilter resolves many
synthetic calls (sometimes >1000 for certain projects/scenarios).
By ignoring diagnostics we can avoid running call checkers
during this process (pending a sibling change in the compiler).

Relates to KT-44276 and github.com/JetBrains/kotlin/pull/4027
2021-07-07 16:51:44 +02:00
Matthew Gharrity
e2109c3f8f ShadowedDeclarationsFilter: check for equivalence
If there are multiple copies of the same library on the classpath,
then ShadowedDeclarationsFilter becomes very slow because it
encounters many equal-signature declarations and thus has to resolve
a lot of calls in order to pick among them.

Having multiple copies of the same library on the classpath is
somewhat common in real-world projects. It occurs in the
JetBrains/intellij-kotlin project, for example. In that project,
ShadowedDeclarationsFilter ends up resolving thousands of calls,
accounting for around 80% of completion time when there are
many completion results (see KT-44276).

We can optimize ShadowedDeclarationsFilter by checking whether the
descriptors in an equal-signature group are structurally equivalent.
If they are, we can just pick one rather than running resolve.

Testing on a small project with Kotlin stdlib duplicated on the
classpath, this change reduces overhead in ShadowedDeclarationsFilter
from 1200 ms to 20 ms when running completion on the prefix 'a'.
End-to-end completion time is cut in half.

Test: JvmBasicCompletionTestGenerated.Common.Shadowing
2021-07-07 16:51:43 +02:00
Andrei Klunnyi
decfcd28d2 KT-39398 Wrong import of unrelated object member is suggested for receiver
Receiver of a function call '<receiver>.foo()' (where receiver is a
class/object/alias name) might be specified incorrectly - corresponding
[companion] object might not be declared.

Before this commit '<receiver>' was considered to be undefined (null).
As a consequence, import suggestion included all 'foo()' functions from
the search scope.

Now as a value of '<receiver>' we set class/object/alias itself
resulting in an empty import suggestion list.
See org/jetbrains/kotlin/idea/util/CallType.kt:307
(#extractReceiverTypeFrom(descriptor: ClassDescriptor)).
2021-07-07 16:51:43 +02:00
Nikita Bobko
365821ae54 2/2 Extract code which is required for :kotlin-scripting-ide-services from ide-common into seprate module
Extract the code and keep it in Kotlin repo. See previous preparation commit as well
2021-07-07 16:51:43 +02:00
Nikita Bobko
cf3f35e1c8 1/2 Preparation commit: move ide-common files which are required for scripting to separate directory
This commit is needed to preserve git history
2021-07-07 16:51:43 +02:00
Yahor Berdnikau
7789054547 Migrate repo to use JVM toolchains Gradle feature.
^KT-46972 Fixed
2021-07-05 14:11:12 +00:00
Ilya Muradyan
8be5f009f1 [REPL] Fix completion for function arguments 2021-06-06 09:00:52 +03:00
Ilya Muradyan
9412fe094b [REPL] Copy findLabelAndCall to scripting-ide-services to fix problems with embeddable artifact 2021-05-19 18:32:50 +03:00
Ilya Chernikov
d365d7c784 Fix IR compilation for empty script
#KT-46646 fixed
2021-05-17 20:15:14 +03:00
Dmitriy Novozhilov
e5b7cf23d6 Drop min functions from addToStdlib.kt 2021-05-14 14:30:20 +03:00
Ilya Kirillov
ca320f2f8d FIR IDE: add this labels to keyword completion 2021-05-12 21:40:20 +03:00
Ilya Muradyan
e9af2849ef Add Kotlin DeprecationLevel into the REPL completion 2021-05-07 19:56:21 +03:00
Ilya Muradyan
b771f9eea4 [REPL] Add completion for the call named parameters 2021-05-04 04:40:00 +03:00
Mikhail Zarechenskiy
f8efe3b5df Make function open to overrie it IDE specific part
Namely, this function is overrided in 211 & 212 platforms, see ScriptDefinitionsManager
2021-04-21 20:00:22 +03:00
Vladimir Dolzhenko
590a8d088d Refine locking to avoid dead lock
#KT-46215 Fixed
2021-04-21 11:01:12 +00:00
Vladimir Dolzhenko
613eda5016 Fix PackageFragmentProvider#isEmpty(FqName) for REPL 2021-04-09 21:06:32 +03:00
Abduqodiri Qurbonzoda
40d1849f33 Migrate compiler, idea and others to new case conversion api 2021-04-08 03:22:02 +03:00
Ilya Muradyan
d40ada5d07 [REPL] Fix syntax errors analysis and incompleteness detection 2021-03-29 18:36:49 +03:00
Ilya Chernikov
bcd7bc5fd7 Fix arguments processing with scriting with old backend by default 2021-03-24 21:26:57 +01:00
Ilya Chernikov
3e458a1efb FIR: Add IncrementalPackagePartsProvider usage in cli...
also refactor IncrementalPackagePartsProvider and parents to simplify
usage
2021-03-24 21:24:18 +01:00
Ilya Muradyan
14d386223b [REPL] Fix unresolved imports caching
Before this fix, if some imports were not resolved during compilation,
this result had been saved in caches, and this import couldn't been
resolved during following compilations even if it was added to the
module dependencies. This commit adds special handling of resolution
caches for the REPL compiler.
2021-03-24 13:35:33 +03:00
Ilya Muradyan
ae5fefce51 [REPL] Fix performance problem
Configuration updating was done incorrectly,
and it led to performance degradation.
2021-03-24 13:35:33 +03:00
Ilya Chernikov
7d07010785 Fix handling of lambdas in top-level destructuring declarations 2021-03-11 15:50:32 +01:00
Ilya Chernikov
10567d9a37 [minor] fix scripting test dependencies 2021-03-11 15:50:31 +01:00
Ilya Chernikov
ef01411d20 [minor] fix script util tests 2021-03-11 15:50:30 +01:00
Ilya Chernikov
375441832e Implement REPL support in IR scripting 2021-03-11 15:50:30 +01:00
Ilya Chernikov
e9da385f7c Implement property for passing argumens to isolated script compiler 2021-03-11 15:50:06 +01:00
Ilya Chernikov
43d7536a28 Protect scripts compilation from passing -Xuse-ir via configuration
as well as other options that require changes in the compilation setup
before compiler options from the configuration could be processed
2021-03-11 15:50:06 +01:00
Ilya Chernikov
bac6a7346e Extend GeneratorExtensions with previous script, implemt it for JS REPL
also refactor JS REPL for better compatibility with the generic
REPL/scripting infrastructure
2021-03-11 15:50:01 +01:00
Ilya Chernikov
4dc228a0a3 Implement proper call to the base class ctor in ir script lowering 2021-03-11 15:49:46 +01:00
Ilya Chernikov
4c6b5ff0b8 Implement IR backend support in scripting tests, enable for some tests 2021-03-11 15:49:44 +01:00
Alexander Udalov
566f97ae3e JVM IR: remove dependency of 'backend.jvm' on 'psi2ir', 'ir.serialization.jvm'
Add a new module 'backend.jvm.entrypoint' which depends on psi2ir and
contains code that runs psi2ir + JVM IR backend with serialization
implementations.

Hopefully this will allow to compile these modules in parallel and
reduce the build time.
2021-03-05 20:46:33 +01:00
Dmitry Savvinov
42345b9c49 Minor: use more clear and specific naming for LazyClassContext.typeChecker (relevant for MPP with type refinement) 2021-02-26 12:37:02 +03:00
Alexander Udalov
addabae8d2 IR: move frontend-dependent code into implementations in psi2ir 2021-02-24 19:07:38 +01:00