Browse Source

add current column in the node annotation tuple

pull/219/head
Eusebiu Marcu 14 years ago
parent
commit
c81abc97ab
  1. 2
      ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs
  2. 1
      ICSharpCode.Decompiler/ITextOutput.cs
  3. 10
      ICSharpCode.Decompiler/PlainTextOutput.cs

2
ICSharpCode.Decompiler/Ast/TextOutputFormatter.cs

@ -152,7 +152,7 @@ namespace ICSharpCode.Decompiler.Ast
int c = 0; int c = 0;
if (n != null) if (n != null)
c = n.Attributes.Count; c = n.Attributes.Count;
node.AddAnnotation(Tuple.Create(output.CurrentLine + c, 0)); node.AddAnnotation(Tuple.Create(output.CurrentLine + c, output.CurrentColumn));
} }
nodeStack.Push(node); nodeStack.Push(node);

1
ICSharpCode.Decompiler/ITextOutput.cs

@ -24,6 +24,7 @@ namespace ICSharpCode.Decompiler
public interface ITextOutput public interface ITextOutput
{ {
int CurrentLine { get; } int CurrentLine { get; }
int CurrentColumn { get; }
void Indent(); void Indent();
void Unindent(); void Unindent();

10
ICSharpCode.Decompiler/PlainTextOutput.cs

@ -27,6 +27,7 @@ namespace ICSharpCode.Decompiler
int indent; int indent;
bool needsIndent; bool needsIndent;
int lineNumber = 1; int lineNumber = 1;
int columnNumber = 1;
public PlainTextOutput(TextWriter writer) public PlainTextOutput(TextWriter writer)
{ {
@ -40,10 +41,14 @@ namespace ICSharpCode.Decompiler
this.writer = new StringWriter(); this.writer = new StringWriter();
} }
public int CurrentLine { public int CurrentLine {
get { return lineNumber; } get { return lineNumber; }
} }
public int CurrentColumn {
get { return columnNumber; }
}
public override string ToString() public override string ToString()
{ {
return writer.ToString(); return writer.ToString();
@ -65,6 +70,7 @@ namespace ICSharpCode.Decompiler
needsIndent = false; needsIndent = false;
for (int i = 0; i < indent; i++) { for (int i = 0; i < indent; i++) {
writer.Write('\t'); writer.Write('\t');
columnNumber += 4;
} }
} }
} }
@ -73,12 +79,14 @@ namespace ICSharpCode.Decompiler
{ {
WriteIndent(); WriteIndent();
writer.Write(ch); writer.Write(ch);
columnNumber++;
} }
public void Write(string text) public void Write(string text)
{ {
WriteIndent(); WriteIndent();
writer.Write(text); writer.Write(text);
columnNumber += text.Length;
} }
public void WriteLine() public void WriteLine()

Loading…
Cancel
Save