|
|
|
@ -37,35 +37,43 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
@@ -37,35 +37,43 @@ namespace ICSharpCode.Decompiler.CSharp.OutputVisitor
|
|
|
|
|
|
|
|
|
|
public override void StartNode(AstNode node) |
|
|
|
|
{ |
|
|
|
|
currentList.Add(node); |
|
|
|
|
nodes.Push(currentList); |
|
|
|
|
currentList = new List<AstNode>(); |
|
|
|
|
// ignore whitespace: these don't need to be processed.
|
|
|
|
|
// StartNode/EndNode is only called for them to support folding of comments.
|
|
|
|
|
if (node.NodeType != NodeType.Whitespace) { |
|
|
|
|
currentList.Add(node); |
|
|
|
|
nodes.Push(currentList); |
|
|
|
|
currentList = new List<AstNode>(); |
|
|
|
|
} |
|
|
|
|
base.StartNode(node); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void EndNode(AstNode node) |
|
|
|
|
{ |
|
|
|
|
System.Diagnostics.Debug.Assert(currentList != null); |
|
|
|
|
foreach (var removable in node.Children.Where(n => n is CSharpTokenNode)) { |
|
|
|
|
removable.Remove(); |
|
|
|
|
// ignore whitespace: these don't need to be processed.
|
|
|
|
|
// StartNode/EndNode is only called for them to support folding of comments.
|
|
|
|
|
if (node.NodeType != NodeType.Whitespace) { |
|
|
|
|
System.Diagnostics.Debug.Assert(currentList != null); |
|
|
|
|
foreach (var removable in node.Children.Where(n => n is CSharpTokenNode)) { |
|
|
|
|
removable.Remove(); |
|
|
|
|
} |
|
|
|
|
foreach (var child in currentList) { |
|
|
|
|
System.Diagnostics.Debug.Assert(child.Parent == null || node == child.Parent); |
|
|
|
|
child.Remove(); |
|
|
|
|
node.AddChildWithExistingRole(child); |
|
|
|
|
} |
|
|
|
|
currentList = nodes.Pop(); |
|
|
|
|
} |
|
|
|
|
foreach (var child in currentList) { |
|
|
|
|
System.Diagnostics.Debug.Assert(child.Parent == null || node == child.Parent); |
|
|
|
|
child.Remove(); |
|
|
|
|
node.AddChildWithExistingRole(child); |
|
|
|
|
} |
|
|
|
|
currentList = nodes.Pop(); |
|
|
|
|
base.EndNode(node); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public override void WriteToken(Role role, string token) |
|
|
|
|
{ |
|
|
|
|
CSharpTokenNode t = new CSharpTokenNode(locationProvider.Location, (TokenRole)role); |
|
|
|
|
t.Role = role; |
|
|
|
|
EmptyStatement node = nodes.Peek().LastOrDefault() as EmptyStatement; |
|
|
|
|
if (node == null) |
|
|
|
|
if (node == null) { |
|
|
|
|
CSharpTokenNode t = new CSharpTokenNode(locationProvider.Location, (TokenRole)role); |
|
|
|
|
t.Role = role; |
|
|
|
|
currentList.Add(t); |
|
|
|
|
else { |
|
|
|
|
} else { |
|
|
|
|
node.Location = locationProvider.Location; |
|
|
|
|
} |
|
|
|
|
base.WriteToken(role, token); |
|
|
|
|