147 Commits

Author SHA1 Message Date
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
Anna Kozlova 96c15f6c71 [cls] include generated equals/hashCode/toString method in stubs
to avoid heavy computation of super functions
2023-04-27 11:37:27 +00:00
Anna Kozlova 7ee648a4f5 [cls] include annotation arguments in cls stubs
^ KTIJ-24666
this would allow to build fir based on stubs,
do not keep ProtoBuf in memory and
search in decompiled code by stubs
2023-04-26 21:43:15 +02:00
Anna Kozlova f0af7c4228 [cls] include property constant initializer in stubs
^KTIJ-24667
this would allow building FirElements from stubs
2023-04-26 21:43:15 +02:00
Anna Kozlova b558d5fc9c [cls] include default parameter value in stubs
this stub would allow building FirElement from stubs,
as well as search signatures in compiled code without loading decompiled text
2023-04-26 21:43:14 +02:00
Anna Kozlova 7021c079c6 [cls] include property accessors in cls stubs 2023-04-26 21:43:14 +02:00
Anna Kozlova 4fe239375f [cls] write contracts information to cls stubs
^ KTIJ-24665
this information would be used to create resolved FirElements from stubs,
so no ProtoBuf would be kept in memory
2023-04-25 08:34:18 +00:00
Egor Kulikov c46c922841 [ClsStubs] Add context receivers on function types 2023-04-20 18:57:51 +00:00
Anna Kozlova f810d435f4 [cls] write flexible type information to cls
^KTIJ-25172
this information would be used to create resolved FirElements from stubs,
so no ProtoBuf would be kept in memory
2023-04-14 18:12:48 +00:00
Jinseong Jeon 0ac3fae9ab LC: commonize facade for multi-file class 2023-03-29 18:51:03 +02:00
Dmitrii Gridin 7af78db2e1 [DLC] drop hard references to member declarations to reduce memory consumption
^KT-56613
2023-03-01 10:43:02 +00:00
Dmitrii Gridin 847b29ac15 [DLC] add missing identity checks to 'equals'
^KT-56613
2023-03-01 10:43:01 +00:00
Dmitrii Gridin 95455c9870 [DLC] add missing visitor methods
Some of our light classes have no correct parent (KT-56882),
so I temporarily disabled
AbstractSymbolLightClassesParentingTestBase for such cases
(previously decompiled light classes were not tested at all)

^KT-56613
^KT-56882
2023-03-01 10:43:01 +00:00
Dmitrii Gridin 5e18ebcd7e [DLC] cleanup code and drop some redundant constructions
^KT-56613
2023-03-01 10:42:58 +00:00
Dmitrii Gridin 007af1c547 [DLC] use library tracker instead of out of block tracker
^KT-56613
2023-03-01 10:42:58 +00:00
Roman Efremov d120d83d60 Fix navigation in IDE to synthetic methods in compiled Kotlin
For some synthetic methods from compiled Kotlin classes, it is
not possible to find the PsiElement, when navigating to declaration
in the IDE.

For other methods it works like this:
1. There is a SourceElement with a psi inside
2. Or for K1, the element is searched in the decompiled text
   (see ByDescriptorIndexer),
3. Or for K2, the element is searched by Stub taken from metadata
   (see FirDeserializedDeclarationSourceProvider)

However, these approaches do not apply to synthetic methods which have
no SourceElement and are not written into decompiled text and metadata.

These are methods values, valueOf, entries from enum and
copy, equals, hashCode, toString from data classes.

Therefore, it was decided to handle their cases separately
at the resolve stage.

Tests (in idea repository):
- org.jetbrains.kotlin.idea.resolve.ReferenceResolveWithLibTestGenerated#testDataClassSyntheticMethods
- org.jetbrains.kotlin.idea.resolve.ReferenceResolveWithLibTestGenerated#testEnumSyntheticMethods
- org.jetbrains.kotlin.idea.fir.resolve.FirReferenceResolveWithLibTestGenerated#testDataClassSyntheticMethods
- org.jetbrains.kotlin.idea.fir.resolve.FirReferenceResolveWithLibTestGenerated#testEnumSyntheticMethods

^KTIJ-24413 Fixed
2023-02-15 19:56:08 +00:00
Dmitrii Gridin 761553ea75 [LC] reduce memory consumption from SLC and DLC
The main change is drop `LightClassesLazyCreator`

KtLightClassForDecompiledDeclaration:
* fixed a few captured fields

^KT-56561 Fixed
2023-02-13 16:08:17 +00:00
Ivan Kochurkin e22359cc10 [FIR] Add MetadataSymbolProvider
Extract common code from K1 to MetadataUtil
2023-01-24 15:27:12 +00:00
Roman Efremov 878608b7b2 Don't add Enum.entries to scope if it can't be called
^KT-53929 Fixed
2023-01-23 12:53:06 +01:00
Mikhail Glukhikh 0c4a0360ac Deserialization/class reading: pass chosen JvmMetadataVersion whenever possible 2023-01-16 18:16:07 +01:00
Mikhail Glukhikh 89dd28226b BinaryVersion: introduce isCompatibleWithCurrentCompilerVersion 2023-01-16 18:12:55 +01:00
Alexander Udalov 3c4b5529af Update year to 2023 in COPYRIGHT_HEADER.txt
This commit is the result of changing the year to 2023 in
COPYRIGHT_HEADER.txt and running all `generate*` tasks in
`generators/build.gradle.kts`.
2023-01-02 22:52:15 +01:00
Vladimir Dolzhenko f9f0f561d7 Add ability to decompile multifile classes
A side effect of KotlinClassFileDecompiler#KotlinDecompiledFileViewProvider@factory
that multifile java classes like FilesKt__FilePathComponentsKt.class
becomes not visible with Kotlin plugin as file
jar://..../kotlin-stdlib.jar!/kotlin/io/FilesKt__FilePathComponentsKt.class
is considered as Kotlin internal compiled file and therefore no PsiFile
for this virtualFile

#KTIJ-912

Merge-request: KT-MR-8146
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2023-01-02 15:31:19 +00:00
Roman Efremov 25f65aff3a Replace getEntries with hardcoded PsiMethod in LC decompiled declaration
This adds NotNull annotation.

^KTIJ-23530 Fixed
2022-12-27 14:41:53 +00:00
Egor Kulikov 877e11419e Stub updates for RawFirBuilder
First step for KT-52615
2022-11-18 11:40:09 +01:00
Vladimir Dolzhenko 5dc2442872 Safe reporting PSI elements in KEWA 2022-11-03 17:27:11 +00:00
Johan Bay 9f3d8130db Remove unnecessary deprecation annotation
Private members on private companion objects have proper visibility
so there is no need for the @Deprecated annotation.

^KT-54539 Fixed
2022-10-25 14:03:11 +02:00
Ilya Kirillov 5a88f2088a [decompiler stubs] fix CCE in tests 2022-09-30 12:15:49 +02:00
Ilya Kirillov cd5f6d1207 [decompiler stubs] fix missing expect modifier on declarations 2022-09-30 12:15:48 +02:00
Jinseong Jeon c2daa26118 AA: use fully decompiled file when indexing built-ins 2022-09-17 16:43:10 +02:00
Dmitry Gridin 7013fa1864 [lc] decompiled: support stub search for top level callable
^KT-53934
2022-09-15 09:27:53 +00:00
Dmitry Gridin 9eb2672282 [lc] decompiled: improve stub search for fields
^KT-53934
2022-09-15 09:27:53 +00:00