Commit Graph

64 Commits

Author SHA1 Message Date
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
Dmitry Gridin 438faf478b [lc] decompiled: extract common part to KotlinDeclarationInCompiledFileSearcher
^KT-53934
2022-09-15 09:27:53 +00:00
Dmitry Gridin 0f4f933835 [lc] decompiled: fix navigation to primary constructor
^KT-53934
^KTIJ-22755
2022-09-15 09:27:52 +00:00
Dmitry Gridin b05eb62d9d [lc] decompiled: support stub search for properties
^KT-53934
2022-09-15 09:27:52 +00:00
Dmitry Gridin 7ec55f885d [lc] decompiled: fix and add new heuristics for stub-only search
support members and constructors

^KT-53934
2022-09-15 09:27:52 +00:00
Dmitry Gridin 5f2098d572 [lc] decompiled: LightMemberOriginForCompiledElement: cleanup code
^KT-53934
2022-09-15 09:27:52 +00:00
Dmitry Gridin d13f2af6ec [lc] decompiled: make isEquivalentTo lightweight
^KT-53934 Fixed
2022-09-15 09:27:51 +00:00
Dmitry Gridin 51fd2af6fd [lc] decompiled: update debug info
^KTIJ-22722
2022-09-10 21:37:47 +02:00
Vladimir Sukharev c8864369fd Use main class as test generator name
Merge-request: KT-MR-7031
Merged-by: Vladimir Sukharev <Vladimir.Sukharev@jetbrains.com>
2022-09-09 12:51:18 +00:00
Dmitry Gridin feb31b79de [lc] support decompiled facade only for .class
we have support only for KtClsFile (see decompiled light classes) so kotlin_builtins and kotlin_metadata should be ignored

^KT-53543
2022-08-29 11:51:43 +00:00
Dmitry Gridin 0ea041a1eb [lc] move SymbolLightClassForDecompiledFacade to common decompiled part
^KT-53543
2022-08-29 11:51:42 +00:00
Nikita Bobko 70ed76e0bd Drop unused ':dist' dependency in some tests
Review: https://jetbrains.team/p/kt/reviews/6753

This commit doesn't fix any issue except for "cleanup". If you find a
mistake in this commit feel free to revert part of it/the whole commit

I checked every module where I drop ':dist' dependency. Tests still pass
in those modules
2022-08-22 15:42:34 +02:00
Ilya Kirillov 7441388f9d [Decompiled LC] restore missed ^IDEA-286315 fix during Decompiled LC migration to the kotlin repo
^IDEA-297478 fixed
2022-08-18 16:10:51 +00:00
Dmitry Gridin 4ceb170917 regenerate tests 2022-08-05 14:12:41 +02:00
Dmitry Gridin 1708b4fe48 [light classes] move light-classes-base module to analysis
^KT-53097
2022-08-01 13:56:34 +00:00
Dmitry Gridin 2ff1c21c8c [light classes] replace light class dependency from analysis.decompiled.light-classes-for-decompiled to light-classes-base
^KT-53097
2022-07-19 15:42:00 +00:00
Dmitry Gridin a8b2d70824 [light classes] replace light class dependency from analysis.decompiled.light-classes-for-decompiled-fe10 to light-classes-base
^KT-53097
2022-07-19 15:41:58 +00:00
Dmitry Gridin f1c019d805 [light classes] replace light class dependency from analysis.decompiled.decompiler-to-psi to light-classes-base
^KT-53097
2022-07-19 15:41:57 +00:00
Ilya Kirillov 77758d1552 [Analysis] do not reregister services in AbstractStubBuilderTest 2022-07-01 11:33:21 +02:00
Ilya Kirillov 271ecfbd68 [Analysis] Try to fix randomly failing tests because of unregistered FileAttributeService
It should be unregistered with the application by ApplicationEnvironmentDisposer
which is registered in :compiler:tests-common-new
2022-07-01 11:33:21 +02:00
Dmitry Gridin f10c5c28a5 Revert "Revert "[light classes] drop old light classes and backend: iteration #1""
This reverts commit 57de064251.
2022-06-28 17:57:29 +02:00
Dmitry Gridin 57de064251 Revert "[light classes] drop old light classes and backend: iteration #1"
This reverts commit 3cb2df9360.
2022-06-28 13:52:11 +02:00
Dmitry Gridin 3cb2df9360 [light classes] drop old light classes and backend: iteration #1
drop clsDelegate and related

