Commit Graph

232 Commits

Author SHA1 Message Date
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
Dmitrii Gridin 7631e90f12 [LL FIR, Java] fix resolve contract violation from java symbol provider from permits
To create a smart psi type pointer, IJ Platform uses resolve
We cannot use resolve from JavaSymbolProvider,
as it may lead to resolve contract violation

^KT-59243 Fixed
2023-06-14 09:25:26 +00:00
Dmitrii Gridin 6992a707dc [LL FIR, Java] fix resolve contract violation from java symbol provider from supertypes
To create a smart psi type pointer, IJ Platform uses resolve
We cannot use resolve from JavaSymbolProvider,
as it may lead to resolve contract violation

^KT-59240 Fixed
2023-06-12 16:41:26 +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
Ilya Kirillov b8f15cbbb3 [LL FIR, Java] fix resolve contract violation from java symbol provider
To create a smart psi type pointer, IJ Platform uses resolve.
We cannot use resolve from JavaSymbolProvider, as it may lead to resolve contract violation.

^KT-59133 fixed
2023-06-08 14:13:30 +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
Anna Kozlova 4d97e4c572 [LL] add tests for FirDeclarationForCompiledElementSearcher
build stub if was not able to load:
expected that in IDE stubs would always be found in the index, for tests -
build from virtual file
2023-06-07 21:00:26 +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
Ilya Kirillov 78f09409b7 [Analysis API] move ClsKotlinBinaryClassCache/FileAttributeService service registration to StandaloneProjectFactory 2023-06-02 09:16:47 +00:00
Ilya Kirillov feaf9acd1d [Analysis API] move KotlinFakeClsStubsCache service registration to StandaloneProjectFactory
so it can be used from standalone mode
2023-06-02 09:16:47 +00:00
Ilya Kirillov 452844ffc6 [Analysis API] move KotlinReferenceProvidersService service registration to StandaloneProjectFactory
so it can be used from standalone mode
2023-06-02 09:16:47 +00:00
Ilya Kirillov 9f2d750f98 [Analysis API] move KtResolveExtensionProvider EP registration to common code
so it can be used from standalone mode
2023-06-02 09:16:47 +00:00
Marco Pennekamp a50e839660 [LL FIR] Add multi-module resolve extension reference resolve tests
- To test the reference resolution of declarations provided through
  resolve extensions of module dependencies, we need support for
  multimodule resolve extension tests.
2023-05-31 18:34:42 +00:00
Marco Pennekamp 915c412929 [AA] KT-58580 Add KotlinDeclarationProviderMerger
- A proper merging strategy for declaration providers is required for
  cases where the main declaration provider created by
  `createDeclarationProvider` can't provide all declarations that the
  original declaration providers can provide. Then, only a sublist of
  the declaration providers should be merged, while keeping the
  unmergeable declaration providers intact.

^KT-58580 fixed
2023-05-31 18:34:42 +00:00
Ilya Kirillov 9829a2bf98 [LL FIR] fix contract violation exception from Java Resolution
When we create `SmartTypePointer` directly inside `JavaSymbolProvider`,
the Java resolution is called which is forbidden inside the
`JavaSymbolProvider`.

Instead, the lazy `JavaElementTypeSource` for JavaType is created,
which creates a `SmartTypePointer` outside `JavaSymbolProvider`.

^KT-58194
2023-05-31 13:01:19 +00:00
Ilya Kirillov 2d08d29dac [Java Resolution] use a smart psi pointer to store PSI in JavaElement for IDE
`JavaElement`s are reused between read actions, so underlying PSI elements might be invalidated when using hard PSI references

^KT-58194 fixed
2023-05-31 13:01:19 +00:00
Ilya Kirillov f8ddf204e2 [Analysis API] add KtTypeScope.getCallableSignatures/getClassifierSymbols 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.

Similar to KtScope.

^KT-58653
2023-05-19 11:53:15 +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 41976a2932 [Analysis API] optimize scope members processing when a candidate name set is known
Use KtScope.getCallableSymbols/getClassifier symbols overloads which accept a candidate name set.

^KT-58653
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
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
Ilya Kirillov 4c69f2fbcb [Analysis API] fix "Unexpected class FirTypeProjectionWithVarianceImpl" exception
from KtFirExpressionTypeProvider.getKtExpressionType

^KTIJ-23432 fixed
2023-05-11 20:44:31 +02: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
Ilya Kirillov ba3a3915c7 [Analysis API] tests: use tagged caret to find declaration to analyze in the air against
We cannot use a KtFile as analysis context.

^KT-55527
2023-05-04 15:26:50 +00:00
Ilya Kirillov eeac3f53b4 [Analysis API] add tests for getImportingScopeContext
^KT-57966
2023-05-04 15:26:50 +00:00
Ilya Kirillov 254092a267 [Analysis API FIR] tests: add ability to ignore specific scope kind in TestScopeRenderer
^KT-57966
2023-05-04 15:26:50 +00:00
Ilya Kirillov 67041851fc [LL FIR] tests: extract scope rendering utilities to a separate object
For further reuse

