Tagir Valeev
e23ddd35ef
[java-inspections] UnusedReturnValue: protect highestModifier access from NPE
...
Fixes EA-913143 - NPE: UnusedReturnValueLocalInspection.checkMethod
GitOrigin-RevId: 5607a59886de697a7586936f931db18bc0009c1b
2023-10-11 21:29:55 +00:00
Mikhail Pyltsin
0f76470f19
[java-inspections] IDEA-333452 Duplicate branch on switch. Improve work with comments
...
- now it can be suppressed properly
- show info level if the branches have different comments
GitOrigin-RevId: 5f1c5c0a67165b949b894d2d81c53800ad3b4b22
2023-09-27 19:37:38 +00:00
Aleksey Dobrynin
1153381d28
[java, inspections, fix] IDEA-323918 IJ-CR-115593
...
- replace redundant embedded expression
- modify documentation
- simplify code
- remove redundant Object
GitOrigin-RevId: e9dc34ea4343ea7bef98faeda6e4fe2e4599cb3c
2023-09-26 17:03:16 +00:00
Mikhail Pyltsin
3b921f8470
[java-inspections] IDEA-332919 IJ-CR-115330 Convert to old-style switch: produce incorrect code for guards
...
- fix space after comma
- increase java level for test
- improve comments
GitOrigin-RevId: 015afb81144e4787cfb61ae52f11b343c67f6b0b
2023-09-26 10:39:02 +00:00
Aleksey Dobrynin
c20f74f38c
[java, inspections] Add inspection to convert string concatenation to a string template IDEA-323918
...
GitOrigin-RevId: 266c49fb835bdd50c9c78b10f5ca1247b5c542da
2023-09-25 16:52:57 +00:00
Mikhail Pyltsin
7f404478c7
[java-inspections] IDEA-332919 Convert to old-style switch: produce incorrect code for guards
...
- preserve guards for patterns
- preserve comma-style for unnamed patterns
GitOrigin-RevId: c306280bded29ac3b6acb88b0ef6071bf50fefcb
2023-09-20 18:30:09 +00:00
Mikhail Pyltsin
e5b3e91017
[java-inspections] DuplicateBranchesInSwitchInspection improvements
...
- Leftovers after IDEA-326939
- merge branches and rules if they have the same guard
- not move branches and rules it they are not close (not to break dominance)
- allow to copy in guarded case
- not use firstLabel instead of full label set
GitOrigin-RevId: 289882c1be7275d33e97037217de8095f59346aa
2023-09-20 14:17:06 +00:00
Mikhail Pyltsin
fbd8b70ca6
[java-inspections] IDEA-332812 Convert to old-style switch: produce incorrect code for null, default
...
GitOrigin-RevId: f0de0aee91d2b41e1ebb6e7a815851cbbf5b8447
2023-09-19 15:55:49 +00:00
Tagir Valeev
623ee94480
[java-inspections] DuplicateBranchesInSwitchInspection improvements
...
1. Do not merge pattern with non-pattern branch
2. Colon labels with guards should not be merged into a single label
Leftovers after IDEA-326939
GitOrigin-RevId: 9fc54e643eda666771af2fc017dbef7d925dd76b
2023-09-19 01:24:53 +00:00
Yuriy Artamonov
c53774e2fc
[inspections] IDEA-321711 Use optimized PsiElementVisitor implementations
...
GitOrigin-RevId: 18ebc32aec877f71cd185ee7072dd139c076e9a3
2023-09-16 15:18:22 +00:00
Tagir Valeev
cdd7f0c627
[java-inspections] SequencedCollectionMethodCanBeUsed improvements (IDEA-324051)
...
Support add(0, x) -> addFirst()
Do not convert get(0), remove(0), add(0, x) when there are nearby calls of the same method with different constant indices
GitOrigin-RevId: b80871d6c2c0b4ad26f0970fe05129a9f1b9b61f
2023-09-12 14:53:31 +00:00
Mikhail Pyltsin
c93cfd1273
IJ-CR-111602 [java-inspections] --IDEA-313900 "Variable can be replaced with pattern variable" sometimes doesn't appear
...
- not run full analysis onTheFly
- suggest renaming for conflicts
GitOrigin-RevId: 6f6d601de6ccd4b46caf6943456adc0a5fe2290e
2023-09-12 01:22:14 +00:00
Alexey Kudravtsev
28669e48e1
optimization: visit only the relevant elements
...
GitOrigin-RevId: 1aa56500a0da1a3fce72a7efbb73057cf464c3f4
2023-09-07 19:14:23 +00:00
Mikhail Pyltsin
ef53b88b28
IJ-CR-113042 [java-inspections] IDEA-327488 skip switch expressions with throw statements if it returns constant value
...
- extracted useful method
GitOrigin-RevId: 9260dd539388d84b406f93ea5a23088a0252548d
2023-09-04 15:58:01 +00:00
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