Commit Graph

464 Commits

Author SHA1 Message Date
Yan Zhulanow 1726a94c87 [Pill] Update module structure 2023-12-07 08:53:35 +00:00
Alexander Kuznetsov e048d49bf0 [Analysis API] fe10: count value classes in isInline
#KT-63771 fixed


Merge-request: KT-MR-13220
Merged-by: Alexander Kuznetsov <Aleksander.Kuznetsov@jetbrains.com>
2023-12-01 17:33:30 +00:00
Egor Kulikov 001e9a4489 [FIR] Source for property delegates should not be null
^KT-60327 fixed


Merge-request: KT-MR-13221
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-11-29 08:27:53 +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
Egor Kulikov 43fc4ccf40 [FIR] Source for implicit iterator calls in for should not be null
^KT-62111 fixed


Merge-request: KT-MR-13029
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-11-22 17:15:24 +00:00
Roman Golyshev 7d7256536c KT-63627 [AA] Properly handle object declarations when traversing scopes in KtFirReferenceShortener
`KtClass` denotes only classes, interfaces and enums.
To handle object declarations, we now use
`KtClassOrObject` PSI type

^KT-63627 Fixed
2023-11-21 18:08:43 +00:00
Roman Golyshev 4f5926a88f KT-62675 [AA] Handle labeled this expressions in reference shortener
At the moment, there is no good way to meaningfully filter `this`
expressions. The filters for the reference shortener can work only with
symbols, and it does not make a lot of sense to check any particular
symbol when deciding whether to shorten a labeled `this` expression.

We would probably need a better API for the shortener to be able
to filter more precisely (see KT-63555)

^KT-62675 Fixed
2023-11-20 20:18:18 +00:00
Marco Pennekamp 03a7162f37 [AA] Enable test-specific configuration of write access permissions
- In general, Analysis API tests forbid write access because the
  Analysis API should not be used from write actions. However, in some
  cases we might want tests to e.g. modify PSI, which requires write
  access. This change allows `AnalysisApiTestConfigurator`s to enable
  write access for the specific test.
2023-11-16 19:50:51 +00:00
Marco Pennekamp 6189d68c3c [AA] Refactoring: Provide default implementations for functions of AnalysisApiTestServiceRegistrar
- Most inheritors of `AnalysisApiTestServiceRegistrar` only need to
  override one or two functions.
2023-11-16 19:50:51 +00:00
Ilya Kirillov 531e4fb86e [Analysis API Standalone] add comment about KT-63493 to StandaloneSessionBuilderAgainstStdlibTest 2023-11-16 13:31:54 +00:00
Ilya Kirillov fee7d63975 [Analysis API Standalone] add tests for resolution against native KLib
^KT-63126
2023-11-16 13:31:53 +00:00
Ilya Kirillov 63c807f7bd [Analysis API Standalone] extract test logic for a test against the stdlib to a base classes
It will be reused in a Kotlin/Native resolution test in the following commit

^KT-63126
2023-11-16 13:31:53 +00:00
Ilya Kirillov 6aeabc83ea [kotlin] fix "IllegalStateException: Could not find stdlib"
The commit removes all the KLib resolution logic,
now Analysis API Standalone clients need to provide all the KLib
list directly.

The resolution logic was removed as too error-prone and requiring compiler configurations.

Kotlin Gradle plugin can provide a full set of required KLibs,
so if a client is a Gradle plugin, this should not be an issue.

Probably, some fancy API which will explicitly perform all KLib dependency searches
should be introduced in the future (KT-63395)

^KT-63126 fixed
2023-11-16 13:31:53 +00:00
Ilya Kirillov 1c17f4a835 [Analysis API Standalone] extract a assertIsCallOf test utility to reused in other test modules
^KT-63126
2023-11-16 13:31:53 +00:00
Egor Kulikov c0a05e435c [FIR] Correctly process invalid implicit invoke
^KT-60170 fixed


Merge-request: KT-MR-12926
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-11-15 11:43:48 +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
Marco Pennekamp 88d307d52c [AA] Add tests for diagnostics suppression on top-level declarations and class members
- `testConflictingOverloadsAtTopLevel` is currently disabled in FIR
  because it fails with a mismatch between diagnostics from the file and
  the individual elements. It will be enabled in the next commit.

^KT-62899
2023-11-13 10:20:26 +00:00
Roman Golyshev 500dd20277 KT-63096 [LL] Add test for using annotation from other module for compiler plugin 2023-11-09 23:39:32 +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
Ilya Kirillov d2b9b487c7 [Analysis API] add test for resolution into declarations with the kotlin. package
^KT-63223
2023-11-08 17:32:49 +00:00
Ilya Kirillov c54d83dcad [Analysis API] fix resolution to declarations inside kotlin*. packages
`kotlin*.` packages should be always allowed.
`kotlin.` packages should be allowed if `AnalysisFlags.allowKotlinPackage` is `true`

^KT-63223 fixed
2023-11-08 17:32:48 +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
Nikita Bobko e778ddfd21 [AA] getExpectForActual analysis-api now returns compatible or weakly incompatible
^KTIJ-27522 Fixed

It's the only reasonable behavior for this API in it's current shape
(when it returns a list of declarations)

It's a common mistake to take only Compatible from
expectActualMatchingMap. The problem will be gone after I fix KT-62590

