Browse Source

remove isLastLine from interface - use stack instead; fix null reference if resolve of TypeDefinition fails

pull/172/merge
Siegfried Pammer 14 years ago
parent
commit
e9eca059d5
  1. 2
      ICSharpCode.Decompiler/Ast/AstBuilder.cs
  2. 3
      ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs
  3. 2
      NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/IOutputFormatter.cs
  4. 4
      NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs
  5. 2
      NRefactory/ICSharpCode.NRefactory/CSharp/OutputVisitor/TextWriterOutputFormatter.cs

2
ICSharpCode.Decompiler/Ast/AstBuilder.cs

@ -428,12 +428,12 @@ namespace ICSharpCode.Decompiler.Ast
} else { } else {
astType = new SimpleType(name); astType = new SimpleType(name);
if (!type.HasGenericParameters) {
// Look for generic type parameters defined in TypeDefinition // Look for generic type parameters defined in TypeDefinition
// allows us to display angle brackets in unbound type names // allows us to display angle brackets in unbound type names
// e.g. typeof(List<>) // e.g. typeof(List<>)
TypeDefinition resolvedType = type.Resolve(); TypeDefinition resolvedType = type.Resolve();
if (!type.HasGenericParameters && resolvedType != null) {
for (int i = 0; i < resolvedType.GenericParameters.Count; i++) { for (int i = 0; i < resolvedType.GenericParameters.Count; i++) {
((SimpleType)astType).TypeArguments.Add(new SimpleType("")); ((SimpleType)astType).TypeArguments.Add(new SimpleType(""));
} }

3
ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs

@ -103,7 +103,7 @@ namespace ICSharpCode.Decompiler.Ast
output.WriteLine(); output.WriteLine();
} }
public void WriteComment(CommentType commentType, string content, bool isLastLine = false) public void WriteComment(CommentType commentType, string content)
{ {
switch (commentType) { switch (commentType) {
case CommentType.SingleLine: case CommentType.SingleLine:
@ -121,6 +121,7 @@ namespace ICSharpCode.Decompiler.Ast
output.Write("///"); output.Write("///");
output.Write(content); output.Write(content);
inDocumentationComment = true; inDocumentationComment = true;
bool isLastLine = !(nodeStack.Peek().NextSibling is Comment);
if (isLastLine) { if (isLastLine) {
inDocumentationComment = false; inDocumentationComment = false;
output.MarkFoldEnd(); output.MarkFoldEnd();

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, bool isLastLine = false); void WriteComment(CommentType commentType, string content);
} }
} }

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

@ -2147,9 +2147,7 @@ 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();
} }
bool isContinuing = (comment.NextSibling is Comment && ((Comment)comment.NextSibling).CommentType == comment.CommentType); formatter.WriteComment(comment.CommentType, comment.Content);
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, bool isLastLine = false) public void WriteComment(CommentType commentType, string content)
{ {
WriteIndentation(); WriteIndentation();
switch (commentType) { switch (commentType) {

Loading…
Cancel
Save