58 Commits

Author SHA1 Message Date
Tagir Valeev
9e458c909c [java-highlighting] checkLabelSelectorCompatibility extracted and moved to SwitchChecker
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: bec076c5bff67e22d06e64e573d3219a4c89dd4d
2025-02-19 17:57:38 +00:00
Tagir Valeev
f8b210a481 [java-highlighting] Minor fixes in switch statement highlighting
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: 2924ae6c9984caa6e8a45f640c4de54e02134ad3
2025-02-19 14:57:00 +00:00
Tagir Valeev
cb626d5749 [java-highlighting] checkSwitchSelectorType migrated
Error messages unified; do not list allowed switch types anymore
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: 69675af87ac8866fb5ba1475094b93af07aa1ad5
2025-02-18 09:36:18 +00:00
Tagir Valeev
e6691d9ea8 [java-highlighting] SwitchBlockHighlightingModel.checkSwitchBlockStatements migrated
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: 463b1549d45bf98586e6ae9dafb4bc4b330bbe52
2025-02-18 09:36:18 +00:00
Tagir Valeev
2350d69472 [java-highlighting] JavaCompilationErrorBundle.properties proofreading (DOC-34381)
GitOrigin-RevId: 05bdca159a63027ea0d1e3d767d4adb9b258f47e
2025-02-14 12:45:24 +00:00
Tagir Valeev
9314a671b8 [java-highlighting] checkSwitchExpressionHasResult migrated
Also use ControlFlow instead of ig ControlFlowUtils to check normal completion. Otherwise, it thinks that System.exit() doesn't complete normally
Also fix (hopefully) yield in finally in ControlFlowUtil.canCompleteNormally
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: efa0cd4b8f478b98e904186005b7802e958507ae
2025-02-07 12:04:27 +00:00
Tagir Valeev
cc643a5ae4 [java-highlighting] More control-flow-related stuff migrated
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: 3c292fdf4869e6d13c16fabbf42e2055ea54f724
2025-02-06 10:35:32 +00:00
Tagir Valeev
2b4707f2ef [java-highlighting] checkVariableExpected; yield checks migrated
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: e4261df8c429a46d6aa238b7dcb4a97fdc45f9eb
2025-01-30 09:37:04 +00:00
Tagir Valeev
c449c341b7 [java-highlighting] test-data adjusted (mostly anchors) after recent updates
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: 1e1b77009dc78de49c7cc5c44d4704937397bb23
2025-01-29 11:35:30 +00:00
Tagir Valeev
a891bc5b66 [java-highlighting] break, continue errors -> StatementChecker; wording adjusted
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: c16e11baec8b9191ac809a34fc919a4375dd0ebd
2025-01-28 17:28:10 +00:00
Tagir Valeev
059a080ab3 [java-highlighting] Fix testdata, tooltips
Part of IDEA-365344 Create a new Java error highlighter with minimal dependencies (PSI only)

GitOrigin-RevId: ed0cf0daf5dbfb034882d49ad5e9c03f264b451e
2025-01-22 10:33:39 +00:00
Mikhail Pyltsin
e01d24d5c8 [java-highlighting] IDEA-357866 Spurious "Different case kinds used in the switch" error on incomplete code
- fixes
- not double error messages

GitOrigin-RevId: 8f789243ee4e09d3eb8de6a2db7dcbe25ee517db
2024-08-22 16:03:56 +00:00
Mikhail Pyltsin
cd14483af8 [java-highlighting] IDEA-357866 Spurious "Different case kinds used in the switch" error on incomplete code
- improve error message

