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

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/CodeGenerationService.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:
66
66
                        if (newMember is CodeMemberMethod)
67
67
                                options.BracingStyle = "C";
68
68
                        generator.GenerateCodeFromMember (newMember, sw, options);
69
 
                        
70
 
                        suitableInsertionPoint.Insert (data, sw.ToString ());
 
69
 
 
70
                        var code = sw.ToString ();
 
71
                        if (!string.IsNullOrEmpty (code))
 
72
                                suitableInsertionPoint.Insert (data, code);
71
73
                        if (!isOpen) {
72
74
                                try {
73
75
                                        File.WriteAllText (type.Region.FileName, data.Text);
114
116
                                indentLevel++;
115
117
                                declaringType = declaringType.DeclaringTypeDefinition;
116
118
                        }
117
 
                        var file = declaringType.ParsedFile as CSharpParsedFile;
 
119
                        var file = declaringType.UnresolvedFile as CSharpUnresolvedFile;
118
120
                        if (file == null)
119
121
                                return indentLevel;
120
122
                        var scope = file.GetUsingScope (declaringType.Region.Begin);
249
251
                                if (line != null) {
250
252
                                        var lineOffset = line.Offset;
251
253
                                        col = Math.Min (line.Length, col);
252
 
                                        while (lineOffset + col - 2 >= 0 && char.IsWhiteSpace (data.GetCharAt (lineOffset + col - 2)))
 
254
                                        while (lineOffset + col - 2 >= 0 && col > 1 && char.IsWhiteSpace (data.GetCharAt (lineOffset + col - 2)))
253
255
                                                col--;
254
256
                                }
255
257
                                result.Add (new InsertionPoint (new DocumentLocation (type.BodyRegion.EndLine, col), insertLine, NewLineInsertion.Eol));
262
264
                                result.Add (new InsertionPoint (new DocumentLocation (region.Region.EndLine + 1, 1), NewLineInsertion.Eol, NewLineInsertion.Eol));
263
265
                        }
264
266
                        result.Sort ((left, right) => left.Location.CompareTo (right.Location));
 
267
//                      foreach (var res in result)
 
268
//                              Console.WriteLine (res);
265
269
                        return result;
266
270
                }
267
271
 
313
317
                        if (nextLine == null) // check for 1 line case.
314
318
                                return new InsertionPoint (new DocumentLocation (line, column + 1), NewLineInsertion.BlankLine, NewLineInsertion.BlankLine);
315
319
                        
316
 
                        for (int i = nextLine.Offset; i < nextLine.Offset + nextLine.Length; i++) {
 
320
                        for (int i = nextLine.Offset; i < nextLine.EndOffset; i++) {
317
321
                                char ch = doc.GetCharAt (i);
318
322
                                if (!char.IsWhiteSpace (ch)) {
319
323
                                        // case2: next line contains non ws chars.
320
324
                                        return new InsertionPoint (new DocumentLocation (line + 1, 1), NewLineInsertion.Eol, NewLineInsertion.BlankLine);
321
325
                                }
322
326
                        }
323
 
                        // case3: whitespace line
 
327
 
 
328
                        DocumentLine nextLine2 = doc.GetLine (line + 2);
 
329
                        if (nextLine2 != null) {
 
330
                                for (int i = nextLine2.Offset; i < nextLine2.EndOffset; i++) {
 
331
                                        char ch = doc.GetCharAt (i);
 
332
                                        if (!char.IsWhiteSpace (ch)) {
 
333
                                                // case3: one blank line
 
334
                                                return new InsertionPoint (new DocumentLocation (line + 1, 1), NewLineInsertion.Eol, NewLineInsertion.Eol);
 
335
                                        }
 
336
                                }
 
337
                        }
 
338
                        // case4: more than 1 blank line
324
339
                        return new InsertionPoint (new DocumentLocation (line + 1, 1), NewLineInsertion.Eol, NewLineInsertion.None);
325
340
                }
326
341