Commit Graph

2575 Commits

Author SHA1 Message Date
Mikhail Filippov
bf43f2fc01 IJPL-150165 bump Kotlin language and API version
GitOrigin-RevId: a59dc8ca214a5047773fccf1cf28a1e1b07acf68
2024-08-30 22:15:55 +00:00
Ilya Kirillov
c615e2eb1d [kotlin] J2K: remove const modifier from K2ConvertGettersAndSettersToPropertyProcessing when non-applicable
It's possible that the property was defined as const previously by Java analysis.
However, during `K2ConvertGettersAndSettersToPropertyProcessing`, a matching getter-like Java method was found that does not modify the original variable but will be attached to the original property as a getter.

The commit fixes the `org.jetbrains.kotlin.j2k.k2.K2JavaToKotlinConverterSingleFileTestGenerated.DetectProperties.testInObject` test for K1 and `org.jetbrains.kotlin.nj2k.NewJavaToKotlinConverterSingleFileTestGenerated.DetectProperties.testInObject` test for K1

KTIJ-31123

GitOrigin-RevId: 70396d1b801f59904d0592c24d64a4a203d3244b
2024-08-28 09:51:54 +00:00
Ilya Kirillov
daf3765276 [kotlin] J2K Java val/var preprocessing, clean up code
KTIJ-31123

GitOrigin-RevId: 69cf919015bdc9b634a40d68e51ec326964db23f
2024-08-28 09:51:54 +00:00
jocelynluizzi13
594102a78f [kotlin] J2K: process field and local variable mutability (var vs val) by Java pre-processing
^KTIJ-31123 fixed
closes https://github.com/JetBrains/intellij-community/pull/2827

GitOrigin-RevId: 442550e3656e0fd0e88c8e110519a491b120c21a
2024-08-28 09:51:54 +00:00
Roman Golyshev
890e8d0773 KTIJ-30883 [kotlin] Use different checks for static and regular imported members in Import Optimizer
Regular non-static declarations are always dispatched with implicit
receivers; thus, it is enough to find a compatible type in the
implicit receivers list to check if the declaration
is indeed imported or just dispatched.

On the other hand, static declarations do not depend on implicit receivers at all;
instead, they come from scopes which can be introduced only by extending a
Java class with static declarations.
So we have to traverse the scopes to do the check.

^KTIJ-30883 Fixed

GitOrigin-RevId: e2efe818ed45d34e8d3f3778dcb280d575378df9
2024-08-27 10:22:58 +00:00
Roman Golyshev
c42c03c84e KTIJ-26423 [kotlin] Adjust testData for J2K
GitOrigin-RevId: 5b289c907586d7d5972093a1de1bd64182770b83
2024-08-12 09:58:57 +00:00
Anna Kozlova
ae238bae5a [kotlin] j2k: disable formatting in postprocessing
- it should speed up write actions
- for some reason, indentation which is started during postformatting might leave uncommitted document which results in assertions

^KTIJ-30926 fixed

GitOrigin-RevId: f76a1e68b7ee226bd559f50bbfbf972d45005211
2024-08-09 20:28:54 +00:00
Alexey Belkov
0aba5a4e72 [kotlin] J2K: unignore K2 tests with K2-specific testdata
KTIJ-30693
KTIJ-30760

GitOrigin-RevId: 80dacdc6dcd7667d5b19771eb3ff192c577bd7d9
2024-08-09 19:19:40 +00:00
Alexey Belkov
3f9fd4a187 [kotlin] J2K: unignore identical K2 tests
KTIJ-30693
KTIJ-30760

GitOrigin-RevId: d736f543140b3aac080e15db6131178697c80b8d
2024-08-09 19:19:40 +00:00
Alexey Belkov
555118fe99 [kotlin] J2K: Support K2 MergePropertyWithConstructorParameterProcessing
KTIJ-30760

GitOrigin-RevId: 451e22b57140ad9d56b84a3a3b56510d6e9188d0
2024-08-09 19:19:40 +00:00
Alexey Belkov
bfe72d1ba0 [kotlin] J2K: move MergePropertyWithConstructorParameterProcessing to common module
KTIJ-30760

GitOrigin-RevId: 1536a8b117fbfcdebce2b1b294dfc41c76d08c79
2024-08-09 19:19:40 +00:00
Alexey Belkov
d746994dcd [kotlin] J2K: move function to common module
KTIJ-30760

