From 1d07f7ba44163364b22521056e7ff774fc1b1185 Mon Sep 17 00:00:00 2001 From: Laria Carolin Chabowski Date: Thu, 1 Oct 2020 23:04:30 +0200 Subject: Add "Sentence case" conversion --- README.md | 1 + build.gradle | 2 +- .../me/laria/code/idea_caseconv/SentenceCaseAction.java | 17 +++++++++++++++++ src/main/resources/META-INF/plugin.xml | 9 ++++++++- 4 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 src/main/java/me/laria/code/idea_caseconv/SentenceCaseAction.java diff --git a/README.md b/README.md index 6e3e453..7b8c18a 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,7 @@ The plugin provides actions to convert to these cases: - `lower case` - `fLIP cASE` - `Title Case` +- `Sentence case` - `dot.case` The Plugin was inspired by the [Case Conversion Plugin for SublimeText](https://packagecontrol.io/packages/Case%20Conversion). diff --git a/build.gradle b/build.gradle index 47ffc27..04c248a 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ plugins { } group 'me.laria.code' -version '0.6.1' +version '0.6.2' sourceCompatibility = 1.8 diff --git a/src/main/java/me/laria/code/idea_caseconv/SentenceCaseAction.java b/src/main/java/me/laria/code/idea_caseconv/SentenceCaseAction.java new file mode 100644 index 0000000..8dace53 --- /dev/null +++ b/src/main/java/me/laria/code/idea_caseconv/SentenceCaseAction.java @@ -0,0 +1,17 @@ +package me.laria.code.idea_caseconv; + +import java.util.Optional; + +public class SentenceCaseAction extends SelectionReplacerAction { + @Override + protected String replace(String s) { + return WordSplitConverter.convert( + s, + " ", + (i, part) -> Optional.of(i == 0 ? + CamelCaseAction.ucfirst(part) + : part + ) + ); + } +} diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index 8711a15..84a690e 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -1,7 +1,7 @@ me.laria.code.idea_caseconv Case conversion - 0.6.1 + 0.6.2 Laria Chabowski @@ -17,6 +17,7 @@
  • lower case
  • fLIP cASE
  • Title Case
  • +
  • Sentence case
  • dot.case
  • How to use:

    @@ -30,6 +31,9 @@
    +
    Version 0.6.2
    +
    Add Convert case: Sentence case action
    +
    Version 0.6.1
    Add a short documentation on how to use the plugin
    @@ -86,6 +90,9 @@ + + -- cgit v1.2.3-54-g00ecf