public virtual string[] GetCleanedUpCommentTextLines(string[] commentTextLines, int columnIndex, CommentTerminal commentTerminal, out bool isDecorated)
{
if (commentTextLines.Length > 1)
{
bool _isDecorated = false;
commentTextLines = commentTextLines
.Select(
(commentTextLine, lineIndex) =>
{
string trimmedStartCommentTextLine = commentTextLine.TrimStart();
string trimmedStartMultiLineCommentDecorator = MultiLineCommentDecorator.TrimStart();
string trimmedMultiLineCommentDecorator = trimmedStartMultiLineCommentDecorator.TrimEnd();
if (trimmedStartCommentTextLine.StartsWith(trimmedStartMultiLineCommentDecorator))
{
_isDecorated = true;
return trimmedStartCommentTextLine.Remove(0, trimmedStartMultiLineCommentDecorator.Length); // decorated
}
else if (trimmedStartCommentTextLine.StartsWith(trimmedMultiLineCommentDecorator))
{
_isDecorated = true;
return trimmedStartCommentTextLine.Remove(0, trimmedMultiLineCommentDecorator.Length); // decorated with missing whitespaces at the right of decorator
}
else if (commentTextLine.Length >= columnIndex && commentTextLine.Take(columnIndex).All(ch => char.IsWhiteSpace(ch)))
return commentTextLine.Remove(0, columnIndex); // undecorated -> remove indentation
else
return commentTextLine; // undecorated -> could not remove indentation (the indentation of this line is smaller then the indentation of the start of the comment)
}
)
.ToArray();
isDecorated = _isDecorated;
return commentTextLines;
}
else
{
isDecorated = false;
return commentTextLines;
}
}