70 Commits

Author SHA1 Message Date
Alexander.Likhachev 21b438f55d Replace the trove4j collections usages with the fastutil ones
The trove4j library is licensed under LGPL, and that causes some troubles while working with it. The fastutil library provides the same functionality in the context of our needs, and is licensed under the Apache license.
^KTI-1135 In Progress
2024-01-10 11:29:25 +00:00
Mikhail Glukhikh 050d74a22e FE: fix PlainJavaClassifierType.isRaw (take inner classes into account)
#KT-64090 Fixed
2024-01-08 08:33:03 +00:00
Dmitrii Gridin 3fcf5c47c2 [resolution] KotlinJavaPsiFacade: replace explicit EMPTY_SCOPE check with more general
Someone can request search for `LocalSearchScope.EMPTY` and we can
catch this case

^KT-62892
2024-01-04 15:20:38 +00:00
Dmitrii Gridin 37ccf5d4f3 [resolution] KotlinJavaPsiFacade: do not return classes with wrong ClassId
We shouldn't return from `findClass`/`findClasses` Java classes with
`ClassId` different from the requested one

^KT-62892
2024-01-04 15:20:38 +00:00
Ivan Kylchik 79c300209e [K2] Avoid type check for Kotlin's property in ConstUtils
When we check Java field for constant initializer, we could
be asked to get and check the type of Kotlin's property that
is used in this Java field. But there is no guarantee that the type
resolve phase was finished and this type is available. So we just
check for `const` modifier and skip type check.

#KT-63752 Fixed
#KT-62558 Obsolete
#KT-61786 Declined
2023-12-12 13:54:32 +00:00
Ivan Kylchik 1125891a13 [K2] Properly report diagnostics on const properties with Java usages
#KT-63752
#KT-59894
#KT-61920 Fixed
2023-11-29 16:33:18 +00:00
Kirill Rakhman ac203591e5 [FE, Java resolve] Support inheritors of sealed Java type without permits clause
This fixes a false negative NO_ELSE_IN_WHEN in K2 and incidentally
also fixes a false positive NO_ELSE_IN_WHEN in K1 since the fix is in
the common code.

#KT-62491 Fixed
2023-10-31 13:41:56 +00:00
Ilya Kirillov f11cb277cd Remove obsolete @OptIn(ExperimentalStdlibApi::class) annotations
They were added when `buildList`, `buildMap` and `buildSet` were experimental.

^KT-62510
2023-10-12 10:41:00 +00:00
Dmitriy Novozhilov 9e5ee3afa0 [FE] Add isLocal name to ClassId constructor calls where it needed 2023-09-21 12:40:44 +00:00
Bogdan Mukvich 7b00323b89 [Build] Update guava
Fix some reports from "Show Vulnerable Dependencies"

^KTI-1342
2023-08-25 14:10:37 +00:00
Ilya Kirillov 5675c19f3b [Java Resolution, LL FIR] fix PsiInvalidElementAccessException from JavaClassifierTypeImpl.substitutor
The cached `PsiSubstitutor` might be invalidated, in this case we should recompute the value

Also make the `JavaClassifierTypeImpl` to be thread safe

^KT-59667 fixed
2023-07-03 07:55:36 +00:00
Vladimir Dolzhenko 7e9a897ef3 Provide equals/hashCode based on psiElementSource
#KT-59445
2023-06-22 14:14:18 +00:00
Vladimir Dolzhenko d0477a6a30 Provide equals/hashCode based on original PSI to avoid potential PCEs
#KT-59445
2023-06-22 14:14:18 +00:00
Anna Kozlova 92bcf3b2d5 [psi] packageCache: avoid pair as a key
supposedly, when search for package is performed,
it's performed multiple times with different names
but for the same scope.
In this situation, extracting scope from key brings a lot of memory.
For IJ, it reduces load from 7Mb -> 4Mb
2023-06-22 12:52:03 +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 2bbf57c15e JavaElementCollectionFromPsiArrayUtil: cleanup code 2023-06-12 16:41: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 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
Ilya Kirillov c78997d0f2 [Java Resolve] fix compilation of projects which use JavaElement compiler internals
The original problem was the KT-58194 where JavaElement's were reworked.

The rework changed the signatures of some declarations which were used in the KSP

^KT-59031 fixed
2023-06-05 12:21:36 +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 c114cb67cb [Java resolution] make it possible to provide custom source element for JavaElement
This is needed to allow using PSI pointers in IDE in JavaElement.
`JavaElement`s are reused between read actions,
so underlying PSI elements might be invalidated when using hard PSI references

^KT-58194
2023-05-31 13:01:19 +00:00
Anna Kozlova d491fd2f70 [LL] don't include kotlin classes in combined java provider
do not resolve annotations when short name doesn't match
2023-04-27 11:37:27 +00:00
Roman Golyshev d4cffb8a5a [213] Switch to 213 platform
KTI-1114
2023-04-21 13:19:04 +00:00
Marco Pennekamp 567abd2a1c KT-57207 Implement JavaClassFinder.findClasses
- This change is a prerequisite for allowing combined Java symbol
  providers (in LL FIR) to correctly disambiguate classpath order after
  getting classes with a combined scope, as the index access of the
  combined Java symbol provider is not guaranteed to return the class
  that should be first based on the original dependency order. To be
  able to disambiguate, a combined Java symbol provider needs access to
  all class candidates the index can find.
2023-04-17 11:07:47 +00:00
Marco Pennekamp 288606868e [FIR] KT-57207 Avoid FirJavaFacade.knownClassNamesInPackage in the IDE
- `FirJavaFacade.knownClassNamesInPackage` cannot be computed in the IDE
  using the current strategy because there are multiple finders and
  there is no `CliFinder`. However, the cache was still used, which
  caused it to be filled with `null` values and additionally caused
  worse performance in `JavaSymbolProvider` due to hash map accesses via
  `hasTopLevelClassOf`.
