diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeAndUnderscoreMacro.java b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeAndUnderscoreMacro.java
index 8ae675bf464e..f7e134f41f0a 100644
--- a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeAndUnderscoreMacro.java
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/CapitalizeAndUnderscoreMacro.java
@@ -32,23 +32,31 @@ public class CapitalizeAndUnderscoreMacro extends MacroBase {
super("capitalizeAndUnderscore", CodeInsightBundle.message("macro.capitalizeAndUnderscore.string"));
}
+ protected CapitalizeAndUnderscoreMacro(String name, String description) {
+ super(name, description);
+ }
+
@Override
protected Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick) {
String text = getTextResult(params, context, true);
if (text != null && text.length() > 0) {
final String[] words = NameUtil.nameToWords(text);
boolean insertUnderscore = false;
- final StringBuffer buf = new StringBuffer();
+ final StringBuilder buf = new StringBuilder();
for (String word : words) {
if (insertUnderscore) {
buf.append("_");
} else {
insertUnderscore = true;
}
- buf.append(StringUtil.toUpperCase(word));
+ buf.append(convertCase(word));
}
return new TextResult(buf.toString());
}
return null;
}
+
+ protected String convertCase(String word) {
+ return StringUtil.toUpperCase(word);
+ }
}
diff --git a/platform/lang-impl/src/com/intellij/codeInsight/template/macro/SnakeCaseMacro.java b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/SnakeCaseMacro.java
new file mode 100644
index 000000000000..9e5d8ac25106
--- /dev/null
+++ b/platform/lang-impl/src/com/intellij/codeInsight/template/macro/SnakeCaseMacro.java
@@ -0,0 +1,30 @@
+/*
+ * Copyright 2000-2013 JetBrains s.r.o.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package com.intellij.codeInsight.template.macro;
+
+/**
+ * @author yole
+ */
+public class SnakeCaseMacro extends CapitalizeAndUnderscoreMacro {
+ public SnakeCaseMacro() {
+ super("snakeCase", "snakeCase(String)");
+ }
+
+ @Override
+ protected String convertCase(String word) {
+ return word.toLowerCase();
+ }
+}
diff --git a/platform/platform-resources/src/META-INF/LangExtensions.xml b/platform/platform-resources/src/META-INF/LangExtensions.xml
index 737fc16383aa..99595f0058b8 100644
--- a/platform/platform-resources/src/META-INF/LangExtensions.xml
+++ b/platform/platform-resources/src/META-INF/LangExtensions.xml
@@ -432,6 +432,7 @@
+