GitOrigin-RevId: 2a8da472e07dd10bdb0ae75e679b6056ab884b72
2024-08-22 16:03:56 +00:00
Mikhail Pyltsin
3f18cddb20 [java-highlighting] IDEA-325375 Exhaustive switch expressions can produce definitely assigned variables. Fix type ranks
GitOrigin-RevId: 1a36f38c08e51d4cafb897a2b8ace796a74ec298
2023-07-17 17:05:57 +00:00
Mikhail Pyltsin
82b6cf4e7d [java-highlighting] IDEA-325375 Exhaustive switch expressions can produce definitely assigned variables
GitOrigin-RevId: 013d2367e1fa08189272343af83c5af9c2ad0582
2023-07-17 11:27:45 +00:00
Mikhail Pyltsin
4f951e7be9 [java-highlighting] IDEA-324327 IJ-CR-110223 Constant associated with switch block must be used with primitives or String
GitOrigin-RevId: 56154226d27f3c254f27cc8db27ca95d2f967ac1
2023-07-13 13:29:03 +00:00
Mikhail Pyltsin
5237df5eb3 [java-highlighting] IDEA-324880 Exhaustive switches can produce definitely assigned variables
GitOrigin-RevId: 7e644a2565803fdd900830d986dba481aeb127db
2023-07-12 11:06:36 +00:00
Mikhail Pyltsin
21d97bbbb0 [java-highlighting] IDEA-324327 IJ-CR-110223 Constant associated with switch block must be used with primitives or String
GitOrigin-RevId: fab5d57dc37c1694607686e268072473ec60a4de
2023-07-11 13:30:16 +00:00
Mikhail Pyltsin
d64809acc7 [java-highlighting] IDEA-324586 Highlight duplicated values with casts in java 21. Fix for null
GitOrigin-RevId: 85c0a0e8608267502c300b150fa9c5df23521efb
2023-07-08 13:45:02 +00:00
Mikhail Pyltsin
4e03b09337 [java-highlighting] IDEA-324586 Highlight duplicated values with casts in java 21
GitOrigin-RevId: 1a34f534b4850b8ae0ea2a0e1f373fa6b3b8b847
2023-07-08 13:44:50 +00:00
Mikhail Pyltsin
b43535b550 [java-highlighting] IDEA-324439 Check duplication in switch with taking into account enum class
GitOrigin-RevId: 5d01e0d205c8db48f46fb6301664324f67373c65
2023-07-05 20:46:06 +00:00
Mikhail Pyltsin
0254c50753 [java-highlighting] IDEA-324327 Constant associated with switch block must be used with primitives or String
GitOrigin-RevId: 864329b3d6cbefdf9c72358064b1e14f2fc4a1e3
2023-07-05 12:09:28 +00:00
Mikhail Pyltsin
014b89199b [java-highlighting] IDEA-324307 Allow to use qualified name for enum in switch. Check duplicates
GitOrigin-RevId: 7bfce5172e1e6f398f01063449eaaeeb2d77f1c9
2023-07-05 12:09:26 +00:00
Mikhail Pyltsin
0537252af9 [java-highlighting] IDEA-324307 Allow to use qualified name for enum in switch
GitOrigin-RevId: e07468e0ce50883fadfc3d57a6666fa5a90d348d
2023-07-05 12:09:25 +00:00
Andrey Cherkasov
5e839de419 [java-highlighting] IDEA-313993 unreachable statement: false negative
GitOrigin-RevId: 396da7635b4bee1c921444c2b23f89f8c67e5895
2023-02-24 13:26:51 +00:00
Andrey Cherkasov
3f34cfe3ea [java-highlighting] 'switch' expression does not cover all possible input values: false positive on reference types
IDEA-309593

GitOrigin-RevId: f869a8a1a98fd7789f5d07290797205205733899
2023-01-18 12:12:10 +00:00
Bas Leijdekkers
b9a6e40f0c Java: render array initializer expressions, switch expressions and instanceof expression correctly
GitOrigin-RevId: aad22125d6c8cbea4c398282a0eabb429c65e735
2022-11-16 19:42:12 +00:00
Anna Kozlova
2fd039b5eb [java] redundant cast: don't suggest to remove cast in switch branches without expected type (IDEA-296622)
GitOrigin-RevId: 24bebef33ad6d01861a68df1470f2ed2f454c4c8
2022-06-24 20:48:12 +00:00
Tagir Valeev
59d575280b [java-analysis] One more test for IDEA-292666
GitOrigin-RevId: 7e414c417d92f34e4a207fe5d0b97dbbde144275
2022-05-02 16:23:21 +00:00
Tagir Valeev
325edf9af2 [java-highlighting] IDEA-202570 Unreachable statement inspection should highlight whole switch expression
Also, fixed unreachable statement highlighting in different cases

GitOrigin-RevId: 20b28272b51c77e3413e1ca143222d35199728bd
2021-12-08 02:48:47 +00:00
Anna Kozlova
49edf8a29d [java] [switch expressions] avoid dbl work when checking types of switch return expressions
IJ-CR-14340