- Rewriting the strategy is non-trivial as additional indices are needed
  on the IDE side. See KTIJ-24642.
2023-04-17 11:07:46 +00:00
Denis.Zharkov 490970e65e Adjust KotlinJavaPsiFacade::knownClassNamesInPackage for empty scope
The method must return an empty set in that case, instead of null
that would mean we can't compute it.

The problem was found when running FirLoadCompiledKotlinGenerated
2023-01-19 10:57:44 +00:00
Dmitriy Novozhilov 259303ca50 [FIR] Fix loading of classId for nested enums in java annotation arguments
^KT-55887 Fixed
^KT-55976
2023-01-17 14:51:29 +00:00
Roman Efremov 25f65aff3a Replace getEntries with hardcoded PsiMethod in LC decompiled declaration
This adds NotNull annotation.

^KTIJ-23530 Fixed
2022-12-27 14:41:53 +00:00
Dmitriy Novozhilov d423782fac [FE 1.0] Remove usages of safeAs and cast from most of FE 1.0 modules:
- :core:descriptors
- :core:descriptors.jvm
- :core:deserialization
- :compiler:cli
- :compiler:frontend
- :compiler:frontend:cfg
- :compiler:frontend.java
- :compiler:frontend.common.jvm
- :compiler:psi
- :compiler:resolution
- :compiler:resolution.common
- :compiler:resolution.common.jvm
- :kotlin-reflect-api
2022-10-12 13:58:56 +00:00
Mikhael Bogdanov 90f8f8e14e Support inner classes in -Xjdk-release
#KT-52823 Fixed
2022-08-02 04:56:20 +00:00
Dmitriy Novozhilov 26df9d74e8 [FE] Add flag to java model to distinguish source java classes from binaries 2022-06-07 14:12:23 +00:00
Yan Zhulanow 8f1a2f4612 Improve heuristic for filtering synthetic enum methods out
It's not possible to check the exact method signature, as it is
unavailable in dumb stubs for Kotlin's light classes. Yet, it's still
possible to check more things, such as parameter count and access flags.
2022-03-14 17:53:55 +09:00
Hung Nguyen 1cb509d529 KT-45777: Remove proto-based approach to compute Java class snapshots
as the ASM-based approach is better, and we have switched to the
ASM-based approach for a while now.
2022-02-01 12:41:53 +03:00
Vyacheslav Gerasimov f7a9065b75 Build: Use intellij maven repo instead of downloaded IDEA
#KTI-82
2021-12-16 21:48:23 +03:00
Vyacheslav Gerasimov bc2f0936bd Build: Rename commonDep -> commonDependency 2021-12-16 21:48:19 +03:00
Vladimir Dolzhenko eaff4c6026 Reset elementFinders on clearPackageCaches()
Clean up references on a plugin unload to avoid class leakage

Relates to #KT-49475

Merge-request: KT-MR-4891
2021-11-01 14:21:15 +00:00
Denis.Zharkov 38fa900e56 FIR: Optimize case with no annotations on package 2021-09-23 16:58:26 +03:00
Hung Nguyen a342c81a9f KT-45777: Take snapshots and compute changes for Java classes
Create `JavaClassDescriptor`s for Java classes
Ignore anonymous and synthetic classes
as they can't impact recompilation.
Clean up handling of local and anonymous classes

Bug: KT-45777
Test: New JavaClassDescriptorCreatorTest
2021-09-01 13:29:17 +03:00
Dmitriy Novozhilov 82e3e00bf5 Fix compilation after migrating to ASM 9 2021-07-08 13:29:19 +03:00
Victor Petukhov 2e57ff25ee Leave KotlinCliJavaFileManager::findClass only passing JavaClassFinder.Request 2021-04-30 14:43:27 +03:00
Victor Petukhov bc5e92033b Support reading annotations on java 9 module on sources and binaries 2021-04-30 14:43:27 +03:00
Victor Petukhov 310d98c4f7 Don't require existence of the corresponding type argument during computing target type to apply type use annotation loaded from class file
^KT-46131 Fixed
2021-04-23 15:12:12 +03:00
Alexander Udalov e9a969875c Minor, fix typo in the issue reference in comment 2021-04-12 15:43:35 +02:00
Ilya Chernikov ca352c9556 Fix jvm method reading when descriptor and signature do not match
#KT-38325 fixed
2021-04-12 16:23:53 +03:00
Vyacheslav Gerasimov f2a892a972 Cleanup 201 and as41 bunch files 2021-03-30 14:23:43 +03:00
Ilya Muradyan 14d386223b [REPL] Fix unresolved imports caching
Before this fix, if some imports were not resolved during compilation,
this result had been saved in caches, and this import couldn't been
resolved during following compilations even if it was added to the
module dependencies. This commit adds special handling of resolution
caches for the REPL compiler.
2021-03-24 13:35:33 +03:00
Dmitriy Novozhilov ca26c193ae Make all hierarchies of JavaAnnotationArgument sealed 2021-03-05 13:00:12 +03:00
Dmitriy Novozhilov 1f6ce874a1 Don't fail on unsupported default values of java annotations 2021-03-05 13:00:12 +03:00
Dmitriy Novozhilov 745aa620d0 Reformat annotationArgumentsImpl.kt 2021-03-05 13:00:11 +03:00
Victor Petukhov 26a96a1c19 Don't throw an exception while loading type use annotations on implicit bounds of a wildcard
^KT-45067 Fixed
2021-02-24 21:06:32 +03:00