Commit Graph

553 Commits

Author SHA1 Message Date
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 c2d08b9462 [AA] Add additional tests for declared member scopes and member scopes
^KT-61800
2023-10-10 13:37:59 +00:00
Ilya Kirillov 9dcd142f0d fixup! [Analysis API] implement an API to get a substitution based on a inheritance relationship between classes 2023-10-06 11:39:33 +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 68c7673cb3 [Analysis API FIR] fix ISE "Status should be resolved for a declaration to create it fake override"
on calling completion on an instance of `kotlin.Pair`.

Caused by unresolved status for `copy` created for data classes from a library.

^KT-62268 fixed
2023-10-05 17:01:40 +00:00
Ilya Kirillov 5d769bf524 [Analysis API] add possibility to have different results for standalone/ide Analysis API mode in tests 2023-10-05 17:01:40 +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
Egor Kulikov 057973f4bb [FIR] Fix NPE on invalid gets with index
^KT-60342 fixed
2023-10-03 22:34:46 +00:00
Yan Zhulanow 715f7d1a35 [LL API] Analyze code fragment in a separate 'FirSession'
Before, `KtCodeFragment`/`FirCodeFragment` was analyzed as a part of
its context `KtModule`. This has the following complications:

- In non-source sessions, diagnostic reporting is globally disabled.
  For code fragments, however, checking the code before passing it to
  the backend is essential.

- Special treatment for call ambiguities in libraries
  (`LLLibraryScopeAwareCallConflictResolverFactory`) becomes complicated
  as the conflict resolver has to be applied to a library module.

- `KtCodeFragment`s usually have a shorter lifetime than their own
  context. Caching may potentially be implemented differently for them.

^KT-61783 Fixed
2023-09-22 12:20:05 +00:00
Ilya Kirillov b25185530f [Analysis API Standalone] use compiler FirSymbolProvider for standalone mode
^KT-61371 fixed
2023-09-20 07:47:59 +00:00
Ilya Kirillov 9c50308954 [LL FIR] refactoring, rename LLFirLibrarySymbolProviderFactory.createJvmFirDeserializedSymbolProviders -> createJvmLibrarySymbolProvider
to match the behavior

^KT-61371
2023-09-20 07:47:59 +00:00
Ilya Kirillov cce8bc6f83 [LL FIR] refactoring, use Project from project session constructor for implementations of LLFirLibrarySymbolProviderFactory
^KT-61371
2023-09-20 07:47:59 +00:00
Ilya Kirillov 2422fc6df3 [LL FIR] refactoring, extract LLFirLibrarySymbolProviderFactory implementation to the standalone module
^KT-61371
2023-09-20 07:47:59 +00:00
Ilya Kirillov 575c7ea0d9 [LL FIR] refactoring, rename JvmFirDeserializedSymbolProviderFactory
so it can be used not only for JVM

^KT-61371
2023-09-20 07:47:59 +00:00
Roman Golyshev a78d631b16 KTIJ-27050 [Analysis API] Correctly handle type parameters in KtFirReferenceShortener
Make `FirShorteningContext` correctly return symbols for type
parameters, so they are not ignored when scopes are inspected

Add additional type of `PartialOrderOfScope` - `TypeParameter`, because
otherwise it would have been classified as `Unclassified`, and that
breaks scopes comparison

Add missing type parameters to the scope of class header in
`ContextCollector`, add testdata for that

There is a bug in the compiler with type parameters leaking to nested
classes headers (KT-61959). After it's fixed, the testData with
incorrect expected shortenings/scopes should be adjusted and fixed too

^KTIJ-27050 Fixed
2023-09-18 10:23:30 +00:00
Roman Golyshev 7b50506aea KT-61889 [AA] Migrate KtFirReferenceShortener to ContextCollector
This should make reference shortener considerably faster, since it won't
need to perform redundant extra resolve of the file.

`ContextCollector` more accurately collects the scopes for the scripts,
so some script tests are also fixed.

It should fix the following bugs:

^KTIJ-26714 Fixed
^KTIJ-26727 Fixed

This is also an important part of fixing the following bugs:
- KTIJ-26715
- KTIJ-26734

But those bugs also rely on KT-61890, because completion uses scopes
and snows incorrect elements from them
2023-09-13 16:43:20 +00:00
aleksandrina-streltsova 752ea6fd98 [AA] Add tests for scope context for position
KTIJ-27007
2023-09-12 14:44:23 +00:00
Dmitrii Gridin 3a577e1c31 [Analysis API] add more tests for vararg parameters
^KT-61422
2023-09-11 15:47:47 +00:00
Marco Pennekamp 536e172d0e [AA] Add declared member scope tests for enum entry initializers
^KT-61425
2023-09-08 11:13:28 +00:00
Marco Pennekamp 72de86a8ba [AA] Add tests for enum class member scopes
^KT-61405
2023-09-08 11:13:28 +00:00
Marco Pennekamp 3aefeb0fc5 [AA] Add tests for enum entry initializer member scopes
^KT-61425
2023-09-08 11:13:28 +00:00
Marco Pennekamp e72a38dc82 [AA] Remove KtSymbolWithMembers from KtEnumEntrySymbol
- An enum entry is a variable which doesn't declare any additional
  members. It must not be confused with its implementing anonymous
  object initializer, which may declare additional members, but is an
  implementation detail hidden outside the enum entry's initializer.
  Hence, the enum entry variable should not have a (declared) member
  scope.
