@@ -16,11 +16,11 @@ internal class FindFoldsVisitor : AstVisitor
16
16
{
17
17
private const string RegionKindNone = null ;
18
18
19
- public List < FoldingReference > FoldableRegions { get ; }
19
+ private FoldingReferenceList _refList ;
20
20
21
- public FindFoldsVisitor ( )
21
+ public FindFoldsVisitor ( ref FoldingReferenceList refList )
22
22
{
23
- this . FoldableRegions = new List < FoldingReference > ( ) ;
23
+ this . _refList = refList ;
24
24
}
25
25
26
26
/// <summary>
@@ -55,7 +55,7 @@ public override AstVisitAction VisitArrayExpression(ArrayExpressionAst objAst)
55
55
{
56
56
if ( IsValidFoldingExtent ( objAst . Extent ) )
57
57
{
58
- this . FoldableRegions . Add ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
58
+ this . _refList . SafeAdd ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
59
59
}
60
60
return AstVisitAction . Continue ;
61
61
}
@@ -64,7 +64,7 @@ public override AstVisitAction VisitHashtable(HashtableAst objAst)
64
64
{
65
65
if ( IsValidFoldingExtent ( objAst . Extent ) )
66
66
{
67
- this . FoldableRegions . Add ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
67
+ this . _refList . SafeAdd ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
68
68
}
69
69
return AstVisitAction . Continue ;
70
70
}
@@ -76,7 +76,7 @@ public override AstVisitAction VisitStatementBlock(StatementBlockAst objAst)
76
76
if ( objAst . Parent is ArrayExpressionAst ) { return AstVisitAction . Continue ; }
77
77
if ( IsValidFoldingExtent ( objAst . Extent ) )
78
78
{
79
- this . FoldableRegions . Add ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
79
+ this . _refList . SafeAdd ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
80
80
}
81
81
return AstVisitAction . Continue ;
82
82
}
@@ -89,7 +89,7 @@ public override AstVisitAction VisitScriptBlock(ScriptBlockAst objAst)
89
89
if ( objAst . Parent is ScriptBlockExpressionAst ) { return AstVisitAction . Continue ; }
90
90
if ( IsValidFoldingExtent ( objAst . Extent ) )
91
91
{
92
- this . FoldableRegions . Add ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
92
+ this . _refList . SafeAdd ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
93
93
}
94
94
return AstVisitAction . Continue ;
95
95
}
@@ -106,7 +106,7 @@ public override AstVisitAction VisitScriptBlockExpression(ScriptBlockExpressionA
106
106
foldRef . StartCharacter -- ;
107
107
foldRef . EndCharacter ++ ;
108
108
}
109
- this . FoldableRegions . Add ( foldRef ) ;
109
+ this . _refList . SafeAdd ( foldRef ) ;
110
110
}
111
111
return AstVisitAction . Continue ;
112
112
}
@@ -115,7 +115,7 @@ public override AstVisitAction VisitStringConstantExpression(StringConstantExpre
115
115
{
116
116
if ( IsValidFoldingExtent ( objAst . Extent ) )
117
117
{
118
- this . FoldableRegions . Add ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
118
+ this . _refList . SafeAdd ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
119
119
}
120
120
121
121
return AstVisitAction . Continue ;
@@ -125,7 +125,7 @@ public override AstVisitAction VisitSubExpression(SubExpressionAst objAst)
125
125
{
126
126
if ( IsValidFoldingExtent ( objAst . Extent ) )
127
127
{
128
- this . FoldableRegions . Add ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
128
+ this . _refList . SafeAdd ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
129
129
}
130
130
return AstVisitAction . Continue ;
131
131
}
@@ -134,7 +134,7 @@ public override AstVisitAction VisitVariableExpression(VariableExpressionAst obj
134
134
{
135
135
if ( IsValidFoldingExtent ( objAst . Extent ) )
136
136
{
137
- this . FoldableRegions . Add ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
137
+ this . _refList . SafeAdd ( CreateFoldingReference ( objAst . Extent , RegionKindNone ) ) ;
138
138
}
139
139
return AstVisitAction . Continue ;
140
140
}
0 commit comments