Commit Graph

490 Commits

Author SHA1 Message Date
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 fe4ca30c55 [AA] implement isExpect/isActual for callable symbols
^KT-54846 Fixed
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
aleksandrina-streltsova ca25162574 [AA] implement isExpect/isActual for KtClassLikeSymbol
KT-54846
2023-07-24 17:24:41 +00:00
Anna Kozlova 40a6c81d97 [AA] retrieve overridden symbols for parameter from generated property
Merge-request: KT-MR-11215
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
2023-07-24 11:09:56 +00:00
Roman Golyshev b8052761db KT-60341 [Analysis API] Provide a type for a FirNameReference only when it refers to an actual property/variable
We cannot always return null, because in such case some expressions
would become not fully explorable from the types perspective (see
the documentation on the `getCorrespondingTypeIfPossible`)

`FirNamedReference` might appear when resolving method references (like
`foo::bar`), but also when IJ Platform tries to resolve other parts of
the Kotlin PSI, notably a `KtNameReferenceExpression` in a
function call (`bar` in `foo.bar(baz)` expression).

N.B. FE10 implementation does not support returning `null` as a type -
currently it always returns `Unit` type in case it cannot figure out
the actual type. This issue should probably be tackled together with
KT-60166, so that both implementations are more or less aligned

^KT-60341 Fixed
^KT-59077 Fixed
^KTIJ-25745 Fixed
2023-07-19 22:01:37 +00:00
Kirill Rakhman 97024d9ccb [FIR] Resolve array literal argument for non-primitive-array parameter as arrayOf call in annotation calls
This allows us to properly complete array literals arguments of
annotation calls fixing several false-negative type mismatch errors
as well as enabling the inference of generic type arguments.

#KT-59581 Fixed
#KT-58883 Fixed
2023-07-19 13:34:58 +00:00
Roman Golyshev 5e30adec06 KTIJ-26276 [Analysis API] Do not consider single aliased import from the same package as unused
Even when the aliased import comes from the same package, it cannot be
removed, because it will break the code

Also, add more tests for the imports coming from the same package

^KTIJ-26276 Fixed
2023-07-19 12:40:57 +00:00
Justin Paupore 9f85739599 [AA] Add KtResolveExtensionInfoProvider to AA.
This provider is responsible for answering queries related to resolve
extensions. At the moment, this includes retrieving a KtScope with all REx
top-level declarations (moved from KtSymbolFromResolveExtensionProvider), and
retrieving information necessary to supply a GeneratedSourcesFilter for REx
generated code. Future REx-related functions can be added to this interface.

^KT-59329
2023-07-14 19:32:09 +02: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
Justin Paupore f01b824751 [AA] Show symbol origins in REx tests.
This is in preparation for adding a separate KtSymbolOrigin for
resolve extension symbols.

^KT-59351
2023-07-14 19:32:08 +02:00
Justin Paupore 734b87b97e [AA] Allow specifying REx file contents in testdata.
Tests can now specify the code generated by a resolve extension from
within the test's testdata. Module-level directives control whether
resolve extensions are enabled for that module, as well as package names
and source shadowing regexes. File-level directives allow a `// FILE:`
block within the testdata to be converted into a KtResolveExtensionFile
and removed from the module as a whole. (This requires a new
`ModuleStructureTransformer`, because we need to be able to entirely
remove the files in question.)

Any test can add support for these directives by calling
`KtResolveExtensionTestSupport.configure` from within their
`configureTest` stanza. This allows this functionality to be used in
conjuction with any test base class.