Motivation to fix this bug, is because it will be easier for me to split
expect-actual matcher-checker-monster thing KT-62590

Review: https://jetbrains.team/p/kt/reviews/12750/timeline
2023-11-06 14:41:15 +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
Ilya Kirillov 834927a901 [Analysis API Standalone] fix common code analysis against a klib
^KT-63007 fixed
2023-11-02 19:19:39 +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
Ilya Kirillov 4720a0faa7 [Analysis API FIR] fix NPE of == call resolve without builtins
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-62957 fixed
2023-10-31 12:24:16 +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
Ilya Kirillov a90562c0da [Analysis API] support creating KtSymbol by K/JS dynamic scope
^KT-61257 fixed
2023-10-26 19:28:27 +00:00
Bart van Helvert 793e7aa1d1 [AA] Add tests for retrieving field and parameter annotation types 2023-10-26 07:48:18 +00:00
Anna Kozlova e79bc5bb59 [AA] KtExpressionInfoProvider.getMissingCases: fix no subject case
return missing else branch (even if it's present, see kdoc)

^ KT-62875 fixed
2023-10-25 09:41:38 +00:00
Anna Kozlova 5cac013d8c [AA] approximate inplace type parameters bounds
^ KTIJ-27211 fixed
2023-10-24 10:54:15 +00:00
Roman Golyshev 44d48510b4 KTIJ-26057 [AA] Ignore implicit receivers scope when dealing with types in reference shortener
Implicit receivers generally do not affect the resolution of types.
However, they generate scopes which might contain undesirable
classifiers, which can confuse reference shortener.

Dropping all the implicit receivers when dealing with type references
allows completely avoid such undesirable scopes instead of filtering
them by `instanceof` checks.

Also, temporary move `hasTypeParameterFromParent` check higher to the
`findClassifierElementsToShorten`, because ATM we don't know how to
properly decide whether to shorten the fully-qualified inner types
with implicit parameters or not (see KTIJ-26072).

^KTIJ-26057 Fixed
2023-10-24 07:47:30 +00:00
Marco Pennekamp f04b27b90b [AA] Add additional KDoc reference resolution tests for callables
- This adds KDoc reference resolution tests for callables in nested and
  inner classes, overloaded functions, and private callables.
- Private declarations are visible in KDoc from outside their containing
  classes. This is in line with K1 KDoc behavior.

^KTIJ-22324
2023-10-23 23:08:01 +00:00
Marco Pennekamp ef484c7518 [AA] Fix KDoc reference resolution of non-imported companion object members
- Similar to the fix for KTIJ-25995, the name interpretation collector
  needs to consider the companion object's member scope as well.

^KTIJ-25995
2023-10-23 23:08:01 +00:00
Marco Pennekamp 71792f9ad6 [AA] Add test for KDoc reference resolution of sibling nested class 2023-10-23 23:08:00 +00:00
Marco Pennekamp 367b84d45e [AA] Add tests for KDoc reference resolution of companion object members
^KTIJ-25995
2023-10-23 23:08:00 +00:00
Marco Pennekamp 3dbae89cdd [AA] Add tests for KDoc reference resolution of non-static callables
^KTIJ-26003
2023-10-23 23:08:00 +00:00
Roman Golyshev 0747fc36de KTIJ-27434 [AA] Unwrap safe call expression when resolving implicit invoke calls
`FirSafeCallExpression` does not implement `FirResolvable`, so we need
to unwrap it to correctly resolve calls like `foo?.bar()` when `bar` is
a lambda with receiver parameter or a functional type property

^KTIJ-27434 Fixed
2023-10-20 13:27:31 +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
Alexander Kuznetsov 45792c2e60 [Analysis API] support unsigned arrays creation functions
IDEA-335151, KT-62663


Merge-request: KT-MR-12614
Merged-by: Alexander Kuznetsov <Aleksander.Kuznetsov@jetbrains.com>
2023-10-18 10:53:52 +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
Roman Golyshev d2fcd71d23 KTIJ-27139 [AA] Shorten qualified expressions only when the callee/type reference is in selection
If you want to shorten call like `foo.bar()` into `bar()`, then you
need your range to intersect with `bar` callee reference. Having only
`foo` in the range is not enough

Same goes for the type references - to shorten `foo.Bar` into `Bar`, you
need at least some intersection of your range with `Bar` reference

^KTIJ-27139 Fixed
^KTIJ-27015 Fixed
2023-10-16 20:05:01 +00:00
Dmitrii Gridin 5de269147f [LL FIR] add tests for synthetic property
^KT-61990
2023-10-16 15:07:11 +00:00
Ilya Goncharov e9cc2931cc [JS] Use kotlin-stdlib-js.klib instead of *.jar 2023-10-16 13:34:37 +00:00
Anna Kozlova 3c2be4551b [AA] getExpectedType should not calculate expression type
if property doesn't specify explicit type,
property's return type would be calculated by provided initializer

^KT-62588 fixed


Merge-request: KT-MR-12564
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-10-16 09:31:52 +00:00
Dmitrii Gridin 1a01dd4dd4 [Analysis API] add diagnostic tests for unresolved reference inside primary constructor
^KT-62437
2023-10-13 17:13:14 +00:00