- This improves the memory usage of `FileStructureElementDiagnosticList`
by avoiding lots of duplicate empty mutable maps. We can assume that
most diagnostics lists are empty, since code is usually green.
- I tested the memory consumption manually by opening all files in
`org.jetbrains.kotlin.idea.k2.codeinsight.inspections` and waiting for
analysis to finish for each file. With the change, the retained size
of `FileStructureElementDiagnosticList` shrank from 63.39kB to
13.77kB.
It is duplicated because we have two checkers: FIR (for IDE support
in simple cases) and IR ("honest" checker supporting all cases).
Fix this by running FIR checker only in IDE.
FIR checker behavior remains covered by tests in
`LLFirPreresolvedReversedDiagnosticCompilerFE10TestDataTestGenerated`.
^KT-62559 Fixed
When flattening a dependency FirSymbolProvider, make sure transitive
dependency FirSymbolProviders are not included. This requires checking
that nested symbol provider sessions match the composite symbol provider
session when they are both source sessions.
^KT-60614 Fixed
Without it, the lazy body of code fragment is not properly resolved
and cannot be analyzed
Use the correct function from `BodyResolveContext` to take the scopes
from code fragment into account
^KTIJ-27879 Fixed
As a file annotation container is required for resolution,
it should be closer to the resolution logic. Now only LLFirTargetResolver
will operate this logic, so we can change the logic in the future without
a big refactoring.
E.g., as the next step, this resolution can be integrated to the file
^KT-63042
This entry point is required to be able to pre-resolve dependency
declarations.
E.g., fake override declaration shares annotation instances between
the original and the fake one, so we should resolve the original
firstly to avoid concurrent modification and correct context.
This will be done later.
This commit effectively only drops body resolution for a file annotation
container if the target element is not a file because this
is not required for correct resolution
^KT-63042
To make it possible to change nullability of IrCapturedType and change
its annotations, which is happening when determining overridability of
functions via IR.
#KT-63437 Fixed
getServiceIfCreated doesn't create a service instance if id wasn't
created before. There are no other service requests for
KotlinLabelProviderService, so it was not used for file types.
KTIJ-27755
- PSI tree change events from the IDE aren't necessarily paired. For
example, when we delete a contract statement via `PsiElement.delete`,
only "after removal" PSI tree change events will be published.
- Previously, the declaration modification service would not see such
contract removal as an out-of-block modification because it didn't see
the already removed contract in the associated function. As there is
no "before removal" event, the service had no chance to discover the
contract removal.
- This fix adds the removed element as a property of `ModificationType`.
While the element will already be removed and its parent will be a
dummy holder, we can still analyze its PSI to determine whether it is
a contract.
^KT-63538 fixed
- The root cause of the exception in KT-62982 is that symbol light
classes are accessed in dumb mode (see KT-63490). Nonetheless, we can
patch the exception by supporting `EnumGeneratedDeclaration` in
`getContainingPsi`.
- To create a symbol from the containing PSI,
`KtFirSymbolContainingDeclarationProvider` will still try and fail to
find the enum class symbol via symbol providers, but it'll fall back
to a designators search in the same `FirFile`, which will find the
symbol without index access (see `findSourceNonLocalFirDeclaration` in
LL API's `declarationUtils.kt`).
^KT-62982 fixed
- This commit rewords the coding conventions around `KtAnalysisSession`
and forbids usage of class context receivers. As explained in the
KDoc, classes opaquely capture their context receivers as properties,
which is a high-risk source of leakage.
Some boolean expressions could be transformed into `IrWhen`
node. To understand that this node is actually
a boolean expression, we need to analyze its origin.
#KT-62683
We should grab static scope before in the same way as scopesBefore
to not get already updated static scope with nested scopes.
Also, we should restore such "before" snapshots to avoid their modification
(this can be reproduced with in the next commit)
^KT-63042
We are resolving delegated constructor call in the wrong context
```
TYPES:
FILE: [ResolvedTo(IMPORTS)] superTypeCallNameClash.kt
public? open [ResolvedTo(SUPER_TYPES)] class Base : R|kotlin/Any|
public? final? [ResolvedTo(TYPES)] class MyClass : R|second/Base| {
public? [ResolvedTo(TYPES)] [ContainingClassKey=MyClass] constructor(): R|second/MyClass| {
LAZY_super<R|second/MyClass.Base|> // should be R|second/Base|
}
public? open [ResolvedTo(RAW_FIR)] class Base : R|kotlin/Any|
}
```
^KT-63042
At the moment, there is no good way to meaningfully filter `this`
expressions. The filters for the reference shortener can work only with
symbols, and it does not make a lot of sense to check any particular
symbol when deciding whether to shorten a labeled `this` expression.
We would probably need a better API for the shortener to be able
to filter more precisely (see KT-63555)
^KT-62675 Fixed
- `runWriteCommandAction`, which is required for PSI modification
functions like `PsiElement.delete`, must be invoked on the EDT.
However, instead of `runWriteCommandAction` we can use
`runUndoTransparentAction`, which does not need to be run on the EDT
and fulfills the same requirement.
^KT-63560
- We cannot configure the application's write action accessibility on a
per-test basis because (1) the application may be shared across
concurrent tests and (2) the application is usually cached, so the
configuration will be missed entirely.
- There is actually a much easier solution to allow write access
selectively: We can enable it in `runWriteAction` blocks, and keep it
in a thread local to support concurrent test runs. As Analysis API
tests never call `runWriteAction`, there will be no "analyze cannot be
called from a write action" error, and if `analyze` is somehow called
from a write action, it will now be caught.
^KT-63560 fixed
`allowNonCachedDeclarations` mode allows referring source declaration which
does not belong to the set of sources passed to fir2ir (e.g. for debugger
support). So if code refers to such declaration, fir2ir creates symbol
for it but not the IR declaration itself