intellij-sdk-code-samples/code_samples/conditional_operator_intention
Yann Cébron cd23596f6b
223 release (#904)
* api_notable_list_2022.md: update unbundled plugins 2022.3

* element_patterns.md: new sample

* 2022.3 release: update GH links

* 2022.3 release: update GH links, #2

* EP list: initial, change android from GH to JB hosting temporarily + adapt links

* 223 release initial values

* stop recommending PreloadingActivity (internal API now)

* product specific EP lists

* element_patterns.md: minor

* code samples: upgrade

* extension_point_list.md: fix duplicate heading

* sdk_code_guidelines.md: update compatibility values

* spring_extension_point_list.md: update

* 223.7571.182
2022-11-30 20:31:23 +01:00
..
2022-11-28 17:31:11 +01:00
2022-11-30 20:31:23 +01:00
2022-11-28 17:31:11 +01:00
2022-11-28 17:31:11 +01:00
2021-11-08 17:31:16 +01:00

Conditional Operator Converter JetBrains IntelliJ Platform SDK Docs

Reference: Code Intentions in IntelliJ SDK Docs

Quickstart

Conditional Operator Converter provides an intention for converting the ternary operator into the if statement, i.e.:

public class X {
  void f(boolean isMale) {
    String title = isMale ? "Mr." : "Ms.";
    System.out.println("title = " + title);
 }
}

will become:

public class X {
  void f(boolean isMale) {
    String title;
    if (isMale) {
      title = "Mr.";
    } else {
      title = "Ms.";
    }
    System.out.println("title = " + title);
  }
}

To invoke the intention action, it is necessary to place the caret on the ? character of the ternary operator. The converter in the isAvailable method, has defined the token check to match JavaTokenType.QUEST, which is ? character.

Extension Points

Name Implementation Extension Point Class
com.intellij.intentionAction ConditionalOperatorConverter PsiElementBaseIntentionAction

Reference: Plugin Extension Points in IntelliJ SDK Docs