^KT-59329
2023-07-14 19:32:08 +02:00
Andrei Klunnyi 0323b0fb19 KT-59801 [FIR] scripting: tests for reference shortening 2023-07-13 15:21:39 +02:00
Mikhail Glukhikh 9d9d7880af K2: render types in quotes in diagnostic messages 2023-07-13 09:07:39 +00:00
Mikhail Glukhikh c839cd3c11 K2: don't use debugging type renderer in error messages 2023-07-13 09:07:39 +00:00
Bart van Helvert 362675a1b5 [AA] Support getting type from get and set annotation calls
#KTIJ-26206 Fixed
2023-07-07 12:57:45 +00:00
Egor Kulikov 27f4b53570 [FIR] Do not expect builtin imports to be always resolved
Merge-request: KT-MR-10886
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-07-05 14:02:50 +00:00
aleksandrina-streltsova 116de97f54 [AA] Add synthetic properties scopes to scope context for position 2023-07-05 12:36:54 +00:00
aleksandrina-streltsova 39bdd67df6 [AA] Shortener: change test data
Remove ON_AIR_CONTEXT_CARET_TAG where it's not necessary
2023-07-04 16:34:53 +00:00
aleksandrina-streltsova 9766270afa [AA] Shorten kdocs that became available because of newly added imports 2023-07-04 16:34:52 +00:00
aleksandrina-streltsova 88f2bf85eb [AA] Test shortener for the whole file with different options 2023-07-04 16:34:51 +00:00
aleksandrina-streltsova 67c3849538 [Analysis API] Shortener: enable shortening in KDoc
^KTIJ-21103
2023-07-04 16:34:51 +00:00
Kirill Rakhman e7c213e06e [FIR] Report separate error for delegated constructor call to interface
#KT-59216 Fixed
2023-07-04 16:00:45 +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
Roman Golyshev c5ded1ba48 KTIJ-26103 [Analysis API] Ignore implicit dispatch receivers in Reference Shortener
Calls to extension functions imported from objects have implicit
dispatch receivers, but those receivers are not present in the code
and should not be analyzed by the shortener

^KTIJ-26103 Fixed
2023-07-03 20:05:09 +00:00
Roman Golyshev ab149e1053 KTIJ-26024 [Analysis API] Add more tests for nested cases of reference shortening in class header
Account for `FirNestedClassifierScopeWithSubstitution` in the reference
shortener
2023-07-03 16:21:42 +00:00
Roman Golyshev 88450c69b3 KTIJ-26024 [Analysis API] Provide correct context for class header from FirTowerDataContextAllElementsCollector
To correctly provide the context for class header resolution, we save
the additional copy of the context right before `withRegularClass`
wrapper call in `LLFirBodyLazyResolver`. Otherwise we would have to
clear the existing context by hand, which is too cumbersome
(if at all possible)

^KTIJ-26024 Fixed
^KTIJ-24832 Fixed
2023-07-03 16:21:42 +00:00
Roman Golyshev 96697b5a77 KTIJ-26024 [Analysis API] Rearrange testData for reference shortener
Move testData for nested classes' scopes to a separate directory
2023-07-03 16:21:42 +00:00
aleksandrina-streltsova 57cbab7d8e [AA] Shortener: allow import if requested import kind has high priority 2023-07-03 15:08:05 +00:00
aleksandrina-streltsova a96e2f37e7 [Analysis API] Shortener: don't add import if it affects usages
^KTIJ-24096 Fixed
2023-07-03 15:08:04 +00:00
aleksandrina-streltsova da5f33d762 [Analysis API] Do not shorten qualifiers outside the selection range
^KTIJ-25116 Fixed
2023-07-03 15:08:04 +00:00
aleksandrina-streltsova ed7a3299f0 [Analysis API] Shorten qualifier of unresolved reference
^KTIJ-25115
2023-07-03 15:08:03 +00:00
Ilya Kirillov 8b0eb0488f [Analysis API] add method for implicit companion object reference detection
Add a new method `isImplicitReferenceToCompanion` to determine
if the given reference is an implicit reference to a companion object.

The method is needed for the rename refactoring in IJ.

^KTIJ-25863
2023-06-30 13:43:30 +00:00
Ilya Kirillov 048ecdf981 [Analysis API] add regression tests for KTIJ-24163
^KTIJ-24114 obsolete
2023-06-30 11:13:46 +00:00
Jinseong Jeon a93bc60655 AA: use simple name of local type as JVM internal name
Otherwise, e.g., if a local type is within an anonymous object, full
class id will include that anonymous object too, resulting in invalid
type signature for PsiType.

