Commit Graph

451 Commits

Author SHA1 Message Date
aleksandrina-streltsova fe4ca30c55 [AA] implement isExpect/isActual for callable symbols
^KT-54846 Fixed
2023-07-24 17:24:42 +00:00
aleksandrina-streltsova ca25162574 [AA] implement isExpect/isActual for KtClassLikeSymbol
KT-54846
2023-07-24 17:24:41 +00:00
aleksandrina-streltsova 20598cf7d7 Revert "[Analysis API] Add API for expect/actual declaration detection"
This reverts commit 338c2433ac.
2023-07-24 17:24:40 +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
Jinseong Jeon 2dee644f7a AA FE1.0: restore an option to register AnalysisHandlerExtension w/o use-site module 2023-07-24 11:34:51 +02: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
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
Ilya Kirillov 4b3bff3344 Rework checkWithAttachment/requireWithAttachment
* better naming
* throw corresponding KotlinIllegalStateExceptionWithAttachments/KotlinIllegalArgumentExceptionWithAttachments instead of general KotlinRuntimeExceptionWithAttachments
2023-07-18 11:49:20 +00:00
Ilya Kirillov 15f6fe2627 Move ExceptionAttachmentBuilder near KotlinExceptionWithAttachments so it's accessible from KotlinExceptionWithAttachments 2023-07-18 11:49:20 +00:00
Ilya Kirillov 4b523825be [Analysis API] forbid providing custom KtLifetimeToken for every analyze call
^KT-60488 fixed
2023-07-18 08:47:34 +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
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 67c3849538 [Analysis API] Shortener: enable shortening in KDoc
^KTIJ-21103
2023-07-04 16:34:51 +00:00
aleksandrina-streltsova 338c2433ac [Analysis API] Add API for expect/actual declaration detection 2023-07-03 15:08:04 +00:00
Ilya Kirillov 5b4916a808 Introduce StandardNames.IMPLICIT_LAMBDA_PARAMETER_NAME
and use it instead of hardcoded constant
2023-06-30 13:43:31 +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
aleksandrina-streltsova 4ccea40651 [AA] Provide API for obtaining array element type of KtType
KTIJ-23199
2023-06-29 09:41:40 +03: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 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
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 7be17a80ce [Analysis API] regenerate Fe10IdeNormalAnalysisSourceModuleAnalysisApiImportOptimizerTestGenerated 2023-06-21 12:04:31 +02:00
Mikhail Glukhikh 7fd441f16a Analysis API: add normal FE10 import optimizer (taken from plugin code) 2023-06-21 12:04:31 +02: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
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
Ilya Kirillov 724386a5f1 [Analysis API] rework the resolve of the nested name references
To properly resolve qualifier parts in the middle,
we need to resolve the whole qualifier to understand
which parts of the qualifier are package or class qualifiers.
And then we will be able to resolve the qualifier
selected by the user to the proper class, package or callable.

^KT-59189
2023-06-09 21:18:45 +00:00
Ilya Kirillov d9cb7b67d4 [Analysis API] move ShortenCommand.invokeShortening to the IDE repository
as Analysis API should not modify the code

^KT-58992 fixed
2023-06-09 14:45:23 +00:00
Ilya Kirillov 95cf892eec [Analysis API] extract the data from the ShortenCommandImpl to the base class
^KT-58992
2023-06-09 14:45:23 +00:00
Justin Paupore f590e88bdd [Analysis API] Add source shadowing for resolve extensions.
KtResolveExtensions are designed to handle IDE analysis use cases where
source might not be available at analysis time, because that source is
generated by an external source generator, such as an annotation
processor or resource compiler. The sources generated by those external
generators can appear in the analysis scope, and cause issues with
source clash - resolution may find the virtual source from the
KtResolveExtension, the on-disk generated source from the external
generator, or both. This can cause issues, because that on-disk
generated source may be stale, and may not have symbols that will exist
the next time the generator is run (or, conversely, may have symbols
that will disappear on the next build).

To solve this, add a `getShadowedScope(): GlobalSearchScope` to
`KtResolveExtension`. Any files in the module that are included in that
scope will be hidden from resolution, allowing the resolve extension to
cleanly replace those files.

