Browse Source

add foldings to documentation comments; closes #165

pull/166/merge
Siegfried Pammer 14 years ago
parent
commit
ba0b80856c
  1. 13
      ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs
  2. 2
      NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/IOutputFormatter.cs
  3. 4
      NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs
  4. 2
      NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/TextWriterOutputFormatter.cs

13
ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs

@ -17,6 +17,7 @@ namespace ICSharpCode.Decompiler.Ast
readonly ITextOutput output; readonly ITextOutput output;
readonly Stack<AstNode> nodeStack = new Stack<AstNode>(); readonly Stack<AstNode> nodeStack = new Stack<AstNode>();
int braceLevelWithinType = -1; int braceLevelWithinType = -1;
bool inDocumentationComment = false;
public TextOutputFormatter(ITextOutput output) public TextOutputFormatter(ITextOutput output)
{ {
@ -102,7 +103,7 @@ namespace ICSharpCode.Decompiler.Ast
output.WriteLine(); output.WriteLine();
} }
public void WriteComment(CommentType commentType, string content) public void WriteComment(CommentType commentType, string content, bool isLastLine = false)
{ {
switch (commentType) { switch (commentType) {
case CommentType.SingleLine: case CommentType.SingleLine:
@ -115,8 +116,16 @@ namespace ICSharpCode.Decompiler.Ast
output.Write("*/"); output.Write("*/");
break; break;
case CommentType.Documentation: case CommentType.Documentation:
if (!inDocumentationComment)
output.MarkFoldStart("///" + content, true);
output.Write("///"); output.Write("///");
output.WriteLine(content); output.Write(content);
inDocumentationComment = true;
if (isLastLine) {
inDocumentationComment = false;
output.MarkFoldEnd();
}
output.WriteLine();
break; break;
} }
} }

2
NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/IOutputFormatter.cs

@ -39,6 +39,6 @@ namespace ICSharpCode.NRefactory.CSharp
void NewLine(); void NewLine();
void WriteComment(CommentType commentType, string content); void WriteComment(CommentType commentType, string content, bool isLastLine = false);
} }
} }

4
NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs

@ -2147,7 +2147,9 @@ namespace ICSharpCode.NRefactory.CSharp
// "1.0 / /*comment*/a", then we need to insert a space in front of the comment. // "1.0 / /*comment*/a", then we need to insert a space in front of the comment.
formatter.Space(); formatter.Space();
} }
formatter.WriteComment(comment.CommentType, comment.Content); bool isContinuing = (comment.NextSibling is Comment && ((Comment)comment.NextSibling).CommentType == comment.CommentType);
formatter.WriteComment(comment.CommentType, comment.Content, !isContinuing);
lastWritten = LastWritten.Whitespace; lastWritten = LastWritten.Whitespace;
return null; return null;
} }

2
NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/TextWriterOutputFormatter.cs

@ -88,7 +88,7 @@ namespace ICSharpCode.NRefactory.CSharp
indentation--; indentation--;
} }
public void WriteComment(CommentType commentType, string content) public void WriteComment(CommentType commentType, string content, bool isLastLine = false)
{ {
WriteIndentation(); WriteIndentation();
switch (commentType) { switch (commentType) {

Loading…
Cancel
Save