^KT-59533 Fixed
2023-06-28 18:38:01 +02:00
Egor Kulikov d17c7d4729 [FIR] Correctly mute destructuring declaration test for 1.0
Merge-request: KT-MR-10847
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-06-27 16:17:07 +00:00
Egor Kulikov a7c1f53af8 [FIR] Correctly process invalid destructing declarations
^KTIJ-24730 fixed

Merge-request: KT-MR-10712
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-06-27 09:54:01 +00:00
Roman Golyshev b4c9a2616e KTIJ-25960 [Analysis API] Resolve static declarations in KDoc
^KTIJ-25960 Fixed
2023-06-26 12:27:26 +00:00
Jinseong Jeon e0fc0d96e5 AA: handle PsiType conversion for recursive type parameter case
^KT-59598 Fixed
2023-06-23 16:31:47 +02:00
aleksandrina-streltsova 3477d35168 [AA] Provide expected type for annotation entry argument
^KTIJ-19863
2023-06-22 12:33:51 +00:00
Roman Golyshev 26dbeb9b6f KTIJ-25530 [Analysis API] Add missing test cases for Java statics
Can be done now because KT-58980 is fixed
2023-06-21 18:37:09 +00:00
Ilya Kirillov 0ad98ff610 [Analysis API] use fe10-specific testdata for Fe10IdeNormalAnalysisSourceModuleAnalysisApiImportOptimizerTestGenerated 2023-06-21 12:04:31 +02:00
Kirill Rakhman 911e62257a [FIR] Improve INVISIBLE_REFERENCE message
Report the nearest invisible containing declaration in cases where
the declaration itself is visible.

#KT-53820 Fixed
2023-06-21 08:36:46 +00:00
Egor Kulikov b147b7e929 [FIR] Store fir for invalid when branches
^KTIJ-25646 fixed

Merge-request: KT-MR-10646
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-06-20 16:11:31 +00:00
Roman Golyshev bccd7bc04a KTIJ-25341 [Analysis API] Visit component calls in import optimizer
N.B. K2 does not require resolved `componentX` functions for the
placeholder variables (`_`), see KT-59504

^KTIJ-25341 Fixed
2023-06-20 10:12:57 +00:00
Roman Golyshev adab552928 KTIJ-25530 [Analysis API] Correctly collect references to implicitly dispatched callables in Import Optimizer
N.B. There is a case which is not covered ATM due to the bug in the
compiler, see KT-58980

^KTIJ-25530 Fixed
2023-06-19 16:02:09 +00:00
Anna Kozlova 09f4f0af66 [AA] delegate to resolveToFirSymbol to avoid decompilation
`getReturnTypeForKtDeclaration` is called by UAST on probably compiled declarations.
In order to avoid redundant decompilation + building raw FIR + resolve,
let's delegate to deserialized FIR which is already prepared in stubs

Fixes KTIJ-24810

When `findSourceNonLocalFirDeclaration` is called on non-physical property accessor e.g.,
during completion, then traverse tree should allow drilling into FirProperty;
otherwise, no FIR would be found
2023-06-16 09:00:09 +00:00
Anna Kozlova dd059a1e63 [LL] find fir by psi: allow fallthrough to traverse tree for invalid code
In case of broken code e.g., duplicated classes provider would return first class,
though we definitely need some code insight in this case
at least to add navigation fixes, etc.
Similar to this, a file copy is created during completion,
where additional elements might appear and we need to search for them.

Added test cases for duplicated classes.
2023-06-15 17:32:40 +00:00
Anna Kozlova f80ed4592d [AA] Handle KtTypeReference children in CompileTimeConstantProvider
CompileTimeConstantProvider could receive a reference expression,
whose grandparent is KtTypeReference (seen that in UAST inspection).
FIR would not contain anything explicit for this reference,
FirResolvedTypeRef would be received as the nearest parent.
Of course, in this case, there could be no compile time constant anyway.
2023-06-15 07:06:41 +00:00
Mikhail Glukhikh 5304afb097 Fix AA/LC behavior accordingly to changes related to KT-54844 2023-06-14 07:09:15 +00:00