Browse Source

add folding for Imports in VB

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

63
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)
@ -43,28 +45,36 @@ namespace ICSharpCode.ILSpy.VB @@ -43,28 +45,36 @@ namespace ICSharpCode.ILSpy.VB
public void StartNode(AstNode node)
{
// var ranges = node.Annotation<List<ILRange>>();
// if (ranges != null && ranges.Count > 0)
// {
// // find the ancestor that has method mapping as annotation
// if (node.Ancestors != null && node.Ancestors.Count() > 0)
// {
// var n = node.Ancestors.FirstOrDefault(a => a.Annotation<MemberMapping>() != null);
// if (n != null) {
// MemberMapping mapping = n.Annotation<MemberMapping>();
//
// // add all ranges
// foreach (var range in ranges) {
// mapping.MemberCodeMappings.Add(new SourceCodeMapping {
// ILInstructionOffset = range,
// SourceCodeLine = output.CurrentLine,
// MemberMapping = mapping
// });
// }
// }
// }
// }
// var ranges = node.Annotation<List<ILRange>>();
// if (ranges != null && ranges.Count > 0)
// {
// // find the ancestor that has method mapping as annotation
// if (node.Ancestors != null && node.Ancestors.Count() > 0)
// {
// var n = node.Ancestors.FirstOrDefault(a => a.Annotation<MemberMapping>() != null);
// if (n != null) {
// MemberMapping mapping = n.Annotation<MemberMapping>();
//
// // add all ranges
// foreach (var range in ranges) {
// mapping.MemberCodeMappings.Add(new SourceCodeMapping {
// ILInstructionOffset = range,
// SourceCodeLine = output.CurrentLine,
// MemberMapping = mapping
// });
// }
// }
// }
// }
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