^KT-57966
2023-05-04 15:26:50 +00:00
Ilya Kirillov e9f75b1350 [LL FIR] add test which checks reference shortening for the whole file
^KT-57966
2023-05-04 15:26:50 +00:00
Ilya Kirillov bb7037aa8e [LL FIR] extract shortening rendering for tests to a separate file
So it can be reused from other tests

^KT-57966 fixed
2023-05-04 15:26:50 +00:00
Nikolay Krasko 3caa1d1349 Refactoring: fix usages of @TestOnly ExtensionsArea.registerExtensionPoint 2023-04-28 08:25:19 +00:00
Anna Kozlova d59d66e876 [AA, LL] use stubs to build deserialized Fir elements in IDE
^KTIJ-24638

Notice on `DebugSymbolRenderer`:
stub based deserializer sets source directly,
but it's available in IDE mode only.
Thus, standalone and IDE tests have different results.
In order to avoid this, sources for compiled code are explicitly ignored

Notice on distinct callables:
for a file which belong to multiple libraries, decompiled code would be build per library.
In order to avoid ambiguity errors for members in that file,
we need to distinct provided elements by origins
failed test from IJ repo:
 FirReferenceResolveWithCrossLibTestGenerated#testSetWithTypeParameters
2023-04-27 11:37:28 +00:00
aleksandrina-streltsova 2cc3b542fd [Analysis API FIR] Initialize properties of KtCallableSignature lazily 2023-04-27 10:59:30 +00:00
Roman Golyshev d4cffb8a5a [213] Switch to 213 platform
KTI-1114
2023-04-21 13:19:04 +00:00
Dmitrii Gridin d66b919c12 [AA] introduce tests on annotation stability
^KT-57849
2023-04-21 10:14:05 +00:00
Ilya Kirillov 0d0b1b7945 [Analysis API] add ability for a custom element navigation for a KtResolveExtensionFile
^KT-57930
2023-04-19 16:09:05 +00:00
Ilya Kirillov 51eaa3f9cf [Analysis API] provide tests for the KtResolveExtensionProvider
^KT-57930
2023-04-19 16:09:05 +00:00
Ilya Kirillov d68587de77 [Analysis API] implement API to extend Kotlin resolution by generated declarations
^KT-57930 fixed
2023-04-19 16:09:04 +00:00
aleksandrina-streltsova e8272fa02e [Analysis API] Move testdata for scope provider 2023-03-20 22:04:48 +00:00
aleksandrina-streltsova 4b7164a557 [Analysis API] Allow handling scopes from KtScopeContext separately
^KT-55527
2023-03-20 22:04:48 +00:00
Yan Zhulanow c33bedb417 [LL API] Simplify 'KtFirAnalysisSessionProvider'
The 'CachingKtAnalysisSessionProvider' was only used in
'KtFirAnalysisSessionProvider', and reasons why it was created
(reusing code between FE10 and K2 session provider implementations)
is not actual anymore.
2023-03-14 09:46:37 +00:00
aleksandrina-streltsova 3d0bca5ca1 [Analysis API] Handle missed cases in PsiElement.getExpectedType()
^KTIJ-24256
2023-03-09 09:19:00 +00:00
Artem Vasilev 564d44b16d [FIR] Test for duplicate filtering for overrides from Java 2023-03-03 11:06:19 +00:00
Ilya Kirillov 4944b454c5 [Analysis API] optimize KotlinPackageProvider.getSubPackageFqNames
Previously, we queried heavy kotlin package provider two times which affected performance
Now it's being queries only a single time

Also, the commit introduces separation for KotlinPackageProvider between kotlin and platform-specific packages

^KTIJ-24640
2023-02-28 13:38:23 +00:00
Jiaxiang Chen 7ce2f64c18 AA: apply java type enhancement to declaredMemberScope.
* added getDeclaredMemberScope to JavaScopeProvider.
2023-02-24 19:57:10 +01:00
Jinseong Jeon 5455942859 AA: handle underscore as type arguments
^KTIJ-24742 Fixed
2023-02-23 13:02:34 +01:00
Ilya Kirillov 803c3b88ac [Analysis API] fix exception on symbol restore when symbol cannot be seen from the use-site module
^KT-56763 fixed
2023-02-20 11:01:32 +00:00
Ilya Kirillov ee1b018c9a [Analysis API] introduce a helper test function to get carets at multimodal tests 2023-02-20 11:01:31 +00:00
Ilya Kirillov 769fb835f9 [Analysis API] introduce a KotlinResolutionScopeProvider to optimize the resolutions scope in the IDE 2023-02-13 11:35:24 +01:00
Ting-Yuan Huang 42b08d411b [FIR] Pass container when creating FunctionType
so that it can be resolved when type annotations are demanded.
2023-02-08 19:43:24 +00:00