- Instead of extending the API with `typeParameterNames`, this commit
creates a PSI-based Java type parameter symbol similarly to the
PSI-based Java class symbol. Because completion requires only the type
parameter name, this approach works fine, and without exposing an
optimization via the API.
- Instead of spreading `equals` and `hashCode` implementations over
`KtFirNamedClassOrObjectSymbol` and `KtFirPsiJavaClassSymbol`, this
commit introduces a shared base class.
- Some completion tests failed because the `hashCode` of
`KtFirNamedClassOrObjectSymbol` and `KtFirPsiJavaClassSymbol` was
different for symbols which should be equal. Both symbols now use the
`ClassId` hash code.
- `KtFirNamedClassOrObjectSymbol.equals` is now properly symmetric with
`KtFirPsiJavaClassSymbol`.
- `KtFirPsiJavaClassSymbol` now has a definite class ID, which
simplifies its implementation a little. `KtFirPsiJavaClassSymbol`
doesn't support local Java classes by design.
- Most Java classes aren't deprecated. To avoid building `firSymbol`
in such cases, this commit adds a simple heuristic which checks the
class's annotations for the presence of one of the deprecation
annotations recognized by the Kotlin compiler.
- Note that annotations are compared via simple names, so there is a
slight margin of error. However, comparing class IDs is more costly in
my tests, because getting an annotation's class ID is not as cheap as
getting its simple name.
- Completion accesses symbol type parameters to render their names.
Instead of building the whole list of type parameters, and
consequently the whole FIR class, completion can now access the type
parameter names directly.
- `KtFirVisibilityChecker` accessed `KtFirPsiJavaClassSymbol.firSymbol`
a significant number of times during completion, which led to many
instances of FIR class construction.
- This commit introduces a heuristic to `KtFirVisibilityChecker`
specifically for `KtFirPsiJavaClassSymbol` to bypass the compiler's
visibility checker. The fact that we're dealing with Java class
visibility from Kotlin makes this feasible without reimplementing the
full logic of `FirVisibilityChecker`.
- `FirJavaClass` gets all its annotations from the Java annotations, so
we can rely on `javaClass.annotations` to determine if any annotations
are present.
- Some completion performance tests (e.g. IntelliJ: "empty place typing
with library cache") spent a considerable amount of time in
`KtFirSymbolProviderByJavaPsi.getNamedClassSymbol`.
- This commit introduces `KtFirPsiJavaClassSymbol`, which implements
many `KtNamedClassOrObjectSymbol` properties with the `PsiClass`
instead of the FIR class. The `FirClassSymbol` is built only when
necessary. This improves performance when no "slow" properties need to
be computed for the symbol.
^KT-56617 fixed
Historically flag was enabled for Gradle projects, but we don't have fir-based JavaTracker for the K2 compiler for now, so we need to use a fallback strategy.
Note: it was disabled for tests with K2
Note2: after adding a fir-based java classes tracker this value should be set to true (KT-57147)
#KT-56886 Fixed
Merge-request: KT-MR-9053
Merged-by: Aleksei Cherepanov <aleksei.cherepanov@jetbrains.com>
During a translation of the code from js() call to statement list,
the compiler folds the code string. For that it uses property bodies.
However the bodies can not be loaded in an incremental rebuild.
The patch uses the backing field initializers of constant properties.
The initializers are always loaded.
^KT-57002 Fixed
Normally, compiled declaration searcher should look up declarations
only inside the session declarations. However, built-ins are treated
as a separate dependency, so '...WithoutDependencies()' functions
return only a part of declarations for the Kotlin standard library.
This commit effectively reverts changes in the previous change
(07fdbeca19).
This commit fixes the rest of failing compiletion tests:
- HighLevelJvmBasicCompletionTestGenerated
- HighLevelMultiFileJvmBasicCompletionTestGenerated
The main motivation is to avoid pollution in autocompletion in IDE, and
avoid clashes for some common names.
A lot of stuff was declared public seemingly by accident. It is only
used, and can only be meaningfully used, from within the psi2ir module.