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

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

@ -39,6 +39,6 @@ namespace ICSharpCode.NRefactory.CSharp @@ -39,6 +39,6 @@ namespace ICSharpCode.NRefactory.CSharp
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 @@ -2147,7 +2147,9 @@ namespace ICSharpCode.NRefactory.CSharp
// "1.0 / /*comment*/a", then we need to insert a space in front of the comment.
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;
return null;
}

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

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

Loading…
Cancel
Save