mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
Naming convention macros should produce empty result on empty string 2
This commit is contained in:
+1
-1
@@ -41,7 +41,7 @@ class NamingConventionMacrosTest extends TestCase {
|
||||
assert "a_b_c_d_e_f_g" == snakeCase("a-b.c/d|e*f+g")
|
||||
assert "a_b" == snakeCase("a--b")
|
||||
assert "foo_bar" == snakeCase("FOO BAR")
|
||||
assert "" == snakeCase("0")
|
||||
assert "" == snakeCase("")
|
||||
}
|
||||
|
||||
public void "test lowercase and dash"() {
|
||||
|
||||
+5
-8
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2000-2010 JetBrains s.r.o.
|
||||
* Copyright 2000-2016 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.
|
||||
@@ -43,16 +43,13 @@ public class ConvertToCamelCaseMacro extends MacroBase {
|
||||
@Override
|
||||
protected Result calculateResult(@NotNull Expression[] params, ExpressionContext context, boolean quick) {
|
||||
final String text = getTextResult(params, context, true);
|
||||
if (text != null) {
|
||||
return convertString(text);
|
||||
}
|
||||
return null;
|
||||
return text != null ? convertString(text) : null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("StringToUpperCaseOrToLowerCaseWithoutLocale")
|
||||
@Nullable
|
||||
@NotNull
|
||||
@VisibleForTesting
|
||||
public Result convertString(String text) {
|
||||
public Result convertString(@NotNull String text) {
|
||||
final String[] strings = splitWords(text);
|
||||
if (strings.length > 0) {
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
@@ -65,7 +62,7 @@ public class ConvertToCamelCaseMacro extends MacroBase {
|
||||
}
|
||||
return new TextResult(buf.toString());
|
||||
}
|
||||
return null;
|
||||
return new TextResult("");
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user