Commit Graph

528 Commits

Author SHA1 Message Date
Ilya Chernikov a47ee44e65 Scripting: refactor test infrastructure - add missing stderr handling 2023-11-10 17:24:12 +00:00
Ilya Chernikov 02dc3c4ddb K2 Scripting: add annotation resolving for scripts
#KT-62400 fixed
2023-11-03 21:54:23 +00:00
Ilya Chernikov 31f9e9e7a8 K2 Scripting: implement basic metadata serialization support
#KT-62305 fixed
NB: kotlin reflection do not see script class constructor after
this change, and it's ok, since the fact that the script is compiled
into a class is an implementation detail.
If needed, java reflection could be used to access the constructor.
2023-11-03 21:54:23 +00:00
Dmitrii Gridin f66bb1bcb7 [FIR] FirScriptConfiguratorExtensionImpl: avoid creation of dummy elements
This will reduce memory and CPU consumption

^KT-61186
2023-10-25 19:00:20 +02:00
Dmitrii Gridin 0b45c6ce23 [FIR] FirScriptConfiguratorExtensionImpl: provide source for script parameters
We need this source to be able to find the parent declaration

^KT-62693 Fixed
2023-10-20 09:27:21 +00:00
Ilya Chernikov 0aff76141b Fix comment on testScriptWithoutParams 2023-09-19 15:46:30 +00:00
Mikhail Glukhikh 45a12e0cfd LV 2.0: fix JvmIdeServicesTest.testDependency by allowing unstable deps 2023-09-19 15:46:29 +00:00
Yahor Berdnikau e71f86ee98 [repo] Fix configuration cache issues in scripting-compiler project 2023-09-19 15:46:28 +00:00
Ilya Chernikov 8a10070772 LV20 update scripting test mute logic for K2
after switching to LV20 by default
2023-09-19 15:46:28 +00:00
Ilya Chernikov 5b64741609 LV20: unmute scripting test
the test doesn't fail anymore, but should
see #KT-60452
2023-09-19 15:46:28 +00:00
Ilya Chernikov c639febf36 LV20: remove redundant scripting plugin registration
related to #KT-61452
2023-09-19 15:46:28 +00:00
Ilya Chernikov 7cbe728e35 LV20: mute scripting test testLazyScriptDefinitionDiscovery 2023-09-19 15:46:28 +00:00
Ilya Chernikov e3dae559d0 LV20: refactor K2 scripting tests - rename tasks 2023-09-19 15:46:27 +00:00
Ilya Chernikov 2c4cca5785 LV20: fix K2 scripting tests - plugin registration 2023-09-19 15:46:27 +00:00
Kirill Rakhman e0b5fa1de8 [FIR] Add opt-in for FirExpression.coneTypeOrNull in scripting
#KT-61367
2023-09-14 10:03:02 +00:00
Alexander.Likhachev 53fde520d5 [Build] Add jUnit dependencies in testApiJUnit5 to the implementation configuration
Adding these dependencies to the `api` configuration pollutes classpath for each dependant modules even if it doesn't need them. Instead, the dependencies should be declared more granularly if they're required
#KTI-1349 In Progress
2023-09-06 22:47:34 +00:00
Alexander.Likhachev 357d12fc8e [Build] Move JUnit dependencies into the version catalog
The `kotlin-test` dependencies are left untouched as changing them affects publications, thus these versions are independent from the used inside our build
#KTI-1349 In Progress
2023-09-06 22:47:33 +00:00
Mikhail Glukhikh f9c7a88175 Add -Xuse-fir-lt=false to some scripting tests
make them compatible with K2
2023-08-25 08:57:53 +00:00
Kirill Rakhman 8d7c5b375e [FIR] Replace usages of FirExpression.typeRef with coneTypeOrNull
#KT-59855 Fixed
2023-08-24 07:54:57 +00:00
Kirill Rakhman d0cc86f52c [Tests] Update test data after changes to FIR diagnostic messages 2023-08-21 16:28:48 +00:00
Dmitrii Gridin 35b0cd65e9 [FIR] PsiRawFirBuilder: add missing script configurator
PsiRawFirBuilder#visitScript didn't work because it didn't
have a configurator
Now FirScriptConfiguratorExtension split into two parts:
* File
* Script

