import com.google.common.base.Strings;
import com.google.common.collect.Iterables;
import java.util.StringTokenizer;
+import java.util.regex.Pattern;
import org.opendaylight.yangtools.yang.common.QName;
final class YangTextTemplate {
private static final CharMatcher NEWLINE_OR_TAB = CharMatcher.anyOf("\n\t");
+ private static final Pattern MULTIPLE_SPACES_PATTERN = Pattern.compile(" +");
private YangTextTemplate() {
throw new UnsupportedOperationException();
final StringBuilder sb = new StringBuilder();
final StringBuilder lineBuilder = new StringBuilder();
- boolean isFirstElementOnNewLineEmptyChar = false;
final String lineIndent = Strings.repeat(" ", nextLineIndent);
-
- String formattedText = NEWLINE_OR_TAB.removeFrom(text);
- formattedText = formattedText.replaceAll(" +", " ");
-
+ final String formattedText = MULTIPLE_SPACES_PATTERN.matcher(NEWLINE_OR_TAB.removeFrom(text)).replaceAll(" ");
final StringTokenizer tokenizer = new StringTokenizer(formattedText, " ", true);
+ boolean isFirstElementOnNewLineEmptyChar = false;
while (tokenizer.hasMoreElements()) {
final String nextElement = tokenizer.nextElement().toString();
private static final CharMatcher TAB_MATCHER = CharMatcher.is('\t')
private static final Pattern SPACES_PATTERN = Pattern.compile(" +")
private static final Splitter NL_SPLITTER = Splitter.on(NL_MATCHER)
+ private static final Pattern TAIL_COMMENT_PATTERN = Pattern.compile("*/", Pattern.LITERAL);
new(GeneratedType _type) {
if (_type === null) {
return description;
}
- var ret = description.replace("*/", "*/");
- ret = AMP_MATCHER.replaceFrom(ret, "&");
-
- return ret;
+ return AMP_MATCHER.replaceFrom(TAIL_COMMENT_PATTERN.matcher(description).replaceAll("*/"), "&");
}
def protected String formatDataForJavaDoc(GeneratedType type, String additionalComment) {