- A following commit will add the ability to get the enum entry's
  initializer, so that a member scope for this initializer can be
  obtained (which might be relevant for local analysis).

^KT-61405 fixed
2023-09-08 11:13:28 +00:00
Roman Golyshev f5307173b5 KTIJ-26959 [AA] Do not ignore underscore named properties in KtFirImportOptimizer
After the fix for the KT-60904 issue (c963eadb),
there are unnamed declarations created even for
the unused variables in destructuring declarations

Because of this, we can actually align testData
for K1 and K2. It seems like KT-59504 is no
longer relevant and can be marked as obsolete
because of the KT-60904 fix

^KTIJ-26959 Fixed
2023-09-08 09:19:06 +00:00
aleksandrina-streltsova f18d600dc8 [LL FIR] Return class as structure element for super type reference
^KT-61755 Fixed
2023-09-08 07:25:36 +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 209d59440b [Analysis API FIR]: fix a freeze on rendering of invalid type arguments
^KT-61750 fixed
2023-09-06 16:05:49 +00:00
Ilya Kirillov f7352585f4 [Analysis API Standalone] do not add non-supported file types to KtSourceModule
^KT-60884
2023-09-06 07:36:12 +00:00
Ilya Kirillov c76f365efb [Analysis API Standalone] change behavior of StandaloneAnalysisAPISession.getModulesWithFiles
- it now returns a map only for `KtSourceModule`
- every `KtSourceModule` is present there, even a module without source files

^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov a2015a6eb5 [Analysis API Standalone] fix wrongly registered KtLifetimeTokenProvider for standalone mode tests
`KtAnalysisSessionProvider` cached the incorrect `KtLifetimeTokenFactory` before the proper one was registered

^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 43a8ae98b7 [Analysis API Standalone] add basic tests for buildStandaloneAnalysisAPISession
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 0416e0423f [Analysis API Standalone] deduplicate binary roots for KtBinaryModuleBuilder
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov d459981974 [Analysis API Standalone] return as a result created module in KtModuleProviderBuilder.addModule so it can be reused
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov fcf062a252 [Analysis API Standalone] simplify initializing KtSdkModuleBuilder with JDK
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 180434951b [Analysis API Standalone] simplify adding source binary roots for KtSourceModuleBuilder
- allow providing source files instead of PsiFile
- automatically provide GlobalSearchScope for created `KtSourceModule`

^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 67f4ebc022 [Analysis API Standalone] simplify adding multiple binary roots for KtBinaryModuleBuilder
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 52e9167675 [Analysis API Standalone] reuse existing local file system in getPsiFilesFromPaths
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov e6bd34b671 [Analysis API Standalone] refactoring, use Path instead of String for path representation
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov eb2c4e4015 [Analysis API Standalone] automatically collect GlobalSearchScope for KtBinaryModule
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 97a7c0b6ff [Analysis API Standalone] extract functions for getting GlobalSearchScope by roots to utils
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov 3f689494ad [Analysis API Standalone] do not force users to provide a project for building KtModule as it's already known
^KT-60884
2023-09-06 07:36:11 +00:00
Ilya Kirillov dca4015cba [Analysis API Standalone] get rid of deprecated utils for initializing the standalone mode
they were deprecated and there are no clients for them now

^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
Roman Golyshev f39153b6e6 KT-61568 [FIR][AA] Add one more testcase for AllCandidatesResolver 2023-08-31 14:59:53 +00:00
Dmitrii Gridin 99307f97e9 [Low Level FIR] introduce service for incoming psi modifications processing
This service encapsulates all logic and simplifies future evolution

^KT-60610
2023-08-31 10:06:43 +00:00
Roman Golyshev 1766c68e9c [FIR][AA] Rely more on isInBestCandidates flag KtFirReferenceShortener
After the KT-61568 has been fixed, `isInBestCandidates`
correctly works in more cases, and can be more
reliably used in `KtFirReferenceShortener`

^KTIJ-26808 Fixed
^KTIJ-26840 Fixed
2023-08-31 08:45:34 +00:00
Ilya Kirillov 714cb67254 [decompiler] add tests for generated psi text by builtin decompiler 2023-08-30 14:45:15 +00:00
Ilya Kirillov e8db349f24 [decompiler] extract builtin VirtualFile creation to a separate service for further reuse
^KTIJ-26760
2023-08-30 14:45:14 +00:00
Roman Golyshev 21dffe4639 KT-61568 [FIR][AA] Do not add redundant file scopes in AllCandidatesResolver
`firResolveSession.getTowerContextProvider` should already
contain all the relevant scopes, including default and
importing scopes for the file

Because of this, import and default scopes had presence over the
more local scopes, and the resolve was performed incorrecty - top level
candidates were given higher priority

^KT-61568 Fixed
^KTIJ-26824 Fixed
2023-08-30 14:30:21 +00:00
Yan Zhulanow dbb7e788b2 [LL API] Provide customizable default language version settings 2023-08-30 06:38:44 +00:00