intellij-sdk-code-samples/code_samples/conditional_operator_intention
Yann Cébron 5d4d1d75e9
2024.2 release (#1347)
* switch to 242, update gh-ic links

* fix link

* fix link

* fix link

* fix link

* regen EP lists

still some diff between 242 and EAP8

* convert gh-ic-master links

* GH code-samples: update PV IDE versions

* code samples: adjust target IDE&since/until values

* regen EP lists from release branch

* intellij_community_plugins_extension_point_list.md: fix duplicate heading

* intellij_community_plugins_extension_point_list.md: fix DevKit.lang.visitorProviderForRBCInspection EP

* GH: update PV versions

* 2024.2 GA
2024-08-07 09:59:03 +02:00
..
2024-07-16 10:59:02 +02:00
2024-08-07 09:59:03 +02:00
2024-07-16 10:59:02 +02:00
2024-07-16 10:59:02 +02: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