Commit Graph

128 Commits

Author SHA1 Message Date
Dmitrii Gridin 5c71015b09 [LC] implement isRecord for classes
Java world should better understand our classes with JvmRecord annotation

^KT-62357
2024-01-04 16:32:10 +00:00
Dmitrii Gridin d88249bda7 [Analysis API decompiler] materialize delegate declarations in stubs
We should materialize delegated declarations to process callables
in scopes correctly. Standalone mode works the same way as it
deserialize directly into FIR.
Another solution is to rework proto and stub serializer/deserializer to
restore FirFields like `$$delegate_0` correctly to work with
`FirDelegatedMemberScope`

^KT-62896 Fixed
^KT-64584 Fixed
2023-12-28 08:48:08 +00:00
Pavel Kirpichenkov 5729fab8c4 Fix deprecation warning
KTIJ-27752
2023-11-21 18:43:06 +00:00
Pavel Kirpichenkov 645e4af8b1 [IDE] Move KotlinJavaScriptMetaFileDecompiler to kotlin.git
KTIJ-27752
2023-11-21 18:43:06 +00:00
Pavel Kirpichenkov b41c4bc4c1 [IDE] create KotlinLabelProviderService on request
getServiceIfCreated doesn't create a service instance if id wasn't
created before. There are no other service requests for
KotlinLabelProviderService, so it was not used for file types.

KTIJ-27755
2023-11-21 18:43:06 +00:00
Pavel Kirpichenkov cf849835ba [K2, IDE] Don't filter declarations from built-ins in K2 decompiler
Intercept decompiler calls to process files that belong to classpath
builtins from K2 IDE differently. Their content won't be filtered w.r.t.
JVM logic during decompilation.

Split stub versions for .kotlin_builtins with K1 and K2 IDE.

K2 currently uses a single shared symbol provider for builtins of all
platforms. KotlinBuiltInDecompiler filters out duplicated declarations
contained in JVM classfiles as required for K1. For K2 this logic
doesn't fit: non-JVM modules (common, in particular) rely on
.kotlin_builtins, because kotlin-stdlib-common doesn't contain
.kotlin_builtins or .knm files for some of the built-in declarations
(e.g., kotlin.Unit). IDE has to restore the missing declarations using
built-ins from classloader. Filtering declarations from there using K1
logic breaks resolution of these declarations inside common modules in
IDE. The change shouldn't affect JVM modules as are able to resolve
all builtin symbols from the standard library before falling back to
built-ins.

KT-61757
2023-11-15 18:04:58 +00:00
Ilya Kirillov 5f5daa0e06 [Decompiler] rename :analysis:decompiled:native -> :analysis:decompiled:decompiler-native
to avoid possible name clashes between different
Gradle subprojects with the same name.

see https://github.com/gradle/gradle/issues/16986
2023-11-10 06:41:03 +00:00
Ilya Kirillov 063d73fa73 [Analysis] migrate analysis modules to use cliArgument helper instead of hardcoded CLI argument names
^KT-63294
2023-11-08 17:32:48 +00:00
Pavel Kirpichenkov 237f90d289 [stubs] Move KlibMetaFileType.STUB_VERSION to KotlinStubVersions
Track changes in K/N stubs directly instead of using the hack with
KlibMetaFileType.STUB_VERSION + KotlinStubVersions.BUILTIN_STUB_VERSION.
Changes in built-in stubs might or might not affect .knm stubs and
should be tracked independently.

The used offset constant for migration is the sum of the offsets from
KlibMetaFileType and KotlinStubVersions.BUILTIN_STUB_VERSION.

KTIJ-26761
KTIJ-26961
2023-11-02 10:28:37 +00:00
Pavel Kirpichenkov e6b2230d51 [minor] remove duplicated import 2023-11-02 10:28:37 +00:00
Pavel Kirpichenkov 2d10877fda [refactoring] extract base class for annotation loaders
Annotation loaders for descriptors (AnnotationAndConstantLoaderImpl) and
stubs (AnnotationLoaderForStubBuilderImpl) share the loading logic until
mapping ProtoBuf.Annotations to output values. The shared logic has been
extracted to the base class.

KTIJ-26761
KTIJ-26961
2023-11-02 10:28:37 +00:00
Pavel Kirpichenkov 30d45039fb [decompiler] Fix property and receiver annotations loading for stubs
Add annotation loading for property backing field, property delegate and
extension receiver to AnnotationLoaderForStubBuilderImpl. Use logic from
AnnotationAndConstantLoaderImpl.

