Browse Source

add folding for Imports in VB

pull/703/head
Siegfried Pammer 10 years ago
parent
commit
3844ca3036
  1. 21
      ILSpy/VB/VBTextOutputFormatter.cs

21
ILSpy/VB/VBTextOutputFormatter.cs

@ -34,6 +34,8 @@ namespace ICSharpCode.ILSpy.VB @@ -34,6 +34,8 @@ namespace ICSharpCode.ILSpy.VB
readonly ITextOutput output;
readonly Stack<AstNode> nodeStack = new Stack<AstNode>();
bool firstImport, lastImport;
public VBTextOutputFormatter(ITextOutput output)
{
if (output == null)
@ -64,7 +66,15 @@ namespace ICSharpCode.ILSpy.VB @@ -64,7 +66,15 @@ namespace ICSharpCode.ILSpy.VB
// }
// }
// }
if (nodeStack.Count == 0) {
if (node is ImportsStatement) {
firstImport = !(node.PrevSibling is ImportsStatement);
lastImport = !(node.NextSibling is ImportsStatement);
} else {
firstImport = false;
lastImport = false;
}
}
nodeStack.Push(node);
}
@ -100,6 +110,11 @@ namespace ICSharpCode.ILSpy.VB @@ -100,6 +110,11 @@ namespace ICSharpCode.ILSpy.VB
return;
}
if (firstImport) {
output.MarkFoldStart(defaultCollapsed: true);
firstImport = false;
}
output.Write(identifier);
}
@ -198,6 +213,10 @@ namespace ICSharpCode.ILSpy.VB @@ -198,6 +213,10 @@ namespace ICSharpCode.ILSpy.VB
public void NewLine()
{
if (lastImport) {
output.MarkFoldEnd();
lastImport = false;
}
output.WriteLine();
}

Loading…
Cancel
Save