Commit Graph
100 Commits
Author SHA1 Message Date
Dmitrii Gridin 5e63d1a5e5 [LL FIR] drop obsolete workaround
The original problem is already fixed

^KTIJ-26848
2023-09-05 18:39:41 +00:00
Dmitrii Gridin bd10ee10fe [psi] avoid usage of SAFE_IDENTIFIER_FOR_NO_NAME
This name leads to inconsistency between FqName from stub and
FqName from ClassId.
The first one is `no_name_in_PSI_3d19d79d_1ba9_4cd0_b7f5_b46aa3cd5d40`
but the second one is `<no name provided>`.
We can't just replace SAFE_IDENTIFIER_FOR_NO_NAME to NO_NAME_PROVIDED
due to many places with unsafe logic inside type mapping.

^KTIJ-26848 Fixed
2023-09-05 12:58:50 +00:00
Dmitrii Gridin ae02d78aff [PSI] ClassIdCalculator: cleanup code
^KTIJ-26848
^KTIJ-26896
2023-09-05 12:58:50 +00:00
Dmitrii Gridin 0701da6c59 [stub] simplify ClassId creation
We can create nested ClassId just from the parent stub instead of calculation by tree.
This commit simplified the complexity of ClassId building to liner.
Example:
```kotlin
package one
class A {
  class B {
    class C {
      class D
    }
  }
}
```
Previously, we had to create ClassId by traverse parents for each class.
Now we will visit each class only once.
It should improve performance and memory consumption during indexing.

^KTIJ-26848
2023-09-05 12:58:50 +00:00
Dmitrii Gridin 2421d3cdf1 [LL FIR] ClassId: add more tests
^KTIJ-26848
^KTIJ-26896
^KTIJ-26902
2023-09-05 12:58:50 +00:00
Dmitrii Gridin c095b60fe8 [LL FIR] drop outdated LazyBodyIsNotTouchedTest
We have our own transformers and tests against compiler test data,
so separate test with compiler transformers is redundant
2023-09-04 12:37:12 +00:00
Dmitrii Gridin 420b6d48c3 [LL FIR] FileStructure: avoid redundant bodies visiting
We shouldn't try to find structure elements inside non-local declarations
Only classes and scripts can have an inner structure

^KT-60611
2023-09-03 11:44:00 +00:00
Dmitrii Gridin 8832865e9a [LL FIR] simplify FileStructureElement invalidation
We can avoid complex reanalyze-base logic and just directly
drop outdated data from FileStructureCache

^KT-60611
2023-09-03 11:44:00 +00:00
Dmitrii Gridin 89c186c496 [LL FIR] move part of in-block modification logic into service
^KT-60611
2023-09-03 11:44:00 +00:00
Dmitrii Gridin 0b7eb32064 [FIR] FirSupertypeResolverVisitor: use symbol API instead of ClassId version
In Low Level FIR we have a simplified version of getFirClassifierContainerFileIfAny
without a scope search

^KTIJ-26848
2023-08-31 12:34:46 +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
Dmitrii Gridin 5aae053785 [AA FIR] add symbol restoring for $$result declaration
^KT-61431 Fixed
^KT-61451
2023-08-28 15:02:25 +00:00
Dmitrii Gridin 99510ca42b [AA] add test for $$result declaration
^KT-61431
2023-08-28 15:02:25 +00:00
Dmitrii Gridin adc853ebd0 [AA] extend SymbolData API to support scripts
^KT-61431
2023-08-28 15:02:24 +00:00
Dmitrii Gridin b6f34ad8c0 [AA] add API to get KtScriptSymbol for KtScript
^KT-61431
2023-08-28 15:02:24 +00:00
Dmitrii Gridin 700835ef13 [AA] generate tests for scripts
^KT-61431
2023-08-28 15:02:24 +00:00
Dmitrii Gridin 5557ea690d [AA] add generated tests for scripts
^KT-61431
2023-08-28 15:02:24 +00:00
Dmitrii Gridin 932c2a6e15 [AA FIR] KtFirReferenceShortener: process only statements in scripts
We shouldn't process other elements (like parameters/receivers) because
we can't modify them anyway. This will help to avoid exceptions like
```
Attempt to load text for binary file which doesn't have a decompiler plugged in
```
in tests