AnnotationLoaderForStubBuilderImpl is used by KotlinMetadataDecompiler,
K2KlibMetadataDecompiler and KotlinJavaScriptMetaFileDecompiler. Stub
versions for built-ins (affects metadata and K/N decompilers) and JS
are bumped.

KTIJ-26761
KTIJ-26961
2023-11-02 10:28:37 +00:00
Mikhail Glukhikh d42ae35624 K2: support DELEGATION member kind for properties #KT-62581 Fixed 2023-10-25 20:19:39 +00:00
Dmitriy Novozhilov 704e2ef5c5 Suppress K2 specific warnings in the codebase
^KT-62472
2023-10-18 07:59:27 +00:00
Nikolay Lunyak ec9cb8beb6 [FIR] Rename JvmNames -> JvmStandardClassIds
This is more consistent with the code of
the common compiler checkers.

It would be nice to refactor the contents
of this object further, but it's out
of scope of the current branch.

^KT-54596
2023-09-19 22:14:09 +00:00
Vladimir Dolzhenko d8c80b0270 Fix parameters matching for suspend functions
#KT-61894 Fixed
2023-09-13 11:59:02 +00:00
Alexander.Likhachev 6eaccc997f [Build] Fix the typo junit jupyter -> jupiter 2023-09-06 22:47:34 +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
Dmitrii Gridin bd10ee10fe [psi] avoid usage of SAFE_IDENTIFIER_FOR_NO_NAME
This name leads to inconsistency between FqName from stub and
FqName from ClassId.
The first one is `no_name_in_PSI_3d19d79d_1ba9_4cd0_b7f5_b46aa3cd5d40`
but the second one is `<no name provided>`.
We can't just replace SAFE_IDENTIFIER_FOR_NO_NAME to NO_NAME_PROVIDED
due to many places with unsafe logic inside type mapping.

^KTIJ-26848 Fixed
2023-09-05 12:58:50 +00:00
Pavel Kirpichenkov cf98fb5612 [Tests] Add .knm stub consistency test
The test compares stub trees built from .knm files directly and from
the decompiled text. Test data for .class decompiler is reused,
JVM-specific cases are ignored

KT-61354
2023-09-05 09:36:25 +00:00
Ilya Kirillov 103ebb0ab4 [kotlin] fix AssertionError: Alien file! in IJ test
We should not cache `VirtualFile` per-application
2023-08-31 08:55:17 +00:00
Ilya Kirillov 714cb67254 [decompiler] add tests for generated psi text by builtin decompiler 2023-08-30 14:45:15 +00:00
Ilya Kirillov 9ea344fe76 [decompiler] fix ambiguities to builtin members resolve in K2 IDE
If a user has multiple kotlin-stdlib libraries in a project, all those stdlib libraries will contain builtins
which will result in resolution ambiguities.

To prevent such kind of ambiguities inside LLFirDependenciesSymbolProvider,
callables are grouped by facade class name.
Only matching callables from the first facade are used.

Facade is a Kotlin/JVM-term so right now it works only for JVM targets.
Builtins are also used in JVM, so the current solution is to have a Facade name also for builtins.

^KTIJ-26760
2023-08-30 14:45:14 +00:00
Ilya Kirillov e8db349f24 [decompiler] extract builtin VirtualFile creation to a separate service for further reuse
^KTIJ-26760
2023-08-30 14:45:14 +00:00
Pavel Kirpichenkov dc3641f79d Limit visibility of internal K/N decompiler classes
KTIJ-26526
2023-08-23 07:46:29 +00:00
Pavel Kirpichenkov af94b241ec Extract K/N decompiler related files into a separate module
KTIJ-26526
2023-08-23 07:46:29 +00:00
Pavel Kirpichenkov d7356afe1e Move K/N decompilers and stub builders to kotlin.git
KTIJ-26526
2023-08-23 07:46:29 +00:00
Dmitrii Gridin e05cb49671 [SLC] invalidate local class members cache on any file changes
We should track the containing file modifications to avoid PIEAE by
changes in members