GitOrigin-RevId: 40e79767d794f7b7fcc9bc4d3930051a1698ea86
2021-09-28 21:10:49 +00:00
Tagir Valeev
c2f73e212e [java-highlighting] Remove accidental comment
GitOrigin-RevId: 1e7870b6e1792f308d9aa42087489e14b8066d3d
2021-09-22 08:47:13 +00:00
Tagir Valeev
a89c1afdf4 [java-highlighting] Report non-initialized variables inside switch expressions
GitOrigin-RevId: b643ba3bb2594267a9377ecd7526c4c996ae1781
2021-09-21 12:33:12 +00:00
Anna Kozlova
0b768770f7 [java] raise error for void type expressions in switch (IDEA-278454)
GitOrigin-RevId: e44afc9d82e2e8211171fa5eb1b5dff90acab375
2021-09-20 10:35:15 +00:00
Anna Kozlova
c4d12028ea [java highlighting] check switch expressions assignability (IDEA-271947)
GitOrigin-RevId: 88f8323cf191138ca94420271be65539a94cfc7c
2021-06-22 09:39:13 +00:00
Roman Ivanov
b12c4d4231 [java] fix test data
GitOrigin-RevId: 61472708704a021e22e06a5c46a9f37509d045ea
2021-06-15 17:46:11 +00:00
Anna Kozlova
1705f01347 [java] lambda context: allow conditional with lambda branches in switch cases (IDEA-269928)
extract cast processing to the upper level as it's not allowed in conditions (^Tagir)

GitOrigin-RevId: 3e608c133d2b44d67f9b57721fbf62c04c2c4147
2021-05-26 19:26:22 +00:00
Anna Kozlova
890efeaded [java]: redundant cast: treat switch expression branches separately (IDEA-269929)
GitOrigin-RevId: 4eecfab7aff32bc69164b740d1bd36f9a29b6cda
2021-05-25 06:42:14 +00:00
Anna Kozlova
5ab478e48e [java] lambda context: allow conditional with lambda branches in switch cases (IDEA-269928)
GitOrigin-RevId: 5bdcade69a621a83cc88074dd566e401852d0fd0
2021-05-25 06:42:11 +00:00
Roman Ivanov
69b3bdfef9 JavaParser: remove outdated special casing for yield, prefer stmt
GitOrigin-RevId: fb804d972a8a2280146bfad740d92c93fd20861a
2021-04-29 05:45:30 +00:00
Artemiy Sartakov
79f7d4dd58 Revert "Sealed classes: restricted keyword/identifier -> contextual keyword (IDEA-257414)"
This reverts commit a3b7cb3c

GitOrigin-RevId: bc91ae528d6f836e9cf43c19e9923286c8de0a9c
2021-02-04 09:33:52 +00:00
Artemiy Sartakov
45d71a0820 Sealed classes: restricted keyword/identifier -> contextual keyword (IDEA-257414)
GitOrigin-RevId: a3b7cb3c6eb3a65f78cf473fb93ddfa9946dea38
2021-01-19 09:22:09 +00:00
Roman Ivanov
bbcb50af87 JavaParser: parse yield() as call
GitOrigin-RevId: 31b4b0f9687bbaa6d1df65e459dcbe05e5c2c6b4
2020-12-14 17:25:01 +00:00
Anna Kozlova
ff667732f6 java: make error message more clear (IDEA-254372)
GitOrigin-RevId: 5c5bf42e6b375c2611ce996ca13a8404477e1eae
2020-11-02 17:28:44 +00:00
Anna Kozlova
ee301e1ee9 java switch expressions: reverted previous commit on inferring type with null result expressions (IDEA-251801)
appeared to be a javac bug, filed https://mail.openjdk.java.net/pipermail/compiler-dev/2020-September/015075.html

GitOrigin-RevId: 74bb18f3b3d82cdfbbad77a883d826b52549b9ab
2020-10-02 07:56:51 +00:00
Anna Kozlova
8aafb282f3 java switch expressions: infer Object if one of branches has null type (IDEA-241470)
GitOrigin-RevId: 489d3413091cbd1a85348fae0a428e29b287f7e0
2020-05-25 22:47:41 +03:00
Anna Kozlova
1bc4cda08e java redundant cast: cleanup: visitor finally inverted
GitOrigin-RevId: 8b4449e6d9163c24b046aad9065e5ec055d6d62c
2020-05-11 08:33:17 +00:00
Tagir Valeev
c7cfd81bc2 Positive test added (IDEA-CR-62158)
GitOrigin-RevId: bafc04a87dd7b52f54938dc6dcb3a76cc32ee732
2020-05-05 05:11:19 +00:00
Tagir Valeev
b3ba7b6783 IDEA-239116 Switch expression without any results is not highlighted as erroneous
GitOrigin-RevId: 66580d3aa4a95e1fdb32b1a3131544560c9c432a
2020-04-29 10:51:14 +00:00
Tagir Valeev
34243206dc Report new restricted identifiers: 'yield' and 'record'.
Fixes IDEA-230808 Disallow usage of 'record' as type name
Fixes IDEA-226604 Disallow using the 'yield' as the class name since Java 14

GitOrigin-RevId: a97753893fd8d0dac98a1a76f499b8c9474c3a7f
2020-01-17 11:12:57 +00:00