^KT-61431
2023-08-28 15:02:24 +00:00
Dmitrii Gridin bef5f89f61 [AA] add configurator for scripts
^KT-61431
2023-08-28 15:02:24 +00:00
Dmitrii Gridin 0a5501b8dd [LL FIR] add ability to pass analyseInDependentSession into AnalysisApiFirScriptTestConfigurator
^KT-61431
2023-08-28 15:02:24 +00:00
Dmitrii Gridin 0068a3f6b8 [Analysis API FIR] mapAnnotationParameters: add debug information
^KT-61252
2023-08-28 12:59:58 +00:00
Dmitrii Gridin 7a24d0ee82 [Analysis API] KtPsiTypeProvider: disable for non-jvm platforms
Otherwise, it will throw exception like:
```
IllegalStateException: No 'FirJvmTypeMapper'
```

Anyway, PsiType is JVM conception, so it is not supposed to be used
outside the JVM platform

^KT-60318
2023-08-28 12:45:29 +00:00
Dmitrii Gridin 7fa7d8ea8d [SLC] provide light classes only for platforms with jvm target
Light classes are not supposed to work on non-jvm platforms due to its
specific

^KT-60318 Fixed
2023-08-28 12:45:29 +00:00
Dmitrii Gridin 2cb6ee81a1 [LL FIR] add guards to type resolver
We should protect return types from value parameters/property accessors
and backing fields from repeatable modifications.
Such declarations can be modified during type resolution by
`transformTypeToArrayType` or property getter type propagation,
so we should be able to restore the original reference in the case of
exceptions (PCE for instance)

^KT-61422
2023-08-23 20:05:18 +02:00
Dmitrii Gridin 2f8a64fff2 [AA FIR] fix exception from vararg parameter with invalid type
It is true that for vararg parameter `arrayElementType` always have to
be not null, but it required resolution to TYPES phase. But in case of
the error type, the type reference is treated as resolved, so we are not
obligatory to resolve such reference to TYPES, because we already have
the resolved type.
So we can make the rule of KtFirValueParameterSymbol#returnType less
strict, and varargElementType will effectively do the same as
lazy resolve + arrayElementType

^KT-61422 Fixed
2023-08-23 20:05:18 +02:00
Dmitrii Gridin 3debf36d60 [FIR] DFA: add missing unwrap for FirDesugaredAssignmentValueReferenceExpression
^KT-60319 Fixed
^KT-61407 Fixed
2023-08-23 09:15:25 +00:00
Dmitrii Gridin c01d27a61e [FIR] VariableStorageImpl: add debug info
^KT-60319
^KT-61407
2023-08-23 09:15:25 +00:00
Dmitrii Gridin e68cf38e99 [LL FIR] FirDeclarationForCompiledElementSearcher: avoid providers search for member declarations
This should improve performance and increase stability

^KT-61331
^KT-61014
2023-08-22 12:19:14 +00:00
Dmitrii Gridin 695f6f0062 [SLC] fix annotation retention mapping
^KT-61377 Fixed
2023-08-21 20:46:25 +00:00
Dmitrii Gridin 566232fd0d [SLC] add test for binary retention
^KT-61377
2023-08-21 20:46:25 +00:00
Dmitrii Gridin 51cc799204 [SLC] fix flaky test 2023-08-21 20:46:25 +00:00
Dmitrii Gridin 175ce94bb5 [LL FIR] StubBasedClassDeserialization: provide psi class there is possible
We can provide psi declaration for nested classes to avoid search
through providers and improve stability

^KTIJ-26670 Fixed
2023-08-21 20:42:44 +00:00
Dmitrii Gridin faac4ad229 [LL FIR] add cache restoring in some situations
In some caches, we assume that the resulting value must be not null if
we provide a context, so we can fix the cache inconsistency in this case.
This is error situations that shouldn't happen, but currently we have
problems with script dependencies (KT-61267), so such checks will help
us to distinguish some LL FIR problems from dependency problems.

^KT-61331 Fixed
^KTIJ-26670
2023-08-21 20:42:44 +00:00
Dmitrii Gridin 3d52ba3bca [psi] KtFile: add hasImportAlias with caching
We have hotspots in UAST due to aliases, so we can reduce the time
significantly by caching `hasImportAlias` property

^KTIJ-26688
2023-08-21 13:57:10 +00:00
Dmitrii Gridin 0487bd7b6a [LL FIR] do not treat phase from FirFile as indicator for entire file
`resolvePhase` from `FirFile` is not an indicator of resolution state for
the entire file, so we shouldn't depend on it.
The right check will be performed during `lazyResolveTargets` over `LLFirResolveTarget`