^KTIJ-26661 Fixed
2023-08-16 10:22:13 +00:00
Anna Kozlova b725cd3e6c [light classes] match property with getter or setter only
^ KTIJ-26536
2023-08-09 07:09:35 +00:00
Dmitriy Novozhilov cc2bc5e8b1 [FIR2IR] Reuse IR fake overrides for FIR fake overrides for all MPP modules
^KT-58229 Fixed
2023-08-03 10:02:57 +00:00
Ilya Kirillov 62e856956c [stub builder] generate K2 test output for the testsuite where classfiles are generated by the K2 compiler
The result of k1/k2 should be similar here, the differences should be fixed by KT-60764
2023-07-31 15:38:07 +00:00
Ilya Kirillov ce990853da [stub builder] generate tests for the testsuite where the classfiles generated by the K2 compiler
The result of k1/k2 should be similar here, the differences should be fixed by KT-60764
2023-07-31 15:38:07 +00:00
Ilya Kirillov 419c0c83e3 [stub builder] introduce a separate testsuite where classfiles generated by the K2 compiler
The result of k1/k2 should be similar here, the differences should be fixed by KT-60764
2023-07-31 15:38:07 +00:00
Mikhail Zarechenskiy 3cdb28e95f Remove last usage of ModelBranch API
It was decided to remove ModelBranch completely from Intellij API, see IDEA-309887
2023-07-17 13:52:53 +00:00
Vladimir Dolzhenko c1b70a7303 Move under debug log message when nested class is not found
To avoid freezes and useless reporting calculations

#KTIJ-25465 Fixed


Merge-request: KT-MR-10996
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-07-08 07:18:09 +00:00
Vladimir Dolzhenko 3c8c20f8d2 Do not do unnecessary writeBooleanAttribute
Merge-request: KT-MR-10945
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-07-05 09:27:04 +00:00
Yan Zhulanow df28bd1d79 [Stubs] Pass proper container source to stub-based FIR declarations
Backend, which is used by the expression evaluator, relies on the class
name in 'FacadeClassSource'. To pass the correct JVM class name,
stubs for top-level functions and properties got the 'origin'.
2023-07-04 11:17:39 +00:00
Ilya Kirillov 0a1f27e43a [LC] remove duplicating checkIsMangled function 2023-06-30 13:43:30 +00:00
Anna Kozlova 137f8b7c70 [decompiler] ensure names starting with numbers are escaped
^ KTIJ-25985
2023-06-23 11:17:46 +00:00
Anna Kozlova 3fc334d2eb [decompiler] additional logging for ByDescriptorIndexer 2023-06-15 15:47:17 +00:00
Ilya Kirillov 78f09409b7 [Analysis API] move ClsKotlinBinaryClassCache/FileAttributeService service registration to StandaloneProjectFactory 2023-06-02 09:16:47 +00:00
Anna Kozlova b8e868caf6 [decompiler] navigate to containing class for fake object descriptors
^ KTIJ-25661
2023-05-30 17:23:54 +00:00
Kirill Rakhman 8f447e5b78 Revert "[AA] Deserialize reference to typealias from stubs as fully expanded"
This reverts commit 3c22b1ce53.

#KT-58335
#KT-58786
2023-05-19 11:50:40 +00:00
Kirill Rakhman 3c22b1ce53 [AA] Deserialize reference to typealias from stubs as fully expanded
#KT-58335
2023-05-16 09:20:57 +00:00
Anna Kozlova 799210262d [decompiler] skip return type check for src functions without return type 2023-05-04 21:31:43 +00:00
Anna Kozlova 8106505166 [decompiler] get rid of indexers in decompiled text 2023-05-02 10:30:35 +00:00
Anna Kozlova 956294821b [psi] don't load text for compiled code
use stubs when possible, when stub doesn't contain anything,
decompiled text won't contain it either,
no sense to load
2023-05-02 10:30:34 +00:00
Anna Kozlova dead2c8be8 [LL] stubBased provider: deserialize fir from stubs build from decompiled text
if the compiled code is opened in the editor,
1. it's decompiled
2. stub is build over decompiled text
3. this stub replaces the stub built from classes.

This process leads to missed information in resulted FIR, e.g. half correct classId.
On the other side, this FIR is used only for this opened editor.
2023-04-27 11:37:29 +00:00
Anna Kozlova a41f7dc25d [cls] save parameter name for functional types in stub
to make it available for deserialized Fir
2023-04-27 11:37:28 +00:00
Anna Kozlova d59d66e876 [AA, LL] use stubs to build deserialized Fir elements in IDE
^KTIJ-24638

Notice on `DebugSymbolRenderer`:
stub based deserializer sets source directly,
but it's available in IDE mode only.
Thus, standalone and IDE tests have different results.
In order to avoid this, sources for compiled code are explicitly ignored

Notice on distinct callables:
for a file which belong to multiple libraries, decompiled code would be build per library.
In order to avoid ambiguity errors for members in that file,
we need to distinct provided elements by origins
failed test from IJ repo:
 FirReferenceResolveWithCrossLibTestGenerated#testSetWithTypeParameters
2023-04-27 11:37:28 +00:00