Commit Graph

360 Commits

Author SHA1 Message Date
Bas Leijdekkers
bf4ea53ca5 Java: fix IndexOutOfBoundsException after changes for IDEA-326944
GitOrigin-RevId: 1a7aaa1416778b1cc3118d960d352d8bcc90f1cb
2023-08-31 15:17:10 +00:00
Tagir Valeev
79b66e1879 [java-inspection] IDEA-324051 Inspections to migrate to sequenced collections (Java 21)
GitOrigin-RevId: bd008786ab983b8e8f3966d182da3be1ca9dcb55
2023-08-18 19:11:48 +00:00
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
5394892f03 [java-inspections] IJ-CR-113042 IDEA-327488 skip switch expressions with throw statements if it returns constant value
GitOrigin-RevId: 193339fae8972c9576d75c7e60611c10f301fe3e
2023-08-16 12:00:10 +00:00
Tagir Valeev
5618627fa4 [java-highlighting] IDEA-326939 Support multi-pattern switch labels that define no variables
GitOrigin-RevId: fb0360f00314417c17566637db6bbda4c21e6faa
2023-08-16 08:59:25 +00:00
Mikhail Pyltsin
a16d27ed41 [java-inspections] IDEA-326230 EnhancedSwitchBackwardMigrationInspection supports comments more accurately
- added support comments right before rules
- preserve comments in code blocks

GitOrigin-RevId: 5f5123f5d51a0b72cb4ff29c50fbc667fd00e450
2023-08-11 17:50:09 +00:00
Mikhail Pyltsin
fc59d971af [java-inspections] IDEA-327488 skip switch expressions with throw statements if it returns constant value
GitOrigin-RevId: c876dd08fe42b936673bc40802bbca320672266e
2023-08-11 17:50:04 +00:00
Izmar Verhage
06190372c4 Deprecate AbstractStubIndex::get and migrate usages
In this commit we implement a logical implication of the fact
that StubIndex::get is deprecated, combined with the fact that
AbstractStubIndex::get is not deprecated but calls
StubIndex::get with the exact same arguments it received. The
absence of deprecation of AbstractStubIndex::get obfuscates
the fact that we want to phase out StubIndex::get calls.

Apart from deprecating said method, we add some convenience
methods in AbstractStubIndex inheritors that ensure a few things:
- The not-deprecated and preferred StubIndex::getElements is
  called with appropriate arguments, including a properly
  specialised requiredClass argument.
- Shorter syntax and DRY: only 3 arguments are required to pass
  into the convenience method, whereas getElements requires 2
  more. These 2 arguments are fields of the AbstractStubIndex
  inheritor, so it makes little sense to get them from there
  and pass them into StubIndex::getElements everywhere.

Wherever we can, these convenience methods are now used.

If you have access to JetBrains internal resources, also see:
https://jetbrains.team/p/ij/reviews/112930/timeline
https://jetbrains.slack.com/archives/CMDBCUBGE/p1691509451975689

GitOrigin-RevId: c51ef4de44aa85841799640b1ece9d291208dc69
2023-08-11 16:14:17 +00:00
Bas Leijdekkers
06764c5161 Java: update "Trailing whitespace in text block" for string templates (IDEA-326944)
GitOrigin-RevId: e45eb0c40c9a07715a37063b237314611cc2e012
2023-08-06 17:26:04 +00:00
Mikhail Pyltsin
2c12bf0ee5 [java-inspections] IDEA-326718 skip not reassigned variables
GitOrigin-RevId: acdfa3cd6fd701f6a61ca0a461d179b1bda107c7
2023-08-02 16:20:58 +00:00
Mikhail Pyltsin
b213c73b1f Revert "[java-inspections] IDEA-326718 skip not reassigned variables"
This reverts commit 4fab9dcc301b8848fc2f0dd106f79ae06025f4e2.

GitOrigin-RevId: 6a37e821f4e0a409aa17cbb29754e8cb248d79da
2023-08-02 11:16:55 +00:00
Mikhail Pyltsin
ce729788c2 [java-inspections] IDEA-326718 skip not reassigned variables
GitOrigin-RevId: 2fc35c81b44024a70b0d2094aa89b065401c9a87
2023-08-02 11:16:46 +00:00
Tagir Valeev
66d5a034d5 [mod-command] Move Presentation to top-level
GitOrigin-RevId: d9e495719328ca4fa9bb25bc8ce9a9d24c5ca5ce
2023-07-31 13:41:35 +00:00
Tagir Valeev
5f7ba99e21 [mod-command] ModCommands utility methods moved to ModCommand interface itself
GitOrigin-RevId: 56d8829b42d0942fd3a10bf6cdeca934f44f036e
2023-07-31 13:41:31 +00:00
Tagir Valeev
3e9a5182b4 [mod-commands] ActionContext moved to top-level
GitOrigin-RevId: 8a4621b5b48fed952c8a2865c8699039e42b1edb
2023-07-28 08:52:46 +00:00
Tagir Valeev
0d61f28ad5 [mod-commands] ModCommandAction#asQuickFix -> LocalQuickFix#from
GitOrigin-RevId: c8f2245707d267fe2412c2fd3da17bdb68557b20
2023-07-24 14:48:57 +00:00
Tagir Valeev
c0b3b031e7 [mod-commands] SetInspectionOptionFix -> UpdateInspectionOptionFix (ModCommand)
GitOrigin-RevId: a1916285a58398848a6ce3c477399b3a86370efc
2023-07-24 14:48:52 +00:00
Tagir Valeev
176f6a543e [mod-commands] ModUpdateInspectionOptions; used in several places
Also AddToInspectionOptionListFix; deduplicated

