|
|
|
@ -29,6 +29,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
readonly TextWriter textWriter; |
|
|
|
readonly TextWriter textWriter; |
|
|
|
int indentation; |
|
|
|
int indentation; |
|
|
|
bool needsIndent = true; |
|
|
|
bool needsIndent = true; |
|
|
|
|
|
|
|
bool isAtStartOfLine = true; |
|
|
|
|
|
|
|
|
|
|
|
public int Indentation { |
|
|
|
public int Indentation { |
|
|
|
get { |
|
|
|
get { |
|
|
|
@ -53,18 +54,21 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriteIndentation(); |
|
|
|
WriteIndentation(); |
|
|
|
textWriter.Write(ident); |
|
|
|
textWriter.Write(ident); |
|
|
|
|
|
|
|
isAtStartOfLine = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void WriteKeyword(string keyword) |
|
|
|
public void WriteKeyword(string keyword) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriteIndentation(); |
|
|
|
WriteIndentation(); |
|
|
|
textWriter.Write(keyword); |
|
|
|
textWriter.Write(keyword); |
|
|
|
|
|
|
|
isAtStartOfLine = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void WriteToken(string token) |
|
|
|
public void WriteToken(string token) |
|
|
|
{ |
|
|
|
{ |
|
|
|
WriteIndentation(); |
|
|
|
WriteIndentation(); |
|
|
|
textWriter.Write(token); |
|
|
|
textWriter.Write(token); |
|
|
|
|
|
|
|
isAtStartOfLine = false; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Space() |
|
|
|
public void Space() |
|
|
|
@ -75,7 +79,6 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
|
|
|
|
|
|
|
|
public void OpenBrace(BraceStyle style) |
|
|
|
public void OpenBrace(BraceStyle style) |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool isAtStartOfLine = needsIndent; |
|
|
|
|
|
|
|
switch (style) { |
|
|
|
switch (style) { |
|
|
|
case BraceStyle.DoNotChange: |
|
|
|
case BraceStyle.DoNotChange: |
|
|
|
case BraceStyle.EndOfLine: |
|
|
|
case BraceStyle.EndOfLine: |
|
|
|
@ -125,16 +128,19 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
Unindent(); |
|
|
|
Unindent(); |
|
|
|
WriteIndentation(); |
|
|
|
WriteIndentation(); |
|
|
|
textWriter.Write('}'); |
|
|
|
textWriter.Write('}'); |
|
|
|
|
|
|
|
isAtStartOfLine = false; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case BraceStyle.NextLineShifted: |
|
|
|
case BraceStyle.NextLineShifted: |
|
|
|
WriteIndentation(); |
|
|
|
WriteIndentation(); |
|
|
|
textWriter.Write('}'); |
|
|
|
textWriter.Write('}'); |
|
|
|
|
|
|
|
isAtStartOfLine = false; |
|
|
|
Unindent(); |
|
|
|
Unindent(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
case BraceStyle.NextLineShifted2: |
|
|
|
case BraceStyle.NextLineShifted2: |
|
|
|
Unindent(); |
|
|
|
Unindent(); |
|
|
|
WriteIndentation(); |
|
|
|
WriteIndentation(); |
|
|
|
textWriter.Write('}'); |
|
|
|
textWriter.Write('}'); |
|
|
|
|
|
|
|
isAtStartOfLine = false; |
|
|
|
Unindent(); |
|
|
|
Unindent(); |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
@ -156,6 +162,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
{ |
|
|
|
{ |
|
|
|
textWriter.WriteLine(); |
|
|
|
textWriter.WriteLine(); |
|
|
|
needsIndent = true; |
|
|
|
needsIndent = true; |
|
|
|
|
|
|
|
isAtStartOfLine = true; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void Indent() |
|
|
|
public void Indent() |
|
|
|
@ -176,16 +183,19 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
textWriter.Write("//"); |
|
|
|
textWriter.Write("//"); |
|
|
|
textWriter.WriteLine(content); |
|
|
|
textWriter.WriteLine(content); |
|
|
|
needsIndent = true; |
|
|
|
needsIndent = true; |
|
|
|
|
|
|
|
isAtStartOfLine = true; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CommentType.MultiLine: |
|
|
|
case CommentType.MultiLine: |
|
|
|
textWriter.Write("/*"); |
|
|
|
textWriter.Write("/*"); |
|
|
|
textWriter.Write(content); |
|
|
|
textWriter.Write(content); |
|
|
|
textWriter.Write("*/"); |
|
|
|
textWriter.Write("*/"); |
|
|
|
|
|
|
|
isAtStartOfLine = false; |
|
|
|
break; |
|
|
|
break; |
|
|
|
case CommentType.Documentation: |
|
|
|
case CommentType.Documentation: |
|
|
|
textWriter.Write("///"); |
|
|
|
textWriter.Write("///"); |
|
|
|
textWriter.WriteLine(content); |
|
|
|
textWriter.WriteLine(content); |
|
|
|
needsIndent = true; |
|
|
|
needsIndent = true; |
|
|
|
|
|
|
|
isAtStartOfLine = true; |
|
|
|
break; |
|
|
|
break; |
|
|
|
default: |
|
|
|
default: |
|
|
|
textWriter.Write(content); |
|
|
|
textWriter.Write(content); |
|
|
|
@ -196,7 +206,7 @@ namespace ICSharpCode.NRefactory.CSharp |
|
|
|
public void WritePreProcessorDirective(PreProcessorDirectiveType type, string argument) |
|
|
|
public void WritePreProcessorDirective(PreProcessorDirectiveType type, string argument) |
|
|
|
{ |
|
|
|
{ |
|
|
|
// pre-processor directive must start on its own line
|
|
|
|
// pre-processor directive must start on its own line
|
|
|
|
if (!needsIndent) |
|
|
|
if (!isAtStartOfLine) |
|
|
|
NewLine(); |
|
|
|
NewLine(); |
|
|
|
WriteIndentation(); |
|
|
|
WriteIndentation(); |
|
|
|
textWriter.Write('#'); |
|
|
|
textWriter.Write('#'); |
|
|
|
|