~ubuntu-branches/ubuntu/trusty/monodevelop/trusty-proposed

« back to all changes in this revision

Viewing changes to external/nrefactory/ICSharpCode.NRefactory.CSharp/Formatter/FormattingVisitor.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2013-05-12 09:46:03 UTC
  • mto: This revision was merged to the branch mainline in revision 29.
  • Revision ID: package-import@ubuntu.com-20130512094603-mad323bzcxvmcam0
Tags: upstream-4.0.5+dfsg
ImportĀ upstreamĀ versionĀ 4.0.5+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
ļ»æ// 
 
2
// FormattingVisitor.cs
 
3
//
 
4
// Author:
 
5
//       Mike KrĆ¼ger <mkrueger@xamarin.com>
 
6
// 
 
7
// Copyright (c) 2010 Novell, Inc (http://www.novell.com)
 
8
// Copyright (c) 2013 Xamarin Inc. (http://xamarin.com)
 
9
//
 
10
// Permission is hereby granted, free of charge, to any person obtaining a copy
 
11
// of this software and associated documentation files (the "Software"), to deal
 
12
// in the Software without restriction, including without limitation the rights
 
13
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 
14
// copies of the Software, and to permit persons to whom the Software is
 
15
// furnished to do so, subject to the following conditions:
 
16
// 
 
17
// The above copyright notice and this permission notice shall be included in
 
18
// all copies or substantial portions of the Software.
 
19
// 
 
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 
21
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 
22
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 
23
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 
24
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 
25
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
 
26
// THE SOFTWARE.
 
27
using System;
 
28
using System.Text;
 
29
using System.Linq;
 
30
using ICSharpCode.NRefactory.Editor;
 
31
using ICSharpCode.NRefactory.TypeSystem;
 
32
using System.Threading;
 
33
 
 
34
namespace ICSharpCode.NRefactory.CSharp
 