^KT-60728
2023-08-02 16:50:45 +00:00
Andrei Klunnyi 419381af7f KT-60749 Scripting: default definition as a fallback
This commit effectively reverts changes made in the scope of KT-60193,
namely c9eebffb and 2d50bd68.

^KT-60749 fixed
2023-07-28 15:46:45 +00:00
Ilya Chernikov 895a811b47 K2 Scripting: fix capturing from the imported scripts 2023-07-26 08:49:27 +00:00
Ilya Chernikov 020a590df7 K2 Scripting: fix order of arguments processing
and base class handling:
Since in K2 we do not distinguish between script arguments taken from
the base class and provided properties, we need this extra functionality
to preserve the argument order of K1 scripts.
This is a temporary measure, since we're going to deprecate base class
usage at some point (KT-60449), so the relevant constructor arguments
should disappear too.
2023-07-26 08:49:27 +00:00
Ilya Chernikov 96bde033e1 K2 Scripting: add support for imported scripts 2023-07-26 08:49:26 +00:00
Ilya Chernikov d24fc3b581 K2 Scripting: add support for result field 2023-07-26 08:49:26 +00:00
Ilya Chernikov 480ea80fc4 Enable K2 scripting tests 2023-07-26 08:49:26 +00:00
Ilya Chernikov 0d7a5c6b1b Scripting: fix string script source location
fixes proper script definition discovery for expressions and other
scripts created from a string.
2023-07-26 08:49:26 +00:00
Dmitriy Novozhilov 8ad202eb8b [IR] Remove descriptor-related methods from SymbolTable
Replace them with calls to SymbolTableExtension
2023-07-17 21:02:39 +00:00
Andrei Klunnyi 2d50bd6857 KT-60193 scripts: configuration discovery might fail silently (2)
This commit covers one more case similar to what is described
in the previous commit of the series (c9eebffb).
2023-07-13 13:31:52 +02:00
Andrei Klunnyi 527d20c7be KT-60171 K2-scripting: CLI specific providers are used in IDE context
^KT-60171 fixed

Merge-request: KT-MR-10987
Merged-by: Andrei Klunnyi <andrei.klunnyi@jetbrains.com>
2023-07-10 11:03:11 +00:00
Andrei Klunnyi c9eebffbfa KT-60193 K2 scripts: configuration discovery might fail silently
Due to possible data races configuration discovery might fail. So far,
it happened silently and we used so-called default one. This
configuration is unaware of specific implicit imports, receivers, base
class, etc. Hence, broken highlighting and navigation.

This commit introduces the following changes:
1. Having default configuration for building `FirScript` is no longer an
   option. Missing configuration means error reported via exception.
2. Every configuration usage is now logged in DEBUG mode.
   Troubleshooting becomes easier.

^KT-60193 fixed
2023-07-07 14:50:35 +02:00
Ilya Chernikov 02e2438d37 K2 Scripting: fix script this receiver handling in IR
also fix accessor lowering
2023-07-05 19:46:04 +00:00
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 8653992ffc K2 CLI: wrap module name into angle brackets
This is not a user-visible change, so no issue is created and no tests
are added.

K1 uses angle brackets, and it will be very convenient to have the same
module names in K1 and K2, in particular to compare IR dumps where
almost everything is the same (up to a certain point) except the module
name.
2023-06-21 14:16:42 +00:00
Ilya Chernikov ae10eebc84 minor: scripting: fix processing of externally provided options 2023-06-20 16:38:32 +00:00
Ilya Chernikov 30131e289f minor: improve tests failure reporting 2023-06-20 16:38:32 +00:00
Ilya Chernikov 7db9f9c3ae minor: script some test cases to speedup parallel execution 2023-06-20 16:38:32 +00:00
Nikolay Lunyak 23f87eda1f [FIR] KT-57803: Report the error message for light tree
The renaming prevents the JVM clash.

