196 Commits

Author SHA1 Message Date
Tagir Valeev
838cf2d73c [java-incomplete-model] Assume that any unresolved class-type is assignable to java.lang.Object
Partially improves inference in incomplete mode

GitOrigin-RevId: 1d9c7c75afd524ea02980be8f96c19fba1eaaf54
2024-06-25 13:54:11 +00:00
Tagir Valeev
5ae32b3ec9 [java-analysis] LambdaUtil.isSafeLambdaReplacement: check all calls in-between; check applicability
Fixes IDEA-350194 Inspection QuickFix results in compilation error

GitOrigin-RevId: fb83bfcb4e4aef9dc87a5c84de6d08202dd52ec6
2024-04-16 19:06:42 +00:00
Bas Leijdekkers
1a3fa9f4f8 Java: clarify quick-fix text when collapsing to noneMatch() (IDEA-309845)
GitOrigin-RevId: 0890d9367b880820af1125b0cb292916b29c238c
2023-01-09 20:19:46 +00:00
Bas Leijdekkers
86f0b63857 Java: better quick fix texts for "Loop can be collapsed with Stream API" and "Simplifiable forEach() call" inspections
GitOrigin-RevId: c4db6507c258e5611f6d47b9373a0c2531802345
2022-12-23 13:26:29 +00:00
Andrey.Cherkasov
f78c90027c [java-inspections] StreamApiMigration: "Replace with collect" fix produces wrong code for record patterns
IDEA-300726

GitOrigin-RevId: 83c638a60f4dee0a363b285535e808140e853fae
2022-08-29 17:03:09 +00:00
Tagir Valeev
7e1064ea3c [java-intentions] More preview tests; minor fixes
GitOrigin-RevId: 22a46c15d8900d8a31514846755a013f6a67ad42
2022-07-29 17:55:13 +00:00
Tagir Valeev
708adee03c [java-inspections] Loop-to-stream: fix unmodifiable after addAll (EA-409975)
GitOrigin-RevId: 7003f8e811725a9e7f8825c514ba359aa845ada7
2021-11-16 10:45:04 +00:00
Tagir Valeev
308d1fd0e6 [java-inspections] LambdaUtil#isSafeLambdaReplacement: check whether functional interface type matches exactly
GitOrigin-RevId: 04b67615268182a09ce3a211547dc8213997eb58
2021-10-20 13:09:36 +00:00
Tagir Valeev
bcb843dd8f [java-inspections] LambdaCanBeMethodReference: disable conversion in many cases when cast is required
Fixes IDEA-267865 Add a option for Java's method reference inspection that ignore lambda which can't convert into method reference without a cast

GitOrigin-RevId: b6f762383d6ba1ef19a5de36e0ad53d107ba4e80
2021-10-09 13:28:51 +00:00
Tagir Valeev
1184074aa6 [java-inspections] Support addAll migration (IDEA-264666)
GitOrigin-RevId: 1173e8e72064daa1896e8452ec1d895949d799b3
2021-03-19 05:48:21 +00:00
Tagir Valeev
ea5e79ca14 [java-inspections] StreamApiMigration: parentheses like (br).readLine()
GitOrigin-RevId: 9f71c7b1a41cd74abd0e51a0637a3da13ce955b6
2020-08-10 09:36:28 +00:00
Tagir Valeev
69a085809a Fix end-of-line comment handling
GitOrigin-RevId: f982435cd3a1659b0a1be1970cd5807419f16ccd
2020-06-03 09:09:48 +03:00
Tagir Valeev
26221c0641 IDEA-231237 Loop-to-stream conversion produces incorrect code if pattern variable is introduced
Also: pattern variable can be deleted via simple .delete()