^KT-58834 fixed
2023-06-08 15:55:04 +02:00
Ilya Kirillov 481962d5f6 [LL FIR] get rid of on-air resolve of partial type qualifiers
It's very slow and leads to performance problems (see KT-58125)

Instead, we do the following:

- For a fully resolved type qualifier, when we want to resolve its part,
 we are looking for the corresponding symbol by traversing nested classes
 bottom up.
 - For an error qualifier, we are trying to resolve the maximum possible
  qualifier in the types transformer where all the type scopes are
  already available.

^KT-58125 fixed
2023-06-08 13:41:35 +00:00
Mikhail Glukhikh 0373e3fdfe KtFe10SymbolInfoProvider: take annotation use-site target into account 2023-06-08 13:34:50 +00:00
Anna Kozlova 983d319a6b [AA] fe10 symbols adjusted to be used in goto type declaration
- try to find sources for decompiled symbols in IDE mode
- function literals can't be declared as extensions,
though there target can contain that indication,
let's take what descriptor provides
2023-06-07 21:46:49 +00:00
Egor Kulikov 347c748182 [FIR] Add excessive delegated constructors to FIR tree
^KTIJ-25453 fixed

Merge-request: KT-MR-10379
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-06-05 14:27:53 +00:00
Ilya Kirillov 1eb0862820 [Analysis, build] replace testApi -> testImplementation in build.gradle.kts where it's possible 2023-06-02 09:16:47 +00:00
Anna Kozlova 1d5c080dd8 [AA] calculate ktType based on symbols when possible
then, for compiled code deserialized fir would be used instead of building
decompiled text and consequence building and resolving of raw fir;

type for ktTypeReference from compiled code is called e.g., by UAST inspections
when they check annotations of the called function parameters
2023-05-31 06:26:28 +00:00
Marco Pennekamp 326b6fa7c2 [AA] Add missing withValidityAssertion calls to scopes
^KT-58653
2023-05-22 19:21:34 +00:00
Ilya Kirillov ee1fd9f6e9 [Analysis API] optimize composite scope
Do not create KtCompositeScope for empty or single scopes
2023-05-19 11:53:15 +00:00
Ilya Kirillov 29be88e3c9 [Analysis API] add KtScope.getCallableSymbols/getClassifier symbols overloads which accept a candidate name set
This is needed for the cases when a candidate name set is known
 to avoid retrieving a set with all possible names when processing the scope.

^KT-58653 fixed
2023-05-19 11:53:15 +00:00
Egor Kulikov bff1520c9e [FIR] Resolve where subjects to corresponding type argument
^KTIJ-25295 fixed

Merge-request: KT-MR-10044
Merged-by: Egor Kulikov <Egor.Kulikov@jetbrains.com>
2023-05-17 15:28:02 +00:00
Dmitrii Gridin 4472e1ae4e [AA FIR] add tests on implicit type in delegated scope
^KT-58727
2023-05-17 09:51:21 +00:00
Yan Zhulanow c6d8876f9f [LL API] Pass the project instance to ProjectStructureProvider
Eliminate unnecessary PSI tree traversal by providing the 'Project'
instance explicitly.
2023-05-16 08:42:57 +00:00
Yan Zhulanow e9c077220f [LL API] Migrate 'getKtModule()' usages to 'ProjectStructureProvider'
Ensure the contextual module is passed wherever possible.

^KT-57559 Fixed
2023-05-16 08:42:57 +00:00
Jinseong Jeon b42d2e56a4 AA: use nameFilter of KtFileScope#get*Symbols 2023-05-15 19:25:05 +02:00
Ilya Kirillov 4c69f2fbcb [Analysis API] fix "Unexpected class FirTypeProjectionWithVarianceImpl" exception
from KtFirExpressionTypeProvider.getKtExpressionType

^KTIJ-23432 fixed
2023-05-11 20:44:31 +02:00
Jinseong Jeon 384ed9cc9e AA: regression test for default value that calls previous params 2023-05-04 18:26:32 +02:00