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 --- .../me/laria/code/idea_caseconv/SentenceCaseAction.java | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 src/main/java/me/laria/code/idea_caseconv/SentenceCaseAction.java (limited to 'src/main/java') 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 + ) + ); + } +} -- cgit v1.2.3-70-g09d2