Commit Graph

2 Commits

Author SHA1 Message Date
Nikita Eshkeev
be5828b0ce [java][switch completion] IDEA-271902 Fix the completion tail in case labels
Eliminate the insertion handler for JavaPsiClassReferenceElement because it might be confusing to the users not to be able to set the variable name themselves.

In addition to that the patch also reverts the test data that was changed earlier because it was a perfectly fine piece of code and should not have been modified in the first place

GitOrigin-RevId: 7046e638ed8f4c1cae72aca600fdfd06eaa3a502
2021-07-12 19:10:45 +00:00
Nikita Eshkeev
c03aca779d [java][switch completion] IDEA-271902 Fix the completion tail in case labels
Java didn't use to have switch expressions and the insert handler for switch statements simply inserted ":" at the end of a case label. In the presence of switch expressions such an automatic completion is not correct anymore.

The SwitchUtils#isRuleFormatSwitch method checks if the passed switch block is actually a switch expression, this fix allows TailTypes.forSwitchLabel return the correct tail type.

Type references in case labels are most likely used as a pattern matching variables, so JavaPsiClassReferenceElement overrides the handleInsert method which checks if it's appropriate to add a pattern variable to the declaration.

Signed-off-by: Nikita Eshkeev <nikita.eshkeev@jetbrains.com>

GitOrigin-RevId: 7b6d381d528136dbedc181ae756cef374938983a
2021-07-07 18:49:13 +00:00