Commit Graph

36 Commits

Author SHA1 Message Date
Tagir Valeev
efbff7c99c [java-highlighting] Move guard expression to switch label
Part of IDEA-326939 Support multi-pattern switch labels that define no variables

GitOrigin-RevId: c236438af58e1c74a2bf12a5985b33cedadb9cbb
2023-08-18 08:18:06 +00:00
Mikhail Pyltsin
ab14666e4e [java-highlighting] 'case default' is the incorrect syntax, and it was replaced with the proper 'default' syntax.
GitOrigin-RevId: 72f8e7f6c9080db7cb0b89c0ed876eb949171e8f
2023-07-14 16:14:45 +00:00
Mikhail Pyltsin
4bc43b46f4 [java-highlighting] IDEA-323955 Record patterns support available only for Java 20 preview. Fix compiler errors and tests
GitOrigin-RevId: 5f856519e56e61818e95cf63766fb6a54c6283ad
2023-07-05 12:09:22 +00:00
Tagir Valeev
338f8674e2 [java-intentions] ConvertSwitchToIfIntention: properly add parentheses when equals() is used
GitOrigin-RevId: cf05261337ac10785b23338860ab039fca271373
2023-03-20 17:26:19 +00:00
Tagir Valeev
2b2d79fb6a [java-intentions] ConvertSwitchToIfIntention: fix brace handling
Fixes EA-795482 - IOE: JavaParserUtil.parseFragment

GitOrigin-RevId: 63fe89da84e4432fab8f8f191c139add97553640
2023-02-13 14:37:08 +00:00
Andrey.Cherkasov
8cfde5e798 [java-intentions] ConvertSwitchToIf: don't add explicit null check if the selector expression is not null
IDEA-300120

GitOrigin-RevId: d49fa3356b23ec87c8f493fc4cdacb0655e4b600
2022-08-18 20:46:01 +00:00
Andrey.Cherkasov
108dc80b56 [java-intentions] ConvertSwitchToIf: fix the intention according a switch throws NPE if the selector expression is null
IDEA-300120

GitOrigin-RevId: 5d77f98e7931e32a06cb3c54076978d317f78a98
2022-08-17 23:14:53 +00:00
Tagir Valeev
46c6cb94ad [java-intentions] EA-465575 - AE: JavaParserUtil.parseFragment
GitOrigin-RevId: 51d05798ab9a127508bcf531a3aa1a13cdda5aae
2022-08-01 18:23:37 +00:00
Tagir Valeev
8560c6a5d1 [java-inspections] More preview tests
GitOrigin-RevId: 571a82f66623887c1b5008963df842b2597c58c9
2022-07-27 10:00:31 +00:00
Tagir Valeev
7726f94f08 [java-inspections] Convert switch to if: respect precedence when generating .equals() call
Fixes EA-465575 - AE: JavaParserUtil.parseFragment

GitOrigin-RevId: 7a94ea5a231f0952d593e21857e8d89a27df2dd2
2022-03-09 14:15:19 +00:00
Alexandr Suhinin
5a1a3450b4 IDEA-274822 [convert switch to if] fix: avoid calls to PsiSwitchLabelStatementBase.isDefaultCase
GitOrigin-RevId: e72998a2f37c21d4c78096da3c45d56f1d7fd2aa
2021-08-03 06:43:20 +00:00
Alexandr Suhinin
8496dd3b7f IDEA-270441 IJ-CR-12027 convert switch to if: fix "null" class name for local Enums
GitOrigin-RevId: bd6d592522e497f7897c92799333630d611dc6e1
2021-07-20 09:42:18 +00:00
Alexandr Suhinin
35d2aba047 IDEA-270441 convert switch to if: support patterns and null
GitOrigin-RevId: 06cdce2583774907fc263b85fdd85624778fccdf
2021-07-19 15:25:40 +00:00
Tagir Valeev
9ca4341d7f [java-intention] BreakConverter#process fixed
isRemovable must be called before any modifications. Otherwise, previous modifications may affect its results.