GitOrigin-RevId: 7f0c4b537b0f9f057c93bbecaa706b8d7ca19948
2024-08-09 19:19:40 +00:00
Alexey Belkov
eabbd496e2 [kotlin] J2K: Migrate MergePropertyWithConstructorParameterProcessing to AAPI
KTIJ-30760

GitOrigin-RevId: ff18e0f9ecf09fc570f8a208043b03010c2212c6
2024-08-09 19:19:40 +00:00
Alexey Belkov
de80468e0a [kotlin] J2K: Migrate K2ConvertGettersAndSettersToPropertyProcessing to AAPI
KTIJ-30693

GitOrigin-RevId: 0f1292061d2ba69c7781cdca45901a9ff36173a8
2024-08-09 19:19:40 +00:00
Alexey Belkov
73e6a9b95d [kotlin] J2K: Rename file
KTIJ-30693

GitOrigin-RevId: 217f25805840d342f835b743a9fa4904054f128e
2024-08-09 19:19:40 +00:00
Alexey Belkov
01268d55e7 [kotlin] J2K: Recreate K1 ConvertGettersAndSettersToPropertyProcessing
KTIJ-30693

GitOrigin-RevId: ba43a38ee01fdbc894b0c19ce00dc4ae368a76d0
2024-08-09 19:19:40 +00:00
Alexey Belkov
ed954c5ca9 [kotlin] J2K: Move ConvertGettersAndSettersToPropertyProcessing to K2
This is an intermediate commit to preserve git file history.
The code doesn't compile yet.

KTIJ-30693

GitOrigin-RevId: 6a56798bc1b0396b519f15005f59e5cfee08c68b
2024-08-09 19:19:40 +00:00
Anna Kozlova
292f797c76 [kotlin] j2k: ensure appliers are performed in separate WA
- when WA is finished, postponed reformat happens which might block document for the next applier otherwise

^KTIJ-30622 fixed

GitOrigin-RevId: 66e7219f22ad80633c98ce4bf5593b12e0504ced
2024-08-09 08:32:37 +00:00
Anna Kozlova
b0517c6d15 [kotlin] j2k: align tests with production
KTIJ-30504

GitOrigin-RevId: 1186bf0118c4e2171586606eb339ecbc4545ff52
2024-08-09 08:32:37 +00:00
Vladimir Dolzhenko
8b3ee81536 [kotlin] Deprecate org.jetbrains.kotlin.idea.core.util.EDT
#KTIJ-30910

GitOrigin-RevId: 177f438ea07fd6cf1d06c22dc2309a885d6cb4ab
2024-08-08 16:44:21 +00:00
Anna Kozlova
aaf1a81ef1 [kotlin] j2k: register k2 preprocessor as such
- ensure tests use all registered pre-/post- processors

KTIJ-30504

GitOrigin-RevId: c98827a8954651930b364ee32f8e68be602f1814
2024-08-08 11:22:59 +00:00
Alexey Belkov
fbdb34b321 [kotlin] J2K: Remove redundant parentheses around Java ternary operator condition
^KTIJ-30900 Fixed

GitOrigin-RevId: b05a0b4ace13b64ad44ed7a1108608e4fa5cd8ad
2024-08-07 13:34:42 +00:00
Alexey Belkov
afd89f9ffd [kotlin] J2K: merge tests
GitOrigin-RevId: 81b235e304322f85f7bba0415a3980d9cbd21f03
2024-08-07 13:34:42 +00:00
Frederik Haselmeier
0f94431819 [kotlin] ported ConvertToIsArrayOfCallFixFactory to K2
^KTIJ-29495 fixed

GitOrigin-RevId: 696a761aea0f7c546f9923b6fa62e0ab2a5b15bb
2024-08-07 10:37:43 +00:00
Alexey Belkov
f1f610eab9 [kotlin] J2K: "unresolved reference" with getter/setter to renamed property conversion of private nested class
^KTIJ-30893 Fixed

GitOrigin-RevId: 7c9adab3da900bc369a11ba60b84893bb864eed1
2024-08-06 20:23:01 +00:00
Alexey Belkov
956f2afcc5 [kotlin] J2K: delete duplicate K2-specific testdata
GitOrigin-RevId: 54e438acc49ab600d3378d9302b51027e59115b6
2024-08-05 19:13:37 +00:00
Alexey Belkov
154f793b8f [kotlin] J2K: adjust K2 testdata
KTIJ-30775

