com.cflint.tools.CommentReformatting Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of CFLint Show documentation
Show all versions of CFLint Show documentation
A static code analysis tool for ColdFusion (in the spirit of FindBugs and Lint). With CFLint, you are able to analyze your ColdFusion code base for code violations.
package com.cflint.tools;
import java.util.Stack;
public class CommentReformatting {
public static String wrap(String value) {
Stack stack = new Stack<>();
StringBuilder sb = new StringBuilder(value);
int pos = sb.indexOf(COMMENT_TEXT);
while (pos >= 0) {
int endpos = sb.indexOf(COMMENT_END_TEXT, pos);
int nextpos = sb.indexOf(COMMENT_TEXT, pos + 1);
if ((endpos > 0 && endpos < nextpos) || nextpos < 0) {
if (!stack.isEmpty()) {
sb.replace(endpos, endpos + 4, "-->");
sb.replace(pos, pos + 5, "";
}