35
{
 
36
        [Obsolete("This class was replaced by CSharpFormatter.")]
 
37
        public class AstFormattingVisitor {}
 
38
 
 
39
        partial class FormattingVisitor : DepthFirstAstVisitor
 
40
        {
 
41
                readonly CSharpFormatter formatter;
 
42
                readonly FormattingChanges changes;
 
43
                readonly IDocument document;
 
44
                readonly CancellationToken token;
 
45
 
 
46
                Indent curIndent;
 
47
 
 
48
                public bool HadErrors {
 
49
                        get;
 
50
                        set;
 
51
                }
 
52
                
 
53
 
 
54
                CSharpFormattingOptions policy {
 
55
                        get {
 
56
                                return formatter.Policy;
 
57
                        }
 
58
                }
 
59
 
 
60
                TextEditorOptions options {
 
61
                        get {
 
62
                                return formatter.TextEditorOptions;
 
63
                        }
 
64
                }
 
65
 
 
66
                FormattingChanges.TextReplaceAction AddChange(int offset, int removedChars, string insertedText)
 
67
                {
 
68
                        return changes.AddChange(offset, removedChars, insertedText);
 
69
                }
 
70
 
 
71
                public FormattingVisitor(CSharpFormatter formatter, IDocument document, FormattingChanges changes, CancellationToken token)
 
72
                {
 
73
                        if (formatter == null)
 
74
                                throw new ArgumentNullException("formatter");
 
75
                        if (document == null)
 
76
                                throw new ArgumentNullException("document");
 
77
                        if (changes == null)
 
78
                                throw new ArgumentNullException("changes");
 
79
                
 
80
                        this.formatter = formatter;
 
81
                        this.changes = changes;
 
82
                        this.document = document;
 
83
                        this.token = token;
 
84
 
 
85
                        curIndent = new Indent(formatter.TextEditorOptions);
 
86
                }
 
87
                
 
88
                void VisitChildrenToFormat (AstNode parent, Action<AstNode> callback)
 
89
                {
 
90
                        AstNode next;
 
91
                        for (var child = parent.FirstChild; child != null; child = next) {
 
92
                                token.ThrowIfCancellationRequested();
 
93
                                // Store next to allow the loop to continue
 
94
                                // if the visitor removes/replaces child.
 
95
                                next = child.GetNextSibling(NoWhitespacePredicate);
 
96
                                
 
97
                                if (formatter.FormattingRegions.Count > 0) {
 
98
                                        if (formatter.FormattingRegions.Any(r => r.IsInside(child.StartLocation) || r.IsInside(child.EndLocation))) {
 
99
                                                callback(child);
 
100
                                        } else {
 
101
                                                var childRegion = child.Region;
 
102
                                                if (formatter.FormattingRegions.Any(r => childRegion.IsInside(r.Begin) || childRegion.IsInside(r.End)))
 
103
                                                    callback(child);
 
104
                                        }
 
105
                                        if (child.StartLocation > formatter.lastFormattingLocation)
 
106
                                                break;
 
107
                                } else {
 
108
                                        callback(child);
 
109
                                }
 
110
                        }
 
111
                }
 
112
                
 
113
                protected override void VisitChildren (AstNode node)
 
114
                {
 
115
                        VisitChildrenToFormat (node, n => n.AcceptVisitor (this));
 
116
                }
 
117
 
 
118
                public void EnsureNewLinesAfter(AstNode node, int blankLines)
 
119
                {
 
120
                        if (formatter.FormattingMode != FormattingMode.Intrusive)
 
121
                                blankLines = 1;
 
122
                        int foundBlankLines = 0;
 
123
                        var nextNode = node.GetNextNode ();
 
124
                        AstNode lastNewLine = null;
 
125
                        while (nextNode != null) {
 
126
                                if (!(nextNode is NewLineNode))
 
127
                                        break;
 
128
                                lastNewLine = nextNode;
 
129
                                foundBlankLines++;
 
130
                                nextNode = nextNode.GetNextNode ();
 
131
                        }
 
132
                        if (nextNode == null)
 
133
                                return;
 
134
                        var start = document.GetOffset(node.EndLocation);
 
135
                        var end = document.GetOffset((lastNewLine ?? nextNode).StartLocation);
 
136
                        var sb = new StringBuilder(options.EolMarker.Length *  blankLines);
 
137
                        for (int i = 0; i < blankLines + (lastNewLine != null ? -1 : 0); i++) {
 
138
                                sb.Append(options.EolMarker);
 
139
                        }
 
140
                        AddChange(start, end - start, sb.ToString());
 
141
                }
 
142
                
 
143
                public void EnsureBlankLinesBefore(AstNode node, int blankLines)
 
144
                {
 
145
                        if (formatter.FormattingMode != FormattingMode.Intrusive)
 
146
                                return;
 
147
                        var loc = node.StartLocation;
 
148
                        int line = loc.Line;
 
149
                        do {
 
150
                                line--;
 
151
                        } while (line > 0 && IsSpacing(document.GetLineByNumber(line)));
 
152
                        int end = document.GetOffset(loc.Line, 1);
 
153
                        int start = document.GetOffset(line + 1, 1);
 
154
                        var sb = new StringBuilder ();
 
155
                        for (int i = 0; i < blankLines; i++) {
 
156
                                sb.Append(options.EolMarker);
 
157
                        }
 
158
                        if (end - start == 0 && sb.Length == 0)
 
159
                                return;
 
160
                        AddChange(start, end - start, sb.ToString());
 
161
                }
 
162
 
 
163
                bool IsSimpleAccessor(Accessor accessor)
 
164
                {
 
165
                        if (accessor.IsNull || accessor.Body.IsNull || accessor.Body.FirstChild == null) {
 
166
                                return true;
 
167
                        }
 
168
                        if (accessor.Body.Statements.Count() != 1) {
 
169
                                return false;
 
170
                        }
 
171
                        return !(accessor.Body.Statements.FirstOrDefault() is BlockStatement);
 
172
                        
 
173
                }
 
174
                
 
175
                bool IsSpacing(char ch)
 
176
                {
 
177
                        return ch == ' ' || ch == '\t';
 
178
                }
 
179
                
 
180
                bool IsSpacing(ISegment segment)
 
181
                {
 
182
                        int endOffset = segment.EndOffset;
 
183
                        for (int i = segment.Offset; i < endOffset; i++) {
 
184
                                if (!IsSpacing(document.GetCharAt(i))) {
 
185
                                        return false;
 
186
                                }
 
187
                        }
 
188
                        return true;
 
189
                }
 
190
                
 
191
                int SearchLastNonWsChar(int startOffset, int endOffset)
 
192
                {
 
193
                        startOffset = Math.Max(0, startOffset);
 
194
                        endOffset = Math.Max(startOffset, endOffset);
 
195
                        if (startOffset >= endOffset) {
 
196
                                return startOffset;
 
197
                        }
 
198
                        int result = -1;
 
199
                        bool inComment = false;
 
200
                        
 
201
                        for (int i = startOffset; i < endOffset && i < document.TextLength; i++) {
 
202
                                char ch = document.GetCharAt(i);
 
203
                                if (IsSpacing(ch)) {
 
204
                                        continue;
 
205
                                }
 
206
                                if (ch == '/' && i + 1 < document.TextLength && document.GetCharAt(i + 1) == '/') {
 
207
                                        return result;
 
208
                                }
 
209
                                if (ch == '/' && i + 1 < document.TextLength && document.GetCharAt(i + 1) == '*') {
 
210
                                        inComment = true;
 
211
                                        i++;
 
212
                                        continue;
 
213
                                }
 
214
                                if (inComment && ch == '*' && i + 1 < document.TextLength && document.GetCharAt(i + 1) == '/') {
 
215
                                        inComment = false;
 
216
                                        i++;
 
217
                                        continue;
 
218
                                }
 
219
                                if (!inComment) {
 
220
                                        result = i;
 
221
                                }
 
222
                        }
 
223
                        return result;
 
224
                }
 
225
                
 
226
                void ForceSpace(int startOffset, int endOffset, bool forceSpace)
 
227
                {
 
228
                        int lastNonWs = SearchLastNonWsChar(startOffset, endOffset);
 
229
                        if (lastNonWs >= 0)
 
230
                                AddChange(lastNonWs + 1, Math.Max(0, endOffset - lastNonWs - 1), forceSpace ? " " : "");
 
231
                }
 
232
                
 
233
                void ForceSpacesAfter(AstNode n, bool forceSpaces)
 
234
                {
 
235
                        if (n == null) {
 
236
                                return;
 
237
                        }
 
238
                        TextLocation location = n.EndLocation;
 
239
                        int offset = document.GetOffset(location);
 
240
                        if (location.Column > document.GetLineByNumber(location.Line).Length) {
 
241
                                return;
 
242
                        }
 
243
                        int i = offset;
 
244
                        while (i < document.TextLength && IsSpacing (document.GetCharAt (i))) {
 
245
                                i++;
 
246
                        }
 
247
                        ForceSpace(offset - 1, i, forceSpaces);
 
248
                }
 
249
 
 
250
                int ForceSpacesBefore(AstNode n, bool forceSpaces)
 
251
                {
 
252
                        if (n == null || n.IsNull) {
 
253
                                return 0;
 
254
                        }
 
255
                        TextLocation location = n.StartLocation;
 
256
                        // respect manual line breaks.
 
257
                        if (location.Column <= 1 || GetIndentation(location.Line).Length == location.Column - 1) {
 
258
                                return 0;
 
259
                        }
 
260
                        
 
261
                        int offset = document.GetOffset(location);
 
262
                        int i = offset - 1;
 
263
                        while (i >= 0 && IsSpacing (document.GetCharAt (i))) {
 
264
                                i--;
 
265
                        }
 
266
                        ForceSpace(i, offset, forceSpaces);
 
267
                        return i;
 
268
                }
 
269
                
 
270
                int ForceSpacesBeforeRemoveNewLines(AstNode n, bool forceSpace = true)
 
271
                {
 
272
                        if (n == null || n.IsNull) {
 
273
                                return 0;
 
274
                        }
 
275
                        int offset = document.GetOffset(n.StartLocation);
 
276
                        int i = offset - 1;
 
277
                        while (i >= 0) {
 
278
                                char ch = document.GetCharAt(i);
 
279
                                if (!IsSpacing(ch) && ch != '\r' && ch != '\n')
 
280
                                        break;
 
281
                                i--;
 
282
                        }
 
283
                        var length = Math.Max(0, (offset - 1) - i);
 
284
                        AddChange(i + 1, length, forceSpace ? " " : "");
 
285
                        return i;
 
286
                }
 
287
 
 
288
                static bool NoWhitespacePredicate(AstNode arg)
 
289
                {
 
290
                        return !(arg is NewLineNode || arg is WhitespaceNode);
 
291
                }
 
292
 
 
293
                static bool IsMember(AstNode nextSibling)
 
294
                {
 
295
                        return nextSibling != null && nextSibling.NodeType == NodeType.Member;
 
296
                }
 
297
 
 
298
                static bool ShouldBreakLine(NewLinePlacement placement, CSharpTokenNode token)
 
299
                {
 
300
                        if (placement == NewLinePlacement.NewLine)
 
301
                                return true;
 
302
                        if (placement == NewLinePlacement.SameLine)
 
303
                                return false;
 
304
                        var prevMeaningfulNode = token.GetPrevNode (n =>n.Role !=Roles.NewLine && n.Role != Roles.Whitespace && n.Role !=Roles.Comment);
 
305
                        return prevMeaningfulNode.EndLocation.Line != token.StartLocation.Line;
 
306
                }
 
307
 
 
308
                void ForceSpaceBefore(AstNode node, bool forceSpace)
 
309
                {
 
310
                        _ForceSpaceBefore(document.GetOffset(node.StartLocation), forceSpace);
 
311
                }
 
312
 
 
313
                void _ForceSpaceBefore(int offset, bool forceSpace)
 
314
                {
 
315
                        bool insertedSpace = false;
 
316
                        do {
 
317
                                char ch = document.GetCharAt(offset);
 
318
                                //Console.WriteLine (ch);
 
319
                                if (!IsSpacing(ch) && (insertedSpace || !forceSpace)) {
 
320
                                        break;
 
321
                                }
 
322
                                if (ch == ' ' && forceSpace) {
 
323
                                        if (insertedSpace) {
 
324
                                                AddChange(offset, 1, null);
 
325
                                        } else {
 
326
                                                insertedSpace = true;
 
327
                                        }
 
328
                                } else if (forceSpace) {
 
329
                                        if (!insertedSpace) {
 
330
                                                AddChange(offset, IsSpacing(ch) ? 1 : 0, " ");
 
331
                                                insertedSpace = true;
 
332
                                        } else if (IsSpacing(ch)) {
 
333
                                                AddChange(offset, 1, null);
 
334
                                        }
 
335
                                }
 
336
                                
 
337
                                offset--;
 
338
                        } while (offset >= 0);
 
339
                }
 
340
 
 
341
                public void FixSemicolon(CSharpTokenNode semicolon)
 
342
                {
 
343
                        if (semicolon.IsNull) {
 
344
                                return;
 
345
                        }
 
346
                        int endOffset = document.GetOffset(semicolon.StartLocation);
 
347
                        int offset = endOffset;
 
348
                        while (offset - 1 > 0 && char.IsWhiteSpace (document.GetCharAt (offset - 1))) {
 
349
                                offset--;
 
350
                        }
 
351
                        if (offset < endOffset) {
 
352
                                AddChange(offset, endOffset - offset, null);
 
353
                        }
 
354
                }
 
355
                
 
356
                void PlaceOnNewLine(NewLinePlacement newLine, AstNode keywordNode)
 
357
                {
 
358
                        if (keywordNode == null || newLine == NewLinePlacement.DoNotCare) {
 
359
                                return;
 
360
                        }
 
361
                        
 
362
                        var prev = keywordNode.GetPrevNode ();
 
363
                        if (prev is Comment || prev is PreProcessorDirective)
 
364
                                return;
 
365
                        
 
366
                        int offset = document.GetOffset(keywordNode.StartLocation);
 
367
                        
 
368
                        int whitespaceStart = SearchWhitespaceStart(offset);
 
369
                        string indentString = newLine == NewLinePlacement.NewLine ? options.EolMarker + curIndent.IndentString : " ";
 
370
                        AddChange(whitespaceStart, offset - whitespaceStart, indentString);
 
371
                }
 
372
                
 
373
                string nextStatementIndent;
 
374
                
 
375
                void FixStatementIndentation(TextLocation location)
 
376
                {
 
377
                        if (location.Line < 1 || location.Column < 1) {
 
378
                                Console.WriteLine("invalid location!");
 
379
                                return;
 
380
                        }
 
381
                        int offset = document.GetOffset(location);
 
382
                        if (offset <= 0) {
 
383
                                Console.WriteLine("possible wrong offset");
 
384
                                Console.WriteLine(Environment.StackTrace);
 
385
                                return;
 
386
                        }
 
387
                        bool isEmpty = IsLineIsEmptyUpToEol(offset);
 
388
                        int lineStart = SearchWhitespaceLineStart(offset);
 
389
                        string indentString = nextStatementIndent ?? (isEmpty ? "" : options.EolMarker) + curIndent.IndentString;
 
390
                        nextStatementIndent = null;
 
391
                        AddChange(lineStart, offset - lineStart, indentString);
 
392
                }
 
393
 
 
394
                void FixIndentation (AstNode node)
 
395
                {
 
396
                        FixIndentation(node.StartLocation, 0);
 
397
                }
 
398
                
 
399
                void FixIndentation(TextLocation location, int relOffset)
 
400
                {
 
401
                        if (location.Line < 1 || location.Line > document.LineCount) {
 
402
                                Console.WriteLine("Invalid location " + location);
 
403
                                Console.WriteLine(Environment.StackTrace);
 
404
                                return;
 
405
                        }
 
406
                        
 
407
                        string lineIndent = GetIndentation(location.Line);
 
408
                        string indentString = curIndent.IndentString;
 
409
                        if (indentString != lineIndent && location.Column - 1 + relOffset == lineIndent.Length) {
 
410
                                AddChange(document.GetOffset(location.Line, 1), lineIndent.Length, indentString);
 
411
                        }
 
412
                }
 
413
                
 
414
                void FixIndentationForceNewLine(AstNode node)
 
415
                {
 
416
                        if (node.GetPrevNode () is NewLineNode) {
 
417
                                FixIndentation(node);
 
418
                        } else {
 
419
                                int offset = document.GetOffset(node.StartLocation);
 
420
                                AddChange(offset, 0, curIndent.IndentString);
 
421
                        }
 
422
                }
 
423
 
 
424
                string GetIndentation(int lineNumber)
 
425
                {
 
426
                        var line = document.GetLineByNumber(lineNumber);
 
427
                        var b = new StringBuilder ();
 
428
                        int endOffset = line.EndOffset;
 
429
                        for (int i = line.Offset; i < endOffset; i++) {
 
430
                                char c = document.GetCharAt(i);
 
431
                                if (!IsSpacing(c)) {
 
432
                                        break;
 
433
                                }
 
434
                                b.Append(c);
 
435
                        }
 
436
                        return b.ToString();
 
437
                }
 
438
 
 
439
                
 
440
                void FixOpenBrace(BraceStyle braceStyle, AstNode lbrace)
 
441
                {
 
442
                        if (lbrace.IsNull)
 
443
                                return;
 
444
                        switch (braceStyle) {
 
445
                                case BraceStyle.DoNotChange:
 
446
                                        return;
 
447
 
 
448
                                case BraceStyle.BannerStyle:
 
449
                                case BraceStyle.EndOfLine:
 
450
                                        var prev = lbrace.GetPrevNode();
 
451
                                        while (prev is NewLineNode)
 
452
                                                prev = prev.GetPrevNode();
 
453
                                        if (prev is PreProcessorDirective)
 
454
                                                return;
 
455
                                        int prevOffset = document.GetOffset(prev.EndLocation);
 
456
 
 
457
                                        if (prev is Comment || prev is PreProcessorDirective) {
 
458
                                                int next = document.GetOffset(lbrace.GetNextNode ().StartLocation);
 
459
                                                AddChange(prevOffset, next - prevOffset, "");
 
460
                                                while (prev is Comment || prev is PreProcessorDirective)
 
461
                                                        prev = prev.GetPrevNode();
 
462
                                                prevOffset = document.GetOffset(prev.EndLocation);
 
463
                                                AddChange(prevOffset, 0, " {");
 
464
                                        } else {
 
465
                                                int braceOffset2 = document.GetOffset(lbrace.StartLocation);
 
466
                                                AddChange(prevOffset, braceOffset2 - prevOffset, " ");
 
467
                                        }
 
468
                                        break;
 
469
                                case BraceStyle.EndOfLineWithoutSpace:
 
470
                                        prev = lbrace.GetPrevNode();
 
471
                                        while (prev is NewLineNode)
 
472
                                                prev = prev.GetPrevNode();
 
473
                                        if (prev is PreProcessorDirective)
 
474
                                                return;
 
475
                                        prevOffset = document.GetOffset(prev.EndLocation);
 
476
                                        int braceOffset = document.GetOffset(lbrace.StartLocation);
 
477
                                        AddChange(prevOffset, braceOffset - prevOffset, "");
 
478
                                        break;
 
479
 
 
480
                                case BraceStyle.NextLine:
 
481
                                        prev = lbrace.GetPrevNode();
 
482
                                        while (prev is NewLineNode)
 
483
                                                prev = prev.GetPrevNode();
 
484
                                        if (prev is PreProcessorDirective)
 
485
                                                return;
 
486
                                        prevOffset = document.GetOffset(prev.EndLocation);
 
487
                                        braceOffset = document.GetOffset(lbrace.StartLocation);
 
488
                                        AddChange(prevOffset, braceOffset - prevOffset, options.EolMarker + curIndent.IndentString);
 
489
                                        break;
 
490
                                case BraceStyle.NextLineShifted:
 
491
                                        prev = lbrace.GetPrevNode();
 
492
                                        while (prev is NewLineNode)
 
493
                                                prev = prev.GetPrevNode();
 
494
                                        if (prev is PreProcessorDirective)
 
495
                                                return;
 
496
                                        prevOffset = document.GetOffset(prev.EndLocation);
 
497
                                        braceOffset = document.GetOffset(lbrace.StartLocation);
 
498
                                        curIndent.Push(IndentType.Block);
 
499
                                        AddChange(prevOffset, braceOffset - prevOffset, options.EolMarker + curIndent.IndentString);
 
500
                                        curIndent.Pop();
 
501
                                        break;
 
502
                                case BraceStyle.NextLineShifted2:
 
503
                                        prev = lbrace.GetPrevNode();
 
504
                                        while (prev is NewLineNode)
 
505
                                                prev = prev.GetPrevNode();
 
506
                                        if (prev is PreProcessorDirective)
 
507
                                                return;
 
508
                                        prevOffset = document.GetOffset(prev.EndLocation);
 
509
                                        braceOffset = document.GetOffset(lbrace.StartLocation);
 
510
                                        curIndent.Push(IndentType.Block);
 
511
                                        AddChange(prevOffset, braceOffset - prevOffset, options.EolMarker + curIndent.IndentString);
 
512
                                        curIndent.Pop();
 
513
                                        break;
 
514
                        }
 
515
                }
 
516
 
 
517
                void CorrectClosingBrace (AstNode rbrace)
 
518
                {
 
519
                        int braceOffset = document.GetOffset(rbrace.StartLocation);
 
520
                        var prevNode = rbrace.GetPrevNode();
 
521
                        int prevNodeOffset = prevNode != null ? document.GetOffset(prevNode.EndLocation) : 0;
 
522
                        if (prevNode is NewLineNode) {
 
523
                                AddChange(prevNodeOffset, braceOffset - prevNodeOffset, curIndent.IndentString);
 
524
                        } else {
 
525
                                AddChange(prevNodeOffset, braceOffset - prevNodeOffset, options.EolMarker + curIndent.IndentString);
 
526
                        }
 
527
                }
 
528
 
 
529
                void FixClosingBrace(BraceStyle braceStyle, AstNode rbrace)
 
530
                {
 
531
                        if (rbrace.IsNull)
 
532
                                return;
 
533
                        switch (braceStyle) {
 
534
                                case BraceStyle.DoNotChange:
 
535
                                        return;
 
536
 
 
537
                                case BraceStyle.NextLineShifted:
 
538
                                case BraceStyle.BannerStyle:
 
539
                                        curIndent.Push(IndentType.Block);
 
540
                                        CorrectClosingBrace (rbrace);
 
541
                                        curIndent.Pop ();
 
542
                                        break;
 
543
                                case BraceStyle.EndOfLineWithoutSpace:
 
544
                                case BraceStyle.EndOfLine:
 
545
                                case BraceStyle.NextLine:
 
546
                                        CorrectClosingBrace (rbrace);
 
547
                                        break;
 
548
 
 
549
                                case BraceStyle.NextLineShifted2:
 
550
                                        curIndent.Push(IndentType.Block);
 
551
                                        CorrectClosingBrace (rbrace);
 
552
                                        curIndent.Pop ();
 
553
                                        break;
 
554
                        }
 
555
 
 
556
                }
 
557
 
 
558
        }
 
559
}
 
560