GitOrigin-RevId: d54e2924963b9ad0e80e30ee5871ba99be0ccbd0
2024-08-05 19:13:37 +00:00
Roman Golyshev
4b234b7f4c KTIJ-26752 [kotlin] Adjust J2K testdata to changes in Import Optimizer
GitOrigin-RevId: 7162eb5d1909ae4a629df76641d6a6a5fcd6115f
2024-08-02 12:44:46 +00:00
Dmitriy Novozhilov
733f46a3ce [kotlin] Update j2k testdata after the fix of KT-69951
Related issue:
- KTIJ-29640
- KTIJ-30775

GitOrigin-RevId: c7a3afe1181dcfd87882377385a4a61a1d4a06f0
2024-08-02 11:42:34 +00:00
Alexey Belkov
98a1b4f7ce [kotlin] J2K: BuiltinMembersConversion: specify precise signatures of 'indexOf' and 'lastIndexOf' replacements
To be safe, we should probably do this for all replacement functions (KTIJ-30849).

^KTIJ-30832 Fixed

GitOrigin-RevId: f3ce8ba845b63f668e4e327884b20e06bde1a001
2024-08-01 15:43:40 +00:00
Frederik Haselmeier
236b594821 Revert "[Kotlin] Updated J2K tests to work with Kotlin 2.0"
This reverts commit 781486f26b3e1d51cebb582705a2dfa55f707ba1.

GitOrigin-RevId: 926ad440796556df029cc341f4086ef986cb9dfa
2024-07-31 17:19:19 +00:00
Frederik Haselmeier
e67fff0d31 [Kotlin] Updated J2K tests to work with Kotlin 2.0
KTIJ-30704

GitOrigin-RevId: 781486f26b3e1d51cebb582705a2dfa55f707ba1
2024-07-31 13:10:42 +00:00
Tagir Valeev
79b2382bf4 [java-psi] Support type annotations when parsing the lightAST (IDEA-356112)
GitOrigin-RevId: 0b1f29ad6b31b2b9e8d3f90db0e6431263cd3905
2024-07-30 16:34:11 +00:00
Alexey Belkov
8d904d0cff [kotlin] J2K: remove separate ReplaceGetterBodyWithSingleReturnStatementWithExpressionBody
^KTIJ-30797 Fixed

GitOrigin-RevId: 46a88f92b74c1fcbb1e0be8706251988df57007a
2024-07-29 14:45:31 +00:00
Alexey Belkov
c589610890 [kotlin] Don't report inspections "Redundant property getter" / "Redundant property setter" with comments
^KTIJ-30781 Fixed

GitOrigin-RevId: 1f0b2a067a5f432ec3d94109b21d9e53ee525c81
2024-07-29 14:45:31 +00:00
Alexey Belkov
66c96e5689 [kotlin] J2K: remove separate RemoveExplicitAccessorInspectionBasedProcessing
^KTIJ-30782 Fixed

GitOrigin-RevId: 0fd3e58cb380e96750e83c966a4eb7a52a30c703
2024-07-29 14:45:31 +00:00
Alexey Belkov
172223eca3 [kotlin] J2K: K2-specific testdata
GitOrigin-RevId: 0d09f3e3724cf87b6604649dc0dd53245ea683d5
2024-07-29 14:45:31 +00:00
Roman Golyshev
2b6f294f4a KTIJ-30581 [kotlin] Adjust refactorings and J2K testdata to the new Import Optimizer implementation
There are some improvements and some degradations.

Most notably, there is a "kotlin.concurrent.Volatile"
annotation replacement in J2K, which happens because
K2 references have problems with type aliases
(see KTIJ-25346 as one of the tracking issues).

GitOrigin-RevId: 8bf9a6a65d34fc335897e8209d09dedf350abc6c
2024-07-25 13:07:13 +00:00
Alexey Belkov
1e18c62013 [kotlin] K2 J2K: Check that Kotlin is configured in module before conversion
The implementation is 100% shared between K1 and K2 J2K and should work the same way.

^KTIJ-30641 Fixed

GitOrigin-RevId: 6942e58c746820b4413d692ce146aa445160a4b3
2024-07-24 14:38:46 +00:00
Alexey Belkov
4b51cc17f4 [kotlin] J2K: BuiltinMembersConversion: calculate correct type for new expressions
^KTIJ-30710 Fixed

GitOrigin-RevId: 186b158af092a5ab5e8c0aa2a393c174538c0edf
2024-07-23 09:22:39 +00:00
Alexey Belkov
d59d5d80ed [kotlin] J2K: Java JDK method converted to extension function should handle implicit casts on the receiver
^KTIJ-29839 Fixed

