Commit Graph

28 Commits

Author SHA1 Message Date
Yan Zhulanow 4a2f11b2f5 Revert "Revert "KT-61890 [AA] Use ContextCollector in KtFirScopeProvider""
This reverts commit 644e29a2ea.
2024-01-05 16:04:14 +00:00
Dmitrii Gridin 8a3f850bca [LL FIR] StubBasedFirMemberDeserializer: deserialized properties must have default getter/setter
In FIR we always have either real getter/setter or the default one

^KT-62888 Fixed
^KT-62651 Fixed
2024-01-03 13:39:42 +00:00
Roman Golyshev 644e29a2ea Revert "KT-61890 [AA] Use ContextCollector in KtFirScopeProvider"
This reverts commit 47a00bf9

See KTIJ-27918
2023-11-24 11:21:15 +00:00
Ivan Kochurkin 115d685d91 [FIR] Fix ambiguity of Throws and other std annotations importing
Including `SharedImmutable` and `ThreadLocal`

Simplify code, remove `DefaultImportPriority.KOTLIN_THROWS`

Introduce `FirNativeClassMapper`
2023-11-23 23:51:23 +00:00
Roman Golyshev d865a44c94 KT-61890 [AA] Add test for ContextCollector at loop variable position
This turns out to be important for conflict resolution in
postfix completion in K2 IDE (see `KotlinDeclarationNameValidator`)
2023-11-14 22:15:05 +00:00
Roman Golyshev 47a00bf97e KT-61890 [AA] Use ContextCollector in KtFirScopeProvider
^KT-61890 Fixed
2023-11-14 22:15:04 +00:00
Roman Golyshev 4f136cde31 KT-61890 [AA] Add testdata to ensure KDoc completion support in IDE
Completion in the IDE relies on correct scopes for KDoc positions.
So we add testData for `KtScopeProvider` and `ContextCollector`
to ensure that there are no regressions
2023-11-14 22:15:04 +00:00
Roman Golyshev 3c68b27280 KT-62071 [AA] Do not throw error from getScopeContextForPosition when implicitScope of receiver value is null
`implicitScope` can be `null`
in case when the implicit receiver resides in a user-defined `kotlin.*`
package, but the user have not yet allowed this with compiler argument
directive.

In this case,
we don't want the IDE to crush and show exceptions - the `kotlin`
package would be highlighted by the compiler diagnostics and other
resolve problems, and that would be enough

^KT-62071 Fixed
2023-10-19 12:59:47 +00:00
Ilya Kirillov 7db2fc522e [Analysis API Standalone] fix builtin resolution for common module
StubBasedBuiltInsSymbolProvider does not work for now for common modules (KT-61757)
 but compiler builtins provider `FirBuiltinSymbolProvider` works.

Also, stub-based symbol providers should not be used in standalone mode.

Testdata from standalone is updated because of the difference
in property accessors (KT-62449) between stub and compiler builtin symbol providers.

Additionally, this commit fixes the behavior of `KotlinStaticPsiDeclarationFromBinaryModuleProvider`.
As compiler builtin declarations have no PSI attached,
`KotlinStaticPsiDeclarationFromBinaryModuleProvider` is used to get PSI
from `DecompiledPsiDeclarationProvider.findPsi`.
`DecompiledPsiDeclarationProvider` is only used in UAST standalone mode.
2023-10-17 13:23:11 +00:00
Dmitrii Gridin 1b1e1d5b3f [Analysis API] DebugSymbolRenderer: unify error types
They are still can be different in the case of error inside
type argument (e.g. `kotlin/Array<out ERROR CLASS: Incomplete code>`)
2023-09-14 18:53:25 +02:00
aleksandrina-streltsova 752ea6fd98 [AA] Add tests for scope context for position
KTIJ-27007
2023-09-12 14:44:23 +00:00
Marco Pennekamp 3fa2ca7ddd [AA] Add specific implementation for KtFirEnumEntryInitializerSymbol
- Previously, `KtFirAnonymousObjectSymbol` was a
  `KtEnumEntryInitializerSymbol`, which carried the risk that an
  anonymous object unrelated to enum entries might be used as an enum
  entry initializer. This commit introduces a specific symbol for FIR
  enum entry initializers.
- As a nice side effect, anonymous object symbol creation is simplified
  and `KtFirEnumEntryInitializerSymbolPointer` can restore the symbol
  via `KtFirEnumEntrySymbol.enumEntryInitializer`.

^KT-61425
2023-09-08 11:13:28 +00:00
Marco Pennekamp 80efa34926 [AA] Add KtEnumEntryInitializerSymbol
- An enum entry's body is an initializer with members only accessible
  within that body. Because users of the Analysis API might want to
  analyze the members of the enum entry initializer, we expose this
  initializer via `KtEnumEntrySymbol`. The initializer only exists if
  the enum entry has a body.
  - We already have some usages of the initializer inside symbol light
    classes, which generate a light class for each enum entry, which
    includes the enum entry's hidden members.
