Commit Graph

304 Commits

Author SHA1 Message Date
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 7c6870f8d2 [Analysis API Standalone] index .knm files in KotlinStaticDeclarationProvider
so `FirSymbolNamesProvider` can know about them

^KT-62910
2023-11-10 06:41:03 +00:00
Roman Golyshev 2f50267d3f KT-63096 [LL] Make KotlinStaticAnnotationsResolver more correct
By using `KotlinDeclarationProvider`, it can now check that the
annotation is actually present in the scope
2023-11-09 23:39:32 +00:00
Roman Golyshev a1155204c7 KT-63096 [LL] Remove KtModuleScopeProvider
It has no usages anymore
2023-11-09 23:39:32 +00:00
Jaebaek Seo e80f044847 K2: Update reference shortener to handle import alias
The existing reference shortener does not use import alias when it
shortens a symbol. Instead, it adds a new import directive for the
symbol that is already imported. This commit updates reference shortener
to let it reuse the existing import alias rather than adding a new one:

 1. When shortening a symbol, check whether the symbol is already
    imported.
 2. If it is already imported by an import alias, keep the symbol
    reference expression and the import alias as a string together in
    `ShortenCommand`.

The actual PSI update (shortening) based on the ShortenCommand is done
by IntelliJ.

^KTIJ-27205
2023-11-09 14:34:38 +00:00
Jinseong Jeon 4110a9971a AA: fix KtTypeProvider#getReceiverTypeForDoubleColonExpression
K1 version has used a wrong expression to retrieve the slice.
K2 version mishandled property access as a receiver.

^KT-63195 fixed
2023-11-08 16:18:21 +00:00
Anna Kozlova 205a125c5f [AA] implement KtFirSimpleNameReference.getImportAlias
^ KT-62980 fixed

Merge-request: KT-MR-12786
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-11-02 21:23:43 +00:00
Roman Golyshev 236a76f779 KT-62676 [AA] Small refactoring of AbstractReferenceShortener*Test 2023-11-01 09:45:40 +00:00
Roman Golyshev b0f15451fd KT-62676 [AA] Collect redundant this qualifiers in reference shortener
^KT-62676 Fixed
2023-11-01 09:45:40 +00:00
Roman Golyshev 4ca1f9d492 KT-62676 [AA] Introduce ShortenOptions class
This class should contain 'global' settings for reference shortening;
ATM it only contains the `removeThis` flag

In the future this setting might be merged together with
`ShortenStrategy` to be computed on per-element basis
2023-11-01 09:45:40 +00:00
Roman Golyshev adf7ee4535 KT-62676 [AA] Rename ShortenOption -> ShortenStrategy
`Option` is going to refer to more global settings of the
reference shortener (like shortening `this` or `Companion`
references)
2023-11-01 09:45:39 +00:00
Ilya Kirillov 1aa5cf031f [Analysis API FIR] fix "ConeClassLikeTypeImpl is not resolved to symbol for on-error type"
We should not expect builtins to be always available as they are taken from indecies.

For K1 and FIR Standalone implementations, the builtins are always available.

^KT-62010 fixed
2023-10-31 12:24:16 +00:00
Roman Golyshev ef31eeae52 KTIJ-26423 [AA] Get rid of the old testdata for KtImportOptimizer
This testdata is some form will be transferred to the `intellij` repo
2023-10-25 20:53:14 +00:00
Roman Golyshev 421793673b KTIJ-26423 [AA] Extend KtImportOptimizer testdata with imports usage information
`KtImportOptimizerResult.unusedImports` should be removed soon, and
part of the testdata for the import optimizer service should go
to `intellij` repository
2023-10-25 20:53:12 +00:00
Ivan Kochurkin 1827df82c4 Removed useless as casts from compiler code
It allows compiling code with K2 and enabled `-Werror`
2023-10-24 20:59:56 +00:00
Anna Kozlova 5cac013d8c [AA] approximate inplace type parameters bounds
^ KTIJ-27211 fixed
2023-10-24 10:54:15 +00:00
Dmitrii Gridin 17ab005668 [Analysis API FIR] KtSymbolContainingDeclarationProvider: support script declarations
This commit also fixes a missing symbol for KtScriptInitializer
and some symbol pointers
Many tests marked as 'DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE'
due to KtFirFileSymbol#createPointer logic – the pointer can
be created only for PSI

^KT-61451
^KT-61887
^KT-62626 Fixed
^KT-62693
2023-10-20 09:27:21 +00:00
Marco Pennekamp b9e3d848a6 [AA] Add KotlinPackageProviderMerger
- In parallel to Kotlin declaration provider merging, we need a proper
  merging strategy for package providers as well, because resolve
  extensions may define additional package providers.