GitOrigin-RevId: d3523f64d86de28d90b82d7bd98c1fd70567652d
2020-01-26 10:14:30 +00:00
Tagir Valeev
cca1cec121 IDEA-230363 Freeze in StreamApiMigrationInspection when StringBuilder-append-loop is followed by append to another StringBuilder
GitOrigin-RevId: c7bc72635a3322ecdd9eea6b47b997154a0ad014
2020-01-10 08:35:02 +00:00
Tagir Valeev
b04be5706b ReplaceCollectionStreamFix: handle comments
GitOrigin-RevId: 739c49a0f24a980ce19574b70cfe35c88c657026
2019-11-07 02:40:58 +00:00
Roman.Ivanov
970afc84ff JoiningMigration: remove unnecessary side effect check for prefix: IDEA-207456 2019-04-09 12:34:13 +07:00
Tagir Valeev
6bef676307 CollectMigration: do not wrap nullable values with toUnmodifiableList/Set (IDEA-207976) 2019-03-14 11:10:38 +07:00
Tagir Valeev
5c0748b0bc StreamApiMigrationInspection: BufferedReaderLines: support parentheses around readLine in while scenario 2019-02-18 12:37:12 +07:00
Anna.Kozlova
1ace9ab2c3 lambda -> method ref: reuse comment tracker (IDEA-189934) 2019-02-04 15:21:43 +01:00
Tagir Valeev
15e0df11f9 IDEA-206497 Replace with stream: support intermediate map operations in counting loops 2019-02-04 14:20:39 +07:00
Tagir Valeev
8da8dca8e0 IDEA-200455 Suggest to replace (a, b) -> a + b lambdas with Integer::sum, Long::sum, Double::sum 2019-01-31 14:21:13 +07:00
Tagir Valeev
cfd0c17038 IDEA-205308 'Replace with max()' produces uncompilable source 2019-01-15 13:14:19 +07:00
Tagir Valeev
a3ed07435e IDEA-205309 'Replace with findFirst()' produces uncompilable source 2019-01-15 12:32:12 +07:00
Tagir Valeev
725cf20422 IDEA-204917 "Loop can be collapsed with Stream API" creates uncompilable results in some cases
1. Look for references inside IntStream.iterate condition (Java9+)
2. When simplifying IntStream.range(...).map(i -> arr[i]) check if arr expression don't refer to i
2019-01-06 10:25:15 +07:00
Tagir Valeev
362b8d0b34 Stream API migration: do not convert continue statements which belong to the nested loops (IDEA-204250) 2018-12-18 12:28:52 +07:00
Tagir Valeev
66504c8088 BoolUtils: negate the equality token for float/double as this does not change the semantics (only >, >=, <, <= change) 2018-10-12 10:34:56 +07:00
Tagir Valeev
cee88f887b FindFirstMigration: use ifPresent when stream element type is primitive and the final statement is an assignment
This case is possible only if we have no non-final locals updated in the loop, so the assignment updates field or array element.
Using common assignment scenario may not work as primitive optionals lack map/filter operations
Fixes IDEA-200209 "Replace with findFirst" produces incompilable code
2018-10-10 15:55:53 +07:00
Tagir Valeev
c09250da45 CommentTracker#replaceAndRestoreComments: try to keep comments after the statement (not move them to the front) 2018-10-08 14:09:24 +07:00
Tagir Valeev
aee5f482a6 JoiningMigration: preserve comments in removed toString() call 2018-09-07 18:31:22 +07:00
Tagir Valeev
a0f1b41336 TerminalBlock: preserve comments after continue statement (not in the proper place though) 2018-09-03 19:57:02 +07:00
Tagir Valeev
ab3c5b7e5a OptionalUtil#getMapTypeArgument: support PsiEmptyExpressionImpl input
Fixes EA-125157 - IOE: PsiJavaParserFacadeImpl.createExpressionFromText
2018-07-26 17:41:49 +07:00
Tagir Valeev
625def0299 FoldExpressionIntoStream, StreamApiMigration: EquivalenceChecker used 2018-07-11 14:43:44 +07:00
Tagir Valeev
3fad9a22f4 PsiJavaCodeReferenceElementImpl: preserve tokens (comments/whitespace) between name element and parameter list 2018-07-11 14:43:42 +07:00
Tagir Valeev
ec98df958b StreamApiMigration: parentheses in BufferedReader.lines() scenario supported 2018-07-10 14:13:38 +07:00
Tagir Valeev
9ba38bc486 StreamApiMigrationInspection: skip parentheses in loop bound 2018-07-09 12:31:45 +07:00
Tagir Valeev
d516456163 CountingLoop: support parenthesized condition 2018-07-06 13:58:43 +07:00
Tagir Valeev
bd4a3477f5 StreamApiMigration: register comments from post-loop operations like sorting 2018-06-27 09:29:38 +07:00
Roman.Ivanov
5076e08145 set SPACE_BEFORE_COLON_IN_FOREACH true by default, fix tests 2018-06-26 12:04:00 +07:00
Tagir Valeev
79ed1b2dc3 shortenClassReferences: dequalify references which are statically imported 2018-06-14 10:08:16 +07:00
Tagir Valeev
f4839c89ea BaseStreamApiMigration: when deleting the initializer replace type with explicit if possible
Fixes IDEA-193618 Invalid code generated after "Can be replaced with 'collect' call"
2018-06-13 11:14:54 +07:00
Roman.Ivanov
5858ba478c fix tests for foreach formatting 2018-06-05 11:31:17 +07:00
Tagir Valeev
3c2cd21d35 MigrateToStreamFix: explicit formatting removed (as formatted anyways automatically) 2018-05-30 18:23:38 +07:00
Tagir Valeev
b336e70485 Less smart simplifications after loop-to-stream (keep stream) 2018-05-13 18:10:54 +07:00
Tagir Valeev
a1a4663b73 CollectMigration: support toUnmodifiableMap
Fixes IDEA-187213 Stream API migration: support Java 10 toUnmodifiableList/Set/Map collections
2018-04-17 15:06:35 +07:00
Tagir Valeev
2e6232e029 StreamApiMigration tests reorganized 2018-03-13 11:21:23 +07:00
Tagir Valeev
b2d5f75a92 StreamApiMigration: support Java10 toUnmodifiableList/Set (part of IDEA-187213) 2018-03-13 11:21:22 +07:00
Tagir Valeev
c483ae9cd0 ControlFlowUtils#getInitializerUsageStatus fixed for do-while loops where var is declared just before the loop 2018-02-21 12:24:01 +07:00
Tagir Valeev
d5f9284f2e ExpressionUtils#isSimpleExpression: disable for non-final fields 2018-02-05 15:53:39 +07:00
Tagir Valeev
3210510c96 CollectionUtils#isCollectionOrMapSize
Used in ToArrayCallWithZeroLengthArrayArgumentInspection and StreamApiMigrationInspection
2018-01-30 11:01:38 +07:00
Tagir Valeev
ac8ad2c822 IDEA-183326 Comment disappears in stream to loop 2017-12-06 17:47:22 +07:00