@@ -25,6 +25,13 @@ internal sealed class FormattingEngineImplementation : IFormattingEngine
25
25
private readonly IEnumerable < ILocalSemanticFormattingRule > _localSemanticRules ;
26
26
private readonly IEnumerable < IGlobalSemanticFormattingRule > _globalSemanticRules ;
27
27
private readonly Stopwatch _watch = new Stopwatch ( ) ;
28
+ private bool _verbose ;
29
+
30
+ public bool Verbose
31
+ {
32
+ get { return _verbose ; }
33
+ set { _verbose = value ; }
34
+ }
28
35
29
36
[ ImportingConstructor ]
30
37
public FormattingEngineImplementation (
@@ -103,26 +110,23 @@ private async Task<SyntaxNode> GetSyntaxRootAndFilter(Document document, Cancell
103
110
return await document . GetSyntaxRootAsync ( cancellationToken ) ;
104
111
}
105
112
106
- private void StartDocument ( Document document , int depth = 1 )
113
+ private void StartDocument ( )
107
114
{
108
- for ( int i = 0 ; i < depth ; i ++ )
109
- {
110
- Console . Write ( " " ) ;
111
- }
112
-
113
- Console . Write ( "Processing {0}" , document . Name ) ;
114
115
_watch . Restart ( ) ;
115
116
}
116
117
117
- private void EndDocument ( )
118
+ private void EndDocument ( Document document )
118
119
{
119
120
_watch . Stop ( ) ;
120
- if ( _watch . Elapsed . TotalSeconds > 1 )
121
+ if ( _verbose && _watch . Elapsed . TotalSeconds > 1 )
121
122
{
122
- Console . WriteLine ( " {0} seconds" , _watch . Elapsed . TotalSeconds ) ;
123
+ Console . WriteLine ( ) ;
124
+ Console . WriteLine ( " {0} {1} seconds" , document . Name , _watch . Elapsed . TotalSeconds ) ;
125
+ }
126
+ else
127
+ {
128
+ Console . Write ( "." ) ;
123
129
}
124
-
125
- Console . WriteLine ( ) ;
126
130
}
127
131
128
132
/// <summary>
@@ -145,16 +149,17 @@ private async Task<Solution> RunSyntaxPass(Solution originalSolution, IReadOnlyL
145
149
continue ;
146
150
}
147
151
148
- StartDocument ( document ) ;
152
+ StartDocument ( ) ;
149
153
var newRoot = RunSyntaxPass ( syntaxRoot ) ;
150
- EndDocument ( ) ;
154
+ EndDocument ( document ) ;
151
155
152
156
if ( newRoot != syntaxRoot )
153
157
{
154
158
currentSolution = currentSolution . WithDocumentSyntaxRoot ( document . Id , newRoot ) ;
155
159
}
156
160
}
157
161
162
+ Console . WriteLine ( ) ;
158
163
return currentSolution ;
159
164
}
160
165
@@ -176,6 +181,7 @@ private async Task<Solution> RunLocalSemanticPass(Solution solution, IReadOnlyLi
176
181
solution = await RunLocalSemanticPass ( solution , documentIds , localSemanticRule , cancellationToken ) ;
177
182
}
178
183
184
+ Console . WriteLine ( ) ;
179
185
return solution ;
180
186
}
181
187
@@ -192,16 +198,17 @@ private async Task<Solution> RunLocalSemanticPass(Solution originalSolution, IRe
192
198
continue ;
193
199
}
194
200
195
- StartDocument ( document , depth : 2 ) ;
201
+ StartDocument ( ) ;
196
202
var newRoot = await localSemanticRule . ProcessAsync ( document , syntaxRoot , cancellationToken ) ;
197
- EndDocument ( ) ;
203
+ EndDocument ( document ) ;
198
204
199
205
if ( syntaxRoot != newRoot )
200
206
{
201
207
currentSolution = currentSolution . WithDocumentSyntaxRoot ( documentId , newRoot ) ;
202
208
}
203
209
}
204
210
211
+ Console . WriteLine ( ) ;
205
212
return currentSolution ;
206
213
}
207
214
@@ -213,6 +220,7 @@ private async Task<Solution> RunGlobalSemanticPass(Solution solution, IReadOnlyL
213
220
solution = await RunGlobalSemanticPass ( solution , documentIds , globalSemanticRule , cancellationToken ) ;
214
221
}
215
222
223
+ Console . WriteLine ( ) ;
216
224
return solution ;
217
225
}
218
226
@@ -228,11 +236,12 @@ private async Task<Solution> RunGlobalSemanticPass(Solution solution, IReadOnlyL
228
236
continue ;
229
237
}
230
238
231
- StartDocument ( document , depth : 2 ) ;
239
+ StartDocument ( ) ;
232
240
solution = await globalSemanticRule . ProcessAsync ( document , syntaxRoot , cancellationToken ) ;
233
- EndDocument ( ) ;
241
+ EndDocument ( document ) ;
234
242
}
235
243
244
+ Console . WriteLine ( ) ;
236
245
return solution ;
237
246
}
238
247
}
0 commit comments