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

« back to all changes in this revision

Viewing changes to src/addins/CSharpBinding/MonoDevelop.CSharp.Formatting/CSharpIndentEngine.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:
30
30
using System.Text;
31
31
 
32
32
using MonoDevelop.Ide.Gui.Content;
33
 
 
34
33
using MonoDevelop.CSharp.Formatting;
35
 
using MonoDevelop.CSharp.Parser;
36
34
 
37
35
namespace MonoDevelop.CSharp.Formatting
38
36
{
75
73
                int cursor;
76
74
                CSharpFormattingPolicy policy;
77
75
                TextStylePolicy textPolicy;
78
 
                // Constructors
79
76
 
80
77
                public CSharpIndentEngine (CSharpFormattingPolicy policy, TextStylePolicy textPolicy)
81
78
                {
146
143
                public bool IsInsideStringLiteral {
147
144
                        get { return (stack.PeekInside (0) & (Inside.StringLiteral)) != 0; }
148
145
                }
149
 
                
150
 
                
151
 
                
 
146
 
152
147
                string TabsToSpaces (string indent)
153
148
                {
154
149
                        StringBuilder builder;
326
321
                }
327
322
                
328
323
                //directive keywords that we care about
329
 
                static string[] directiveKeywords = new string [] {"region", "endregion" };
 
324
                static string[] directiveKeywords = new string [] { "region", "endregion" };
330
325
                
331
326
                string GetDirectiveKeyword (char currentChar)
332
327
                {
338
333
                                return null;
339
334
                        
340
335
                        for (int i = 0; i < directiveKeywords.Length; i++) {
341
 
                                if (directiveKeywords[i].StartsWith (str)) {
 
336
                                if (directiveKeywords[i].StartsWith (str, StringComparison.Ordinal)) {
342
337
                                        if (str == directiveKeywords[i])
343
338
                                                return directiveKeywords[i];
344
 
                                        else
345
 
                                                return null;
 
339
 
 
340
                                        return null;
346
341
                                }
347
342
                        }
348
343
                        
444
439
                        
445
440
                        // got a "/*" - might start a MultiLineComment
446
441
                        if ((inside & (Inside.StringOrChar | Inside.Comment)) != 0) {
447
 
//                              if ((inside & Inside.MultiLineComment) != 0)
448
 
//                                      Console.WriteLine ("Watch out! Nested /* */ comment detected!");
 
442
                                // if ((inside & Inside.MultiLineComment) != 0) - user seems to have nested /* */ comments...
449
443
                                return;
450
444
                        }
451
445
                        
555
549
                                switch (style) {
556
550
                                case GotoLabelIndentStyle.LeftJustify:
557
551
                                        needsReindent = true;
558
 
                        //              curIndent = " ";
 
552
                                        //curIndent = " ";
559
553
                                        break;
560
554
                                case GotoLabelIndentStyle.OneLess:
561
555
                                        needsReindent = true;
562
556
                                        TrimIndent ();
563
 
                        //              curIndent += " ";
 
557
                                        //curIndent += " ";
564
558
                                        break;
565
559
                                default:
566
560
                                        break;
690
684
                                }
691
685
                        } else {
692
686
                                stack.Push (Inside.Block, keyword, curLineNr, 0);
693
 
// Destroys one lined expression block 'var s = "".Split (new char[] {' '});'
694
 
//                              if (inside == Inside.ParenList)
695
 
//                                      TrimIndent ();
 
687
                                // Destroys one lined expression block 'var s = "".Split (new char[] {' '});'
 
688
                                //if (inside == Inside.ParenList)
 
689
                                //      TrimIndent ();
696
690
                        }
697
691
                        
698
692
                        keyword = String.Empty;
783
777
                                        break;
784
778
                                }
785
779
 
786
 
                                                                /* not escaped... error!! but what can we do,
 
780
                                /* not escaped... error!! but what can we do,
787
781
                                 * eh? allow folding across multiple lines I
788
782
                                 * guess... */
789
783
                                break;
890
884
                {
891
885
                        var after = stack.PeekInside (0);
892
886
                        if ((after & Inside.ParenList) == Inside.ParenList && pc == '(') {
893
 
//                              var indent = stack.PeekIndent (0);
 
887
                                //var indent = stack.PeekIndent (0);
894
888
                                var kw = stack.PeekKeyword (0);
895
889
                                var line = stack.PeekLineNr (0);
896
890
                                stack.Pop ();