Code Coverage Statistics for Source File
c:\Tools\SD3\src\Libraries\ICSharpCode.TextEditor\Project\Src\Document\FoldingStrategy\IndentFoldingStrategy.cs
|
Sequence Point Coverage
N/A
0 of 0
|
Branch Coverage
N/A
0 of 0
|
Lines
47
|
Highlight:
Uncovered Code
Covered Code
| L | V | Source |
|---|---|---|
1 |
// <file> |
|
2 |
// <copyright see="prj:///doc/copyright.txt"/> |
|
3 |
// <license see="prj:///doc/license.txt"/> |
|
4 |
// <owner name="Mike Krüger" email="mike@icsharpcode.net"/> |
|
5 |
// <version>$Revision: 915 $</version> |
|
6 |
// </file> |
|
7 |
||
8 |
using System; |
|
9 |
using System.Collections.Generic; |
|
10 |
||
11 |
namespace ICSharpCode.TextEditor.Document |
|
12 |
{ |
|
13 |
/// <summary> |
|
14 |
/// A simple folding strategy which calculates the folding level |
|
15 |
/// using the indent level of the line. |
|
16 |
/// </summary> |
|
17 |
public class IndentFoldingStrategy : IFoldingStrategy |
|
18 |
{ |
|
19 |
public List<FoldMarker> GenerateFoldMarkers(IDocument document, string fileName, object parseInformation) |
|
20 |
{ |
|
21 |
List<FoldMarker> l = new List<FoldMarker>(); |
|
22 |
Stack<int> offsetStack = new Stack<int>(); |
|
23 |
Stack<string> textStack = new Stack<string>(); |
|
24 |
//int level = 0; |
|
25 |
//foreach (LineSegment segment in document.LineSegmentCollection) { |
|
26 |
// |
|
27 |
//} |
|
28 |
return l; |
|
29 |
} |
|
30 |
||
31 |
int GetLevel(IDocument document, int offset) |
|
32 |
{ |
|
33 |
int level = 0; |
|
34 |
int spaces = 0; |
|
35 |
for (int i = offset; i < document.TextLength; ++i) { |
|
36 |
char c = document.GetCharAt(i); |
|
37 |
if (c == '\t' || (c == ' ' && ++spaces == 4)) { |
|
38 |
spaces = 0; |
|
39 |
++level; |
|
40 |
} else { |
|
41 |
break; |
|
42 |
} |
|
43 |
} |
|
44 |
return level; |
|
45 |
} |
|
46 |
} |
|
47 |
} |