void (Document document, RangeMarker range) { String prefix = getBlockCommentPrefix(); String suffix = getBlockCommentSuffix(); int start = range.getStartOffset(); int prefixStart = start = CharArrayUtil.shiftForward(document.getCharsSequence(), start, " \t\n"); if (CharArrayUtil.regionMatches(document.getCharsSequence(), prefixStart, prefix)) { start += prefix.length(); } int end = range.getEndOffset(); if (CharArrayUtil.regionMatches(document.getCharsSequence(), end - suffix.length(), suffix)) { end -= suffix.length(); } if (start >= end) return; for (int i = end - DOUBLE_DASH.length(); i >= start; i--) { if (CharArrayUtil.regionMatches(document.getCharsSequence(), i, DOUBLE_DASH) && !CharArrayUtil.regionMatches(document.getCharsSequence(), i, suffix) && !CharArrayUtil.regionMatches(document.getCharsSequence(), i - 2, prefix)) { document.replaceString(i, i + DOUBLE_DASH.length(), ESCAPED_DOUBLE_DASH); } } if (CharArrayUtil.regionMatches(document.getCharsSequence(), start, GT)) { document.replaceString(start, start + GT.length(), ESCAPED_GT); } if (CharArrayUtil.regionMatches(document.getCharsSequence(), prefixStart, prefix + "-")) { document.insertString(start, " "); } if (CharArrayUtil.regionMatches(document.getCharsSequence(), range.getEndOffset() - suffix.length() - 1, "-" + suffix)) { document.insertString(range.getEndOffset() - suffix.length(), " "); } }