GitOrigin-RevId: e9e5beb4537af0c2944ad2ba69d1cf5346073311
2023-07-24 14:48:50 +00:00
Tagir Valeev
be9a7b3ed9 [mod-commands] Move ModCommands, PsiUpdateModCommandAction, and PsiUpdateModCommandQuickFix to analysis-api module
ModCommand clients should be able to avoid lang-api

GitOrigin-RevId: d85285f99e69067c35e9a1a3ea0787264406bc1d
2023-07-21 11:17:28 +00:00
Mikhail Pyltsin
0f30f2df13 [java-highlighting] IDEA-325916 Get rid of deconstruction patterns with pattern variables
GitOrigin-RevId: 10db5aec839b046de87ac01db919cbe6905728d1
2023-07-20 16:42:30 +00:00
Tagir Valeev
07d22ea643 [java-inspections] Do not fuse PriorityQueue and PriorityBlockingQueue into the stream operation
It's more efficient to construct these containers from the collection directly
Fixes IDEA-324751 Inefficient code suggested by the "Stream may be extended replacing PriorityQueue" inspection

GitOrigin-RevId: 4a1ee4882e4c0d5b303f14f5d3a643df5ecd9933
2023-07-19 08:54:40 +00:00
Tagir Valeev
aeca87cc26 [java-inspections] DeleteSwitchLabelFix converted to modcommand (IDEA-322693)
GitOrigin-RevId: c01de8d06f1ece38410eb60375d43f7808732177
2023-07-14 17:45:21 +00:00
Tagir Valeev
c79d364b26 [java-inspections] Convert BaseSwitchFix hierarchy to ModCommands (IDEA-322693)
Also: ActionContext for quick-fix wrapper may provide exact offset in the editor when it's inside the highlighting
Also: Remove empty line from switch block body when inserting new labels
Also: ModPsiUpdater: replace original template field values with defaults when possible

GitOrigin-RevId: 8caa7cfe27881e50677c01dd243e57cced4ce65b
2023-07-14 17:45:18 +00:00
Tagir Valeev
bac1bbfc69 [java-inspections] EA-854868 AIOOBE: OverwrittenKeyInspection$OverwrittenKeyVisitor.processCallSequence
GitOrigin-RevId: 5851c26875d8d6c0ed7ca218c1de9616557ab1ef
2023-07-13 12:05:38 +00:00
Tagir Valeev
d81e9a70bc [mod-commands] 'Fix all' action: provide summary on actions failed during batch mode
GitOrigin-RevId: 6e7425499ce4aaa192d82beb01fd985cb3ef5119
2023-07-11 07:52:50 +00:00
Fabrice Tiercelin
7ce127b0f9 [java-inspections] IDEA-324141 Use var for the inspection "Bulk 'Files.readAttributes()' call can be used"
PR#2508
Reviewed-by: Tagir Valeev <tagir.valeev@jetbrains.com>

GitOrigin-RevId: c3914e71028831bcd72121e0f3070d4ed1fc01db
2023-07-10 13:18:07 +00:00
Tagir Valeev
090e1b85cf [java-inspections] ParameterCanBeLocalInspection: inline superclass
GitOrigin-RevId: ff91063ec7dd20dbbeab56c65521d19934636a6b
2023-07-07 15:58:25 +00:00
Tagir Valeev
059257aec5 [java-inspections] ConvertFieldToLocalQuickFix: ModCommand; superclass inlined
GitOrigin-RevId: 62aa30ecb2fa401534fe71fc5960863f19aa068d
2023-07-07 15:58:22 +00:00
Tagir Valeev
6b65e3797e [java-inspections] More ModCommands (IDEA-322693)
GitOrigin-RevId: 872930704951f58571b072b6c85a5400574029f8
2023-07-07 15:58:15 +00:00
Tagir Valeev
1b71833b85 [java-inspections] Fix AccessModifier options
They were stored in string before, and the case of the string was inconsistent: lowercase when initialized but uppercase when changed from the form

GitOrigin-RevId: 522810c5bdf49c264f8591cf4c09cbadb7624213
2023-07-07 15:58:06 +00:00
Tagir Valeev
0ffaede2b9 [java-inspections] ClassCanBeRecordInspection: simplify options; convert to OptPane
1. Radiobuttons -> checkbox
2. Remove annotation class selector, keep only textual input field (decrease of usability but people would rarely type a class name explicitly there, as we have a quick-fix)
Part of IDEA-313775 Process remaining inspections that have swing options panel