- Additionally, other non-scope-based package providers may be added in
  the future, and the merger preserves these out of the box.

^KT-61791
2023-10-12 16:10:32 +00:00
Marco Pennekamp 239cfa6d29 [AA] Add tests for combined declared member scopes
^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 1408556511 [AA] Refactoring: Rename AbstractMemberScopeByFqNameTest to AbstractMemberScopeTest
^KT-61900
2023-10-10 13:38:00 +00:00
Marco Pennekamp df54540a81 [AA] Update usages of declared member scopes
- Now that non-static declared member scopes don't contain static
  callables anymore, we have to update some usages in the Analysis API.
- In symbol light classes, many usages of `getDeclaredMemberScope` can
  be kept as-is because Kotlin classes/objects generally cannot declare
  static callables (and we do not need to create symbol light classes
  for Java classes). The only exception are enum classes, which
  implicitly declare some static callables.

^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 21efd6aff3 [AA] Add tests for *static* (declared) member scopes
^KT-61900
^KT-61800
2023-10-10 13:38:00 +00:00
Marco Pennekamp 4ba0aef23b [AA] Refactoring: Simplify member scope test classes
^KT-61900
2023-10-10 13:38:00 +00:00
Ilya Kirillov 15e4cbc10d [Analysis API] implement an API to get a substitution based on an inheritance relationship between classes
^KT-62090 fixed
2023-10-06 11:39:33 +00:00
Ilya Kirillov 1107e728a2 [Analysis API] implement better rendering for chained KtSubstitutor 2023-10-06 11:39:33 +00:00
Anna Kozlova da385210d8 [AA] provide psiType#asKtType conversion
it's useful for IDE's features such as write UAST or refactorings

^KT-62302 fixed

Merge-request: KT-MR-12414
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-10-05 15:18:55 +00:00
Yan Zhulanow 9ef58f2bdb [LL API] Collect syntax errors in 'KtFirCompilerFacility'
^KTIJ-27167 Fixed
2023-09-22 11:39:49 +00:00
Yan Zhulanow 834cbaac5a [LL API] Run fir2ir separately for files in different modules
Each module may have its own compiler configuration.

^KTIJ-27061 Fixed
2023-09-21 06:19:15 +00:00
Marco Pennekamp 3add7f9db5 [AA] Support enum entry initializers in member scope tests
- Now that the enum entry initializer provides a member scope, not the
  enum entry, we need a way to get to the enum entry initializer in
  tests. This can only be done via the enum entry's name, because the
  initializer is anonymous.

^KT-61425
2023-09-08 11:13:28 +00:00
Alexander.Likhachev 6eaccc997f [Build] Fix the typo junit jupyter -> jupiter 2023-09-06 22:47:34 +00:00
Alexander.Likhachev 6f96be0b76 [Build] Get rid of the testApiJUnit5 method
#KTI-1349 In Progress
2023-09-06 22:47:34 +00:00
Ilya Kirillov 1f290828e5 [Analysis API Standalone] use the full version of jdk root finding from IJ
partial ones only work for jdk >= 9

^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 8f824dcff9 [Analysis API Standalone] copy JdkClassFinder from IntelliJ sources
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 56910b70a3 [Analysis API] fix "KotlinIllegalStateExceptionWithAttachments: expected as maximum one expect for the actual"
^KT-61597 fixed
2023-08-31 15:19:29 +00:00
Yan Zhulanow b96c1a644f [LL API] Fix code fragment compilation in library sources (KT-61383)
In complex projects, there might be several library copies (with the
same or different versions). As there is no way to build a reliable
dependency graph between libraries, a project library depends on all
other libraries. As a result, there might be several declarations in the
classpath with the same name and signature.

Normally, K2 issues a 'resolution ambiguity' error on calls to such
libraries. It is acceptable for resolution, as resolution errors are
never shown in the library code. However, the backend, to which
'evaluate expression' needs to pass FIR afterwards, is not designed for
compiling ambiguous (and non-completed) calls.
2023-08-30 06:38:44 +00:00
Yan Zhulanow 4b80c2197f [Analysis API] Run code fragment compilation tests against libraries 2023-08-30 06:38:44 +00:00
Dmitrii Gridin adc853ebd0 [AA] extend SymbolData API to support scripts
^KT-61431
2023-08-28 15:02:24 +00:00
aleksandrina-streltsova aa0eca6d6d [AA] Provide KtCallableSymbol for static Java members
^KTIJ-25126 Fixed
2023-08-24 22:17:48 +03:00
Roman Golyshev 10df37ba8e KTIJ-26423 [AA] Return more info from KtFirImportOptimizer
Deprecate `unusedImports`, since they are supposed to be computed
on the IDE side from now on based on the information from
Analysis API