GitOrigin-RevId: 531d7c45b9a1a1a658f4c68741c760b1c073edaa
2024-07-23 09:22:39 +00:00
Alexey Belkov
434c48a6a0 [kotlin] J2K: BuiltinMembersConversion cleanup
KTIJ-29839

GitOrigin-RevId: 17e8fef73cceff91f64b5ed4425abc0acb3855cf
2024-07-23 09:22:39 +00:00
Alexey Belkov
713072b892 [kotlin] K2 J2K: Initial generic nullability inference
TODOs are listed in the J2KNullityInferrer Javadoc.

KTIJ-29147

GitOrigin-RevId: 2949b6d7c6b72b586ea6d3af89d0f2e655edcc6d
2024-07-17 11:55:13 +00:00
Alexey Belkov
64e631f7c9 [kotlin] J2K: rename file
KTIJ-29147

GitOrigin-RevId: a6984cef1a86c48fea2bbbbebc2dfdf6ceb57e7d
2024-07-17 11:55:13 +00:00
Alexey Belkov
e47357762f [kotlin] K2 J2K: add UnnecessaryNotNullAssertion post-processing
KTIJ-28575

GitOrigin-RevId: 3116e039b877d5a18b851528cb66b0bd00dc4e77
2024-07-17 11:55:13 +00:00
Eve Matthaey
68b54b47e8 [kotlin] J2K: Add extension point for custom pre- and post-processings
^KTIJ-29835 Fixed

closes https://github.com/JetBrains/intellij-community/pull/2784

GitOrigin-RevId: b887e694bd36c3369580a5c41c190acf9f38fd85
2024-07-17 11:55:13 +00:00
Vlad Koshkin
ce6f8813db Merge commit '813e61b202209c2216e28c3c9a58cb8b5d4c0682' into master-813e61b202209c2216e28c3c9a58cb8b5d4c0682
# Conflicts:
#	community/plugins/kotlin/core/src/org/jetbrains/kotlin/idea/references/KtFe10ReferenceResolutionHelperImpl.kt
#	community/plugins/kotlin/jvm-debugger/core/src/org/jetbrains/kotlin/idea/debugger/core/jvmNameUtil.kt
#	community/plugins/kotlin/refactorings/kotlin.refactorings.k2/src/org/jetbrains/kotlin/idea/k2/refactoring/inline/codeInliner/InlinePreprocessorUtil.kt

GitOrigin-RevId: de65740be8c1237da67bebcfd95aaf44db380104
2024-07-05 12:07:45 +02:00
Alexey Belkov
5f107cb4c3 [kotlin] J2K: Copy paste: UninitializedPropertyAccessException on pasting incomplete code with variable reference
The problem:

Step 1: `JKSymbolProvider#preBuildTree` runs a visitor over the converted Java PSI,
so it is able to visit every field/parameter and create a `JKUniverseFieldSymbol` for them (with unbound `target`).

Step 2: `JavaToJKTreeBuilder#buildTree` is only able to build a JK tree for certain entry points.
It can't handle some types of incoming PSI elements (for example, `PsiParameterList`),
so we can meet a situation when some incomplete code is copy-pasted, and some PSI nodes will not be
visited by `JavaToJKTreeBuilder`. In the case of fields/parameters, it means that `JKUniverseFieldSymbol#target`
will remain unbound. So, we will get an `UninitializedPropertyAccessException` on accessing it
in conversions or JKCodeBuilder.

^KTIJ-30470 Fixed

GitOrigin-RevId: ebead0d7f3c1a89a8dcbe4367efa6b0a07e79f85
2024-06-28 14:53:17 +00:00
Alexey Belkov
5148245bd1 [kotlin] J2K: EnumFieldAccessConversion cleanup
KTIJ-30470

GitOrigin-RevId: 9ac10b4ebcb5fd33657780e24838539ca09598cc
2024-06-28 14:53:17 +00:00
Alexey Belkov
fcf1eedfd4 [kotlin] J2K: Fix "pattern matching for instanceof" with unbound variable targets
In JavaToJKTreeBuilder we should avoid using `lateinit` symbol targets
because they may still be unbound (for example, first we visit the field usage
and then visit the field itself).

The change in PsiLambdaExpression to convert the lambda parameters first
is not required but generally seems logical.

^KTIJ-30444 Fixed

GitOrigin-RevId: 8ada888cb4c0a2581641e4972873e2ad8e0b40a6
2024-06-27 19:42:31 +00:00