GitOrigin-RevId: f481bf923209cecb668e3b41370b52af029b1ed6
2023-07-07 15:57:36 +00:00
Mikhail Pyltsin
06c12be0aa [java-highlighting] IDEA-323955 IJ-CR-110218 Record patterns support available only for Java 20 preview. Fix compiler errors and tests
GitOrigin-RevId: ab45d7a32412b84c130618b47530ae0ab6418084
2023-07-06 00:03:16 +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
bf21083eee [intention-preview] Disable trimming automatically if diff is empty; convert DIFF_NO_TRIM inspections to ModCommands
GitOrigin-RevId: f52087d0262c2e513bdcdf9fff7f51d432e94485
2023-07-04 19:08:34 +00:00
Tagir Valeev
a16c17a02e Zero-tolerance warnings fixed
GitOrigin-RevId: 5e3865ff1bf7aff0f09e87d42821f3d4dca49281
2023-07-04 19:08:27 +00:00
Tagir Valeev
cf2584bfdd [java-inspections] ReplaceWithConstantValueFix: suggest to extract side effects when applicable
Fixes IDEA-323618 Side-effect ignored by code assist

GitOrigin-RevId: 6206743a4af64948f95d722708e42caf05dda2f3
2023-07-03 21:09:36 +00:00
Tagir Valeev
99a30ec5b5 [java-inspections] AccessStaticViaInstance: batch-mode-friendly
GitOrigin-RevId: 21c547a9d826f07671e5f76b9de0c12c4ed793c6
2023-06-30 09:01:13 +00:00
Tagir Valeev
3df9a89271 [java-inspections] AccessStaticViaInstanceFix: mod-command
IDEA-323888 Replace 'side effect' dialog in Java quick-fixes with chooser

GitOrigin-RevId: 215c1987ee33c6fd14f6fe987bbd491fa3b78343
2023-06-30 09:01:06 +00:00
Tagir Valeev
640306d59f [java-inspections] RemoveAssignmentFix, JoinDeclarationAndAssignmentJavaInspection: mod-command action, with chooser
IDEA-323888 Replace 'side effect' dialog in Java quick-fixes with chooser

GitOrigin-RevId: 0ceadfeebf9bf294d5201a641922efba3b8a66be
2023-06-29 10:02:34 +00:00
Tagir Valeev
5b29f251c1 [java-inspections] RemoveInitializerFix2: mod-command action, with chooser
IDEA-323888 Replace 'side effect' dialog in Java quick-fixes with chooser

GitOrigin-RevId: 99e43ec42520ff407ad755c1b05cd5c9320bd273
2023-06-29 10:02:30 +00:00
Tagir Valeev
51c5999d0b [java-inspections] DeleteElementFix: ModCommand
GitOrigin-RevId: aefb109889b898b31067f369577f14433075e4e9
2023-06-29 10:02:27 +00:00
Tagir Valeev
2f1be4183d [java-inspections] More ModCommand fixes
GitOrigin-RevId: 0c09d9d462156b87b8cd8ef33d203d959a579baf
2023-06-27 11:08:29 +00:00
Bas Leijdekkers
ae4e392cdc Java: change reference graph method return type to avoid some unnecessary casts
GitOrigin-RevId: cbb043d4284bc30ad5137a75723f698a93e6594e
2023-06-26 16:29:03 +00:00
Bas Leijdekkers
7758ed9de2 Java: remove redundant ObjectUtils.tryCast() calls
GitOrigin-RevId: fe11b176cf9a14ec4e363b0ce099693302f76ab2
2023-06-26 16:29:02 +00:00
Tagir Valeev
ad40c945e2 [java-inspections] More quickfixes to ModCommand
GitOrigin-RevId: ccc6093d680712cb81c1325d997fb2771b61a0be
2023-06-25 19:05:51 +00:00
Tagir Valeev
2d3661c971 [mod-command] ModDeleteFile command; more fixes
GitOrigin-RevId: d1d1251165923ba7653875801ef56b9de00807da
2023-06-23 09:45:44 +00:00
Tagir Valeev
fe8778f422 [mod-command] Rename EditorUpdater -> ModPsiUpdater; move to analysis-api
GitOrigin-RevId: 41f8d5eb372f78e2c2c7d3a1257214c2b8c5f000
2023-06-22 10:54:21 +00:00
Tagir Valeev
d787947509 [java-inspections] More ModCommand quick-fixes
GitOrigin-RevId: 35f844688c7bb2be1953ec0ba776898df418dd99
2023-06-19 17:19:32 +00:00
Tagir Valeev
adbda9bffb [mod-command] ModDisplayError; used in FillPermitsListFix
GitOrigin-RevId: 58bb0f6a1a2b69a8131642ca25524d8fa6ce8b43
2023-06-19 17:19:25 +00:00
Tagir Valeev
88865252cd [java-inspections] More ModCommands
GitOrigin-RevId: 2411bfe677ce7c4c3eba363df904429f00e35504
2023-06-18 15:07:08 +00:00