^KT-57803 Fixed
2023-06-06 07:43:37 +00:00
Ilya Kirillov 78f09409b7 [Analysis API] move ClsKotlinBinaryClassCache/FileAttributeService service registration to StandaloneProjectFactory 2023-06-02 09:16:47 +00:00
Alexander Udalov 60016d3e5b Remove obsolete compiler flag -Xuse-ir 2023-05-30 14:46:09 +00:00
Alexander Udalov bb4bb58453 Remove tests on -Xuse-ir compiler flag
This flag is going to be removed because old backend is not supported
anymore, therefore there's no need to test it.
2023-05-30 14:46:09 +00:00
Andrei Klunnyi 6535278bd3 [KT-58817] Implicit receiver for code completion
Prior to this commit code completion for .kts files was supported only
partially. Script has an implicit receiver - base class representing a
script itself, the point where its basic API resides. The knowledge of
this receiver was missing.

There are at least two context where this knowledge is crucial:
1. Code highlighting (worked fine)
2. Code completion (failed)

`FirScriptConfiguratorExtension` is responsible for filling
`FirScriptBuilder` with base script class (in addition to other
properties). See usages of [1] in its implementation.

The thing is that resolution during the completion works a bit
different. Instead of converting the entire `KtFile` it's interested
in `KtScript` only. See usages of [2].
`RawFirBuilder.Visitor.visitScript` is where implicit receivers were
missing.

Code completion and inspections applied to `.kts` files already have
`FirScript` and don't require its full reconstruction with expensive
`FirScriptConfiguratorExtension`. `RawFirBuilder.Visitor` was modified
to support sometimes already existing `FirElement`.

----------------------------------------------------------------
[1]: ScriptCompilationConfiguration.baseClass
[2]: RawFirBuilder.Visitor.convertScript
2023-05-26 12:55:01 +00:00
Andrei Klunnyi 2a1d4a42ae [KT-58817] Implicit import issues cannot be reported
To be reported with [1] imports require source. It was missing for
implicit script imports.

`FirScriptConfiguratorExtensionImpl` was extended and now adds fake
source elements (users don't see imports in the source code).

Since diagnostics for implicit import statements are meaningless for
IDE, they are suppressed in `LLFirDiagnosticReporter`.

----------------------------------------------------------------------
[1]: DiagnosticReporter.reportOn()
2023-05-26 12:55:00 +00:00
Andrei Klunnyi 28ff94533a [KT-58817] Add script-related extensions for FIR session
The following two registrars were missing:
- FirScriptingCompilerExtensionIdeRegistrar
- FirScriptingSamWithReceiverExtensionRegistrar

`FirScriptingCompilerExtensionIdeRegistrar` was introduced as a copy of
`FirScriptingCompilerExtensionRegistrar` adapted for usage from IDE.

`FirRegisteredPluginAnnotations` and `FirJvmTypeMapper` are mandatory at
`FirExtensionService.registerExtensions` and reported as missing at
runtime.
2023-05-26 12:55:00 +00:00
Andrei Klunnyi 1b8fd01969 [KT-58817] Star-imports are not handled
Default imports coming from script configuration can be of "star" type.
Prior to this commit they were effectively ignored due to a bug at FQN
assembly.

Before: org.gradle.dsl.* => org.gradle.dsl.
After: org.gradle.dsl.* => org.gradle.dsl
2023-05-26 12:55:00 +00:00
Vladimir Dolzhenko 4a1552e907 Use nameSequence instead of file extensions to reduce memory allocations
#KTIJ-25470
2023-05-17 12:45:19 +00:00
Vladimir Dolzhenko 8ad781987e Optimize file extensions usage
#KTIJ-25470

Merge-request: KT-MR-10135
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-05-15 13:59:24 +00:00
Roman Golyshev d4cffb8a5a [213] Switch to 213 platform
KTI-1114
2023-04-21 13:19:04 +00:00
Nikolay Krasko 57934a6870 Revert "Revert "[K2/N] KT-57026, KT-57208: Adjust Native & JS test infrastructures for MPP testing""
This reverts commit c0c692844e.
2023-03-10 14:24:49 +01:00