diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-12-05 18:01:34 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-12-05 18:01:34 +0400 |
commit | fa14296bd721c3b641caa15827e3bb5d87e72c5b (patch) | |
tree | c738eceffa87561ccd505e1b40219b445f9efa6e /main/src/addins/TextTemplating | |
parent | 4111ebc30dfddfa96e4caa4e45786f1cc968e5c0 (diff) |
[Ide/CSharpBinding] Corrected folding locations. Moved all folding
responsibility into the backends.
It's now easy to generate folds for any language structure + the
refactoring enables that the correct parsing locations from the new
ast can be taken - now the folding regions should always be correct
instead of beeing best-fits.
Diffstat (limited to 'main/src/addins/TextTemplating')
-rw-r--r-- | main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4ParsedDocument.cs | 49 |
1 files changed, 26 insertions, 23 deletions
diff --git a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4ParsedDocument.cs b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4ParsedDocument.cs index ead050333d..e8079692f6 100644 --- a/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4ParsedDocument.cs +++ b/main/src/addins/TextTemplating/MonoDevelop.TextTemplating/Parser/T4ParsedDocument.cs @@ -71,33 +71,36 @@ namespace MonoDevelop.TextTemplating.Parser } } - public override IEnumerable<FoldingRegion> GenerateFolds () - { - foreach (ISegment seg in TemplateSegments) { - if (seg.EndLocation.Line - seg.TagStartLocation.Line < 1) - continue; - - string name; - TemplateSegment ts = seg as TemplateSegment; - if (ts != null) { - if (ts.Type == SegmentType.Content) { + public override IEnumerable<FoldingRegion> Foldings { + get { + foreach (var region in Comments.ToFolds ()) + yield return region; + foreach (ISegment seg in TemplateSegments) { + if (seg.EndLocation.Line - seg.TagStartLocation.Line < 1) continue; - } else if (ts.Type == SegmentType.Expression) { - name = "<#=...#>"; - } else if (ts.Type == SegmentType.Helper) { - name = "<#+...#>"; + + string name; + TemplateSegment ts = seg as TemplateSegment; + if (ts != null) { + if (ts.Type == SegmentType.Content) { + continue; + } else if (ts.Type == SegmentType.Expression) { + name = "<#=...#>"; + } else if (ts.Type == SegmentType.Helper) { + name = "<#+...#>"; + } else { + name = "<#...#>"; + } } else { - name = "<#...#>"; + Directive dir = (Directive)seg; + name = "<#@" + dir.Name + "...#>"; } - } else { - Directive dir = (Directive)seg; - name = "<#@" + dir.Name + "...#>"; + + DomRegion region = new DomRegion (seg.TagStartLocation.Line, seg.TagStartLocation.Column, + seg.EndLocation.Line, seg.EndLocation.Column); + + yield return new FoldingRegion (name, region, false); } - - DomRegion region = new DomRegion (seg.TagStartLocation.Line, seg.TagStartLocation.Column, - seg.EndLocation.Line, seg.EndLocation.Column); - - yield return new FoldingRegion (name, region, false); } } } |