^KT-48773
2022-06-28 11:44:38 +00:00
Ilya Kirillov ba797fa1b4 [stubs] fix cls stubs for declarations with context receivers
^KTIJ-21243 fixed
2022-06-20 19:10:36 +02:00
Ilya Kirillov a47880a98b [stubs] add test which checks consistency between cls and decompiled stubs 2022-06-20 19:09:44 +02:00
Ilya Kirillov 314d9b9477 [analysis] move DecompiledPsiDeclarationProvider to symbol light classes module to avoid circular dependencies 2022-05-30 17:48:34 +02:00
Jinseong Jeon 55e24451a4 AA: migrate PSI declaration provider (from IJ) 2022-05-30 17:48:34 +02:00
Vladimir Dolzhenko efd5beb49b IJ file type optimizations based on extension
#KTIJ-21668

Merge-request: KT-MR-6288
Merged-by: Vladimir Dolzhenko <Vladimir.Dolzhenko@jetbrains.com>
2022-05-17 14:46:00 +00:00
Mikhail Zarechenskiy 24220cbfb5 KotlinBinaryClassCache: restore missing fixes after merge to Kotlin repo
- Avoid lookups in branches: https://github.com/JetBrains/intellij-community/commit/c904c56bb4ac9764935aed09e2107636e2e5bb68
 - Don't fail during index of incorrect class files: https://github.com/JetBrains/intellij-community/commit/3af051e3d30e773d9dfe6cb388a42387b8636c6b

 ^KTIJ-21472 In Progress
 Also, this commit fixes projectLeak in Intellij Aggregator _LastInSuiteTest.testProjectLeak[Java Tests / 3]
2022-05-02 12:21:43 +00:00
Ilya Kirillov 34c855b450 [decompiler] add missing cache to annotation loader
it was missed during moving the code from intellij repository

^KTIJ-21613 fixed
2022-04-25 10:32:02 +02:00
Dmitry Timofeev 4e784eeb33 Create INTERSECTION_TYPE stubs for definitely non-nullable types
^KTIJ-20802 Fixed
2022-04-05 10:48:12 +00:00
Yan Zhulanow dd2afb558e Port stub-relating changes from 'master' of IntelliJ 2022-03-17 17:44:55 +09:00
Yan Zhulanow c334a44e02 Preserve synthetic enum methods in stub-based 'ClsClassImpl'
'ClsClassImpl' instances created by the platform contain synthetic
enum methods (added by 'ClassInnerStuffCache.calcMethods()'). Such
convention is common in IntelliJ (see KT-36095 and
'9a8b345adaded83fe13980a28db5d9f9acc7450d' in the IntelliJ repository).

This commit makes Kotlin's stub-based classes consistent with the
convention. Instead, a filter is added in place of 'ClsClassImpl' usage.

See also the following commits:
- 7c86911f44
- 43468c6d55
2022-03-14 17:53:55 +09:00
Yan Zhulanow fa4dadf9b7 Update KotlinClassInnerStuffCache implementation
'KotlinClassInnerStuffCache' was copy-pasted from the platform's
'ClassInnerStuffCache' several years ago. After J2K and other changes,
it became quite dirty.

Besides cleaning things up, enum synthetic method handling have
significantly improved. Before, such methods were handled only in
'processDeclarationsInEnum', and 'getMethods()' didn't return them.
This led to inconsistent behavior and was reason for providing special
ad-hoc support in '1b6ded600518176b21cc308ed3e032ef8d04cc90'.
2022-03-14 17:53:55 +09:00