GitOrigin-RevId: d05be1e54ba62e5ac18003bf54dab2abb16124ce
2020-08-03 09:51:38 +00:00
Tagir Valeev
ba72470db2 Suggest j and k for int type
GitOrigin-RevId: 964e58ddcbf7920d18274be6e05df40088f9ed32
2020-06-11 10:01:40 +03:00
Anna Kozlova
bd1a21a02a bump highest language level to 14, prepare to remove 13_preview
GitOrigin-RevId: ec42a9047ba63b0cbaddd8357d11ae2ed56ed6b6
2020-04-01 12:31:42 +00:00
Anna Kozlova
2e17e61cae remove language level 12 preview for 2019.3 release
IDEA would support latest preview only

GitOrigin-RevId: 6609e80acced9e1be07880c14de239f75afcc78b
2019-07-09 00:03:25 +03:00
Tagir Valeev
0835bd0976 ConvertSwitchToIfIntention: fix processing of empty blocks
IDEA-205137 `Replace Switch with If` produce exceptions
IDEA-205122 Unwrap switch fails with exception
2019-01-10 12:40:04 +07:00
Tagir Valeev
7addf9e702 IDEA-204717 Can't convert enhanced 'switch' to 'if' if a branch's body contains an end-of-line comment 2018-12-26 21:05:24 +07:00
Tagir Valeev
92048254c1 VariableNameGenerator: fixed failing tests 2018-12-21 13:31:29 +07:00
Tagir Valeev
bb990f4f13 ConvertSwitchToIfIntention: support Java 12 switch statements (no expressions) 2018-12-07 11:56:15 +07:00
Tagir Valeev
747aec38c9 ConvertSwitchToIfIntention: better comments handling 2018-10-23 15:34:51 +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
763ad22de9 Support local classes 2018-10-01 16:31:37 +07:00
Tagir Valeev
625c1cc676 ConvertSwitchToIfIntention: fixes after review IDEA-CR-37311:
1. Do not suggest intention if `default` case is not the last one and fallthrough is possible into or out of that case
2. Generate a code-block if side-effect should be extracted to variable
2018-09-27 10:17:10 +07:00
Tagir Valeev
1b4e5c1e39 Merge SwitchStatementWithSingleDefaultInspection into SwitchStatementWithTooFewBranches
Fixes IDEA-199499 Improve "Replace 'switch' with 'if'" action and make it a quick-fix for "Switch has too few branches"
Now default is not counted as branch in SwitchStatementWithTooFewBranches
2018-09-26 17:06:07 +07:00
Tagir Valeev
f859a4c439 Support BreakConverter in ConvertSwitchToIfIntention
Fixes IDEA-141261 'Replace 'switch' with 'if'' intention produces incorrect code if some 'case' clause contains 'break' statement inside 'if'
2018-09-26 11:58:20 +07:00
Anna.Kozlova
ae3afdbaf8 switch -> if: fix comments line breaks (IDEA-195383) 2018-07-11 13:02:10 +02:00
Anna Kozlova
a6db339c7d convert switch -> if: ignore whitespaces (IDEA-165260) 2018-06-29 20:20:36 +03:00
Anna.Kozlova
a1239e3f1f preserve comments: replace switch with if (IDEA-113518) 2017-12-28 18:09:41 +01:00
Bas Leijdekkers
8d6551408c fix ControlFlowUtil.canCompleteNormally() regression (IDEA-141259) 2017-07-24 19:34:17 +02:00
Bas Leijdekkers
aa515b08a1 generate "constant".equals(variable) code when converting switch to if (IDEA-157516) 2017-07-24 19:34:16 +02:00
Tagir Valeev
f2442e32fa ConvertSwitchToIfTest: test5 rewritten as getClass() is now pure 2017-05-18 14:36:52 +07:00
Bas Leijdekkers
9d49239ff4 EA-76495 (IOE: PsiJavaParserFacadeImpl.createStatementFromText) 2015-12-01 19:11:39 +01:00
Bas Leijdekkers
d57591cd2c IDEA-142912 (Intention: replace switch with if failed with bit operator (operator precedence)) 2015-08-27 17:45:58 +02:00
anna
9c91d9374f add convert switch to if for invalid switch types (IDEA-81580) 2012-02-23 11:50:19 +01:00