- To hide the implementation detail that initializers are anonymous
  objects, `KtEnumEntryInitializerSymbol` is simply a
  `KtSymbolWithMembers`.
- The advantage of making it a `KtSymbolWithMembers`, instead of
  providing a custom way to get a member scope, is that we can pass
  around the initializer easily, e.g. in `KtEnumEntrySymbolRenderer`.
- We implement `KtEnumEntryInitializerSymbol` directly as a
  `KtFirAnonymousObjectSymbol` without a wrapper. This has a few
  advantages:
  1. We can directly benefit from the anonymous object symbol being a
     `KtSymbolWithMembers`, so we don't have to handle enum entry
     initializers specially in e.g. `KtFirScopeProvider`.
  2. We don't have to implement a new symbol restoration mechanism for
     the initializer.
  3. This implementation matches the actual FIR tree structure (with a
     simplification that the connecting anonymous object expression
     between the enum entry and the initializing anonymous object is
     omitted).

^KT-61425 fixed
2023-09-08 11:13:28 +00:00
Nikolay Lunyak f9c6af4d2a [FIR] Properly assign <local> packages to symbols
This prevents `FirConflictsExpressionChecker.kt`
from missing conflicting local functions. It used
to due to inconsistencies in assigning `<local>`,
and this commit makes it a bit more
straightforward.

The change in KtClassTypeQualifierRenderer
prevents `FirOverrideImplementTest.testLocalClass`
from failing in `intellij`. It didn't fail for
callables, because `KtCallableSignatureRenderer`
doesn't try to render packages.

^KT-59186 Fixed
2023-08-18 13:31:04 +00:00
aleksandrina-streltsova 9548486b55 [FIR] don't transform analyzed lambda
Inside `transformDeclarationContent` current tower data context is saved. Previously, stored context could be incomplete, because `dataFlowAnalyzer.enterFunction(function)` wasn't called in all cases.
^KTIJ-26419 Fixed
2023-08-03 07:54:24 +00:00
aleksandrina-streltsova 9e50a3b71d [FIR] create snapshot of collected tower data context for declaration
KTIJ-26113
2023-07-31 10:50:12 +00:00
aleksandrina-streltsova af6672c87d [FIR] store tower data context for operand in and/or binary expression
KTIJ-26113
2023-07-31 10:50:12 +00:00
aleksandrina-streltsova 1c472c2751 [AA] update test data after adding properties to callable symbols
KT-54846
2023-07-24 17:24:42 +00:00
aleksandrina-streltsova 52a95cb75f [AA] update test data after adding properties to KtClassLikeSymbol
KT-54846
2023-07-24 17:24:41 +00:00
Justin Paupore fa0209a322 [AA] Expand functionality of TestScopeRenderer.
- Add package and constructor listings
- Add single-scope renderForTests() implementation, including a lambda
  to provide additional information about each symbol
- Remove special handling for empty scopes (interfered with single-scope
  rendering)

^KT-59329
2023-07-14 19:32:08 +02:00
aleksandrina-streltsova 116de97f54 [AA] Add synthetic properties scopes to scope context for position 2023-07-05 12:36:54 +00:00
Denis.Zharkov 78e2d53f3c K2: Adjust Analysis API to the recent scope structure changes
Namely, in the previous commit we merged two
(LOW and HIGH priority default start import scopes) into the single one

For more explanations, please look at the previous commit
2023-07-04 07:25:22 +00:00
Denis.Zharkov 2e5b783cc6 K2: Refine how JDK members are mapped to built-in classes
Previously, the semantic was more-or-less correct for most of the cases
but some corner one, like `sort` in MutableList didn't work properly.

Namely, `sort` should be marked there in a way to forbid to call it
everywhere beside super-calls.
Also, overriding it should be allowed.

Mostly, the logic was re-written to K2 model from K1-related
JvmBuiltInsCustomizer.

^KT-57694 In progress
^KT-57269 Fixed
2023-05-30 10:44:41 +00:00
Ilya Kirillov d1da3b8acd [Analysis API] fix missing names in KtFirStarImportingScope
The missing name types were: java classifier names, callable/classifier names generated by plugins
2023-05-19 11:53:16 +00:00
Anna Kozlova 5ca052f87b [LL] [cls] use stubBased symbol provider for builtins
this gives the following benefits:
1. no protobuf in memory, all data is already present in stubs
2. given that symbol provider for libraries is already stub based,
we can get rid of complicated code to find source psi by deserialized fir
3. it's also possible to reduce number of index access,
when fir is requested for given ktElement
2023-05-09 07:36:09 +00:00
Mikhail Glukhikh 156be26982 AA: use full rendering of backing field symbols 2023-04-25 12:18:27 +00:00
Mikhail Glukhikh 1f05ce2e01 AA/LC: Support annotation property->backing field move
#KT-57462 Fixed
2023-04-25 12:18:27 +00:00
aleksandrina-streltsova 4b7164a557 [Analysis API] Allow handling scopes from KtScopeContext separately
^KT-55527
2023-03-20 22:04:48 +00:00