Currently the `unusedImports` property is not removed completely
so it can still be used by the Kotlin side import optimizer
tests; they should be moved/adapted to the intellij repository
also
2023-08-21 10:46:58 +00:00
Ilya Kirillov 2ce324f1fc [Analysis API] rename AbstractSingleSymbolByPsi -> AbstractSingleSymbolByPsiTest
to match test naming convention
2023-08-17 13:01:02 +00:00
Ilya Kirillov 1b0034b6e7 [Analysis API] allow AbstractSingleSymbolByPsi to accept <expr>-based section in addition to <caret>-based 2023-08-17 13:01:02 +00:00
Pavel Kirpichenkov c0c234e1d2 Minor: rename files to source files in configurators for standalone mode
KT-59793
2023-08-17 12:03:10 +00:00
Pavel Kirpichenkov ef6375f627 [LL] Use package provider to check for existing package
KT-59793
2023-08-17 12:03:08 +00:00
Yan Zhulanow 5a67b0d7dc [LL API] Correct used IR symbols in code fragments
As 'FirCodeFragments' are converted to IR independently of its context,
in some cases duplicate (and not quite correct) symbols for local
classes and functions are created.

Until properly fixed in fir2ir, here we replace such duplicates with
original symbols.
2023-08-08 17:26:39 +00:00
Yan Zhulanow e1db3c88cf [LL API] Support code fragment compilation 2023-08-07 16:22:01 +00:00
Yan Zhulanow 02af189066 [LL API] Support code fragment analysis 2023-08-07 16:22:01 +00:00
Marco Pennekamp e3d803de8b [AA] KT-58257 Prepare KtResolveExtension API for active invalidation
- `KtResolveExtension`s need to participate in active invalidation,
  because LL FIR sessions depend on changes in resolve extension files.
- The resolve extension will simply be able to use the
  `KotlinModificationSubscriptionService`, which is part of the Analysis
  API surface for **API implementors**, to publish modification events.
2023-07-31 15:58:00 +00:00
Marco Pennekamp 0c94a3131c [AA] KT-58257 Add API for subscription-directed invalidation
- The commit refactors some modification trackers previously provided by
  `KotlinModificationTrackerFactory` to a subscription-directed
  mechanism implemented via `MessageBus` and `KotlinTopics`. The
  following modification trackers are affected:
  - Module out-of-block modification: The FE10 Analysis API doesn't use
    these modification trackers, so the effect is limited to LL FIR.
  - Module state: Likewise, FE10 doesn't use this modification tracker,
    so again the effect is limited to LL FIR.
- Project and library modifications trackers remain, because many small
  objects in e.g. light classes depend on these trackers (making
  listener management unfeasible), and they are not relevant for
  `LLFirSession` invalidation.
- This new API paves the way for a session invalidation service to
  subscribe to out-of-block and module state changes as events. This
  removes the need to iterate through modification trackers.
  - Also note that the out-of-block modification provided by the new
    subscription mechanism is intended to work for _any_ `KtModule`, as
    long as it makes sense to have out-of-block modifications. For
    example, the subscription should work for script modules. The OOB
    modification tracker previously only supported `KtSourceModule`s,
    which required separate single-file modification trackers for script
    and not-under-content-root modules.
- `MessageBus` is a general utility provided by IntelliJ, but usually it
  is retrieved from `project`. To keep these two concerns decoupled,
  `project.messageBus` should not be used directly. Instead, the commit
  adds a `KotlinMessageBusProvider`, which for now just provides the
  project message bus with its standard implementation, but allows
  swapping out the message bus implementation later.
- Global changes are also supported by the new subscription API. Such
  global changes may for example occur during cache invalidation in
  tests, on global PSI tree changes, or when an SDK is removed.
- Test-only invalidation has been moved from
  `KotlinModificationTrackerFactory` to a new
  `KotlinGlobalModificationService`. This creates one central service
  for invalidation between tests, which is easier from an implementation
  and a usage perspective than calling multiple scattered services and
  providers.
2023-07-31 15:58:00 +00:00
Dmitrii Gridin c01c113af4 [AA] implement infrastructure for scripts
^KT-60728
2023-07-27 12:02:04 +00:00
Yan Zhulanow 7821ef0414 [Analysis API] Make 'KtCompiledFileForOutputFile' an internal API 2023-07-27 10:23:42 +00:00