^KTIJ-26666 Fixed
^KT-61296
2023-08-17 17:06:26 +00:00
Dmitrii Gridin a6b3896552 [LL FIR] LLFirTargetResolver: cleanup
Drop redundant extension

^KT-60799
2023-08-17 12:23:23 +00:00
Dmitrii Gridin 7884b5fecf [LL FIR] lazy resolution for file should process file annotation container
File annotation container is a part of a file,
so we should resolve it before to avoid contact violation

^KT-60799
2023-08-17 11:05:23 +00:00
Dmitrii Gridin b92303d36f [LL FIR] update test data for file lazy resolution
^KT-60799
2023-08-17 11:05:23 +00:00
Dmitrii Gridin 17d0017fbf [LL FIR] do not treat content of script initializers as non-local
^KT-61260 Fixed
2023-08-17 11:02:03 +00:00
Dmitrii Gridin 1a21affe1d [LL FIR] add test for 'for' on top level in script
^KT-61260
2023-08-17 11:02:03 +00:00
Dmitrii Gridin e05cb49671 [SLC] invalidate local class members cache on any file changes
We should track the containing file modifications to avoid PIEAE by
changes in members

^KTIJ-26661 Fixed
2023-08-16 10:22:13 +00:00
Dmitrii Gridin b0b2e76e13 [LL FIR] dependent analyze: support different numbers of statements
Previously, the different number of statements has led to
some unexpected behavior. E.g., the resulting script can have
duplicated declarations – one from the original script instead of
some statement and one from the copy

^KT-60987
2023-08-10 16:18:26 +00:00
Dmitrii Gridin 4f4b30ee28 [LL FIR] dependent analyze: add test on different statements in script
It contains a wrong result. Will be fixed in the next commit

^KT-60987
2023-08-10 16:18:26 +00:00
Dmitrii Gridin 201100db60 [LL FIR] AbstractDependentCopyTest: supports custom text in copy
This provides an ability to test more real-world cases.
E.g., we can emulate completion behavior

^KT-60987
2023-08-10 16:18:26 +00:00
Dmitrii Gridin 5d336e8649 [FIR] typeFromCallee: do not leak code 2023-08-10 10:35:21 +00:00
Dmitrii Gridin bdd8cce69c [LL FIR] LowLevelFirApiFacadeForResolveOnAir: drop unused function 2023-08-09 15:22:57 +00:00
Dmitrii Gridin 3947ba57da [LL FIR] support on-air resolve for scripts
We should reanalyze only statements and leave declarations as they are

^KT-61013 Fixed
2023-08-09 15:22:57 +00:00
Dmitrii Gridin 4c8399ae8c [LL FIR] KtToFirMapping: encapsulate recorder
We need this to avoid wrong recorders in on-air resolve

^KT-61013
2023-08-09 15:22:57 +00:00
Dmitrii Gridin d19a23aae5 [LL FIR] implement tests on dependent copy session analyze
^KT-60987
2023-08-09 15:22:57 +00:00
Dmitrii Gridin b39286e6cb [LL FIR] fix script testdata
Conflict with 887dc18719
2023-08-09 06:58:41 +00:00
Dmitrii Gridin 734a3e5716 [LL FIR] do not create lazy bodies during on-air resolve in scripts
We assume that on-air resolve already has normal bodies,
so depending on this fact, we can omit some redundant work

^KT-61026 Fixed
2023-08-08 15:40:48 +00:00
Dmitrii Gridin 601ffb2db4 [LL FIR] transform script body properly
Problem: transformSingle for expressions can return another expression,
and we should replace the original one with such new expression

^KT-61011 Fixed
^KT-61009 Fixed
2023-08-08 15:40:47 +00:00
Dmitrii Gridin 2688398361 [FIR] FirTypeUtils: add debug info 2023-08-08 12:04:46 +00:00
Dmitrii Gridin 55a253db04 [AA FIR] KtFirExpressionTypeProvider: add debug info 2023-08-08 12:04:46 +00:00
Dmitrii Gridin 1182a156e8 [LL FIR] add debug info to exception 2023-08-07 13:26:39 +02:00
Dmitrii Gridin 3b9b9327a4 [FIR] add debug info to CME from bounds
^KT-59007
^KT-60324
2023-08-04 08:12:50 +00:00
Dmitrii Gridin 77344c0845 [LL FIR] add checks about resolved context receivers
^KT-60728
^KT-60519
2023-08-02 16:50:45 +00:00
Dmitrii Gridin 0e0847bc9d [LL FIR] support lazy bodies in scripts
Also, it adds guards to avoid problems with PCE

^KT-60728 Fixed
^KT-60519 Fixed
2023-08-02 16:50:45 +00:00
Dmitrii Gridin 2f57916869 [FIR] add replaceStatements to FirScript
It is required to implement StateKeeper for scripts
statements should be MutableOrEmptyList to avoid CME

^KT-60728
^KT-60519
2023-08-02 16:50:45 +00:00
Dmitrii Gridin a2dc6ca8f2 [FIR] add RawFirBuilder test for script
^KT-60728
^KT-60519
2023-08-02 16:50:45 +00:00
Dmitrii Gridin 2c932c9e1d [LL FIR] add proper lazy resolve support for script dependent declarations
Such declarations (only `ResultProperty` for now) should delegate
resolution to the script, because they depend on its content

^KT-60728
2023-08-02 16:50:45 +00:00
Dmitrii Gridin f549712912 [FIR] FirCallableSymbol: introduce calculateReturnType
It will help to avoid copy-pasted logic there it is needed

^KT-60728
2023-08-02 16:50:45 +00:00
Dmitrii Gridin 35b0cd65e9 [FIR] PsiRawFirBuilder: add missing script configurator
PsiRawFirBuilder#visitScript didn't work because it didn't
have a configurator
Now FirScriptConfiguratorExtension split into two parts:
* File
* Script

^KT-60728
2023-08-02 16:50:45 +00:00
Dmitrii Gridin 32e3b67416 [LL FIR] LLFirTargetResolver: add default implementation to withFile and withRegularClassImpl
To drop redundant implementations in resolvers

^KT-60728
2023-08-02 16:50:45 +00:00
Dmitrii Gridin de48a51711 [LL FIR] avoid redundant context collection
We assume that declaration context will be collected
during `LLFirAnnotationArgumentsTargetResolver`, so other
`LLFirAbstractBodyTargetResolver` shouldn't repeat this process

^KT-60728
2023-08-02 16:50:45 +00:00
Dmitrii Gridin 1a3b0fa9d5 [LL FIR] provide script scopes to declarations
All transformations inside a script should be
under the script context for proper resolution

^KT-60728
2023-08-02 16:50:45 +00:00
Dmitrii Gridin 544341412a [LL FIR] extract LLFirResolveTargetWithDedicatedElement
It is required to simplify the logic in the next commit.
Also, it drops redundant inheritance from [firFile] and [path] properties

^KT-60728
2023-08-02 16:50:45 +00:00
Dmitrii Gridin dc347e2aa6 [LL FIR] add tests on specific cases in scripts resolve
* args
* $$result

^KT-60728
2023-08-02 16:50:45 +00:00
Dmitrii Gridin 63c6c38952 [LL FIR] LLFirPhaseUpdater: update phases inside delegate expression
^KT-60728
2023-08-02 16:50:45 +00:00
Dmitrii Gridin 7a2dad5ca5 [LL FIR] create separate FileStructureElement for script
It is required to avoid duplication visiting on declarations

^KT-60728
2023-08-02 16:50:45 +00:00
Dmitrii Gridin 97e330997b [LL FIR] support scripts in BODY_RESOLVE transformer
^KT-60728
2023-08-02 16:50:45 +00:00
Dmitrii Gridin 6cb1142210 [LL FIR] support scripts in annotation transformers
^KT-60728
2023-08-02 16:50:44 +00:00
Dmitrii Gridin efc6ca27b2 [LL FIR] support scripts in TYPES transformer
^KT-60728
2023-08-02 16:50:44 +00:00
Dmitrii Gridin 64bdcc1131 [LL FIR] support scripts in COMPILER_REQUIRED_ANNOTATIONS transformer
^KT-60728
2023-08-02 16:50:44 +00:00
Dmitrii Gridin 95e04c97cc [LL FIR] LLFirWholeFileResolveTarget should process script declarations
^KT-60728
2023-08-02 16:50:44 +00:00
Dmitrii Gridin 3686bf7ff9 [LL FIR] allow independent resolve for declarations in scripts
^KT-60728
2023-08-02 16:50:44 +00:00
Dmitrii Gridin 61981f6026 [LL FIR] skip FirScript resolve in transformers
It is a temporary step to be able to implement
granular scripts support

^KT-60728
2023-08-02 16:50:44 +00:00
Dmitrii Gridin da71a152cd [FIR] update FirRenderer for scripts
^KT-60728
2023-07-28 17:49:14 +00:00
Dmitrii Gridin 2bacba5a9a [LL FIR] add one more complex test case for scripts
^KT-60728
2023-07-28 17:49:14 +00:00
Dmitrii Gridin e99cfbd3b7 [LL FIR] add script tests for AbstractFirLazyDeclarationResolveTest
^KT-60728
2023-07-28 00:13:59 +02:00
Dmitrii Gridin 1515fbe99f [LL FIR] add script tests for AbstractGetOrBuildFirTest
^KT-60728
2023-07-28 00:13:59 +02:00
Dmitrii Gridin a60abc6c06 [LL FIR] add script tests for AbstractInBlockModificationTest
^KT-60728
2023-07-28 00:13:59 +02:00
Dmitrii Gridin 5ab4229ee5 [LL FIR] AbstractWholeFileResolvePhaseTest change extension to .lazy.resolve.txt
^KT-60728
2023-07-27 12:02:05 +00:00
Dmitrii Gridin e328aeee72 [LL FIR] add script tests for AbstractWholeFileResolvePhaseTest
^KT-60728
2023-07-27 12:02:05 +00:00
Dmitrii Gridin 167c247456 [LL FIR] rename AbstractInnerDeclarationsResolvePhaseTest to AbstractWholeFileResolvePhaseTest
^KT-60728
2023-07-27 12:02:05 +00:00
Dmitrii Gridin b1b123efc0 [LL FIR] merge innerDeclarationsResolve testData to fileStructure
^KT-60728
2023-07-27 12:02:05 +00:00
Dmitrii Gridin bba1eeac82 [LL FIR] AbstractInnerDeclarationsResolvePhaseTest use .txt instead of .fir.txt
^KT-60728
2023-07-27 12:02:05 +00:00
Dmitrii Gridin 8a906004e3 [LL FIR] do not resolve declarations from script separately
It leads to exceptions because of race.
We shouldn't try to resolve a script and its content simultaneously,
because it is not thread-safe

^KT-60728
2023-07-27 12:02:05 +00:00
Dmitrii Gridin 6fa254c353 [LL FIR] merge diagnosticTraversalCounter testData to fileStructure
^KT-60728
2023-07-27 12:02:04 +00:00
Dmitrii Gridin 9970663a2b [LL FIR] add script tests for AbstractFirContextCollectionTest
^KT-60728
2023-07-27 12:02:04 +00:00
Dmitrii Gridin 3ed5ccbb6f [LL FIR] add script tests for AbstractFileStructureTest
^KT-60728
2023-07-27 12:02:04 +00:00
Dmitrii Gridin c79bdd8ce3 [LL FIR] drop granular resolve from scripts
Effectively, KtScript currently resolves as a monolith,
so we have problems because some declarations have
their own locks, but some others are not
This change fixed many exceptions

^KT-60728
2023-07-27 12:02:04 +00:00
Dmitrii Gridin e248d1a588 [LL FIR] add script tests for AbstractFileBasedKotlinDeclarationProviderTest
^KT-60728
2023-07-27 12:02:04 +00:00
Dmitrii Gridin aa36e2ef5b [LL FIR] add script tests for AbstractNonLocalDeclarationAnchorTest
^KT-60728
2023-07-27 12:02:04 +00:00
Dmitrii Gridin 60dc0ace47 [LL FIR] add script tests for AbstractClassIdTest
^KT-60728
2023-07-27 12:02:04 +00:00
Dmitrii Gridin c01c113af4 [AA] implement infrastructure for scripts
^KT-60728
2023-07-27 12:02:04 +00:00
Dmitrii Gridin e5cd674f33 [AA] split KtSourceModuleImpl on separate files
^KT-60728
2023-07-27 12:02:04 +00:00
Dmitrii Gridin 3518aa5898 [LL FIR] ANNOTATIONS_ARGUMENTS_MAPPING: drop intermediate state with lazy arguments
This is safer because we can be sure that no one can
read an intermediate result with lazy expressions (related to KT-60387)

^KT-60552 Fixed
2023-07-26 12:27:16 +00:00
Dmitrii Gridin 65fec8dc19 [LL FIR] StateKeeper: provide context
We need this to be able to construct new elements on the fly
during arrangement

^KT-60552
2023-07-26 12:27:16 +00:00
Dmitrii Gridin d93ffe0aec [FIR] add missing resolve for ConeFunctionExpectedError building
^KT-60638 Fixed
2023-07-25 10:55:41 +00:00