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

« back to all changes in this revision

Viewing changes to src/core/MonoDevelop.Ide/MonoDevelop.Ide.TypeSystem/ParsedDocument.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:
31
31
using System.Threading;
32
32
using ICSharpCode.NRefactory;
33
33
using ICSharpCode.NRefactory.Semantics;
 
34
using Mono.TextEditor;
34
35
 
35
36
 
36
37
namespace MonoDevelop.Ide.TypeSystem
53
54
                [NonSerialized]
54
55
                List<Comment> comments = new List<Comment> ();
55
56
                
56
 
                public virtual IParsedFile ParsedFile {
 
57
                public virtual IUnresolvedFile ParsedFile {
57
58
                        get { return null; }
58
59
                        set { throw new InvalidOperationException (); }
59
60
                }
79
80
                        }
80
81
                }
81
82
                
82
 
                List<FoldingRegion> foldings = new List<FoldingRegion> ();
 
83
                IEnumerable<FoldingRegion> foldings = null;
83
84
                public virtual IEnumerable<FoldingRegion> Foldings {
84
85
                        get {
85
 
                                return foldings;
 
86
                                return foldings ?? Enumerable.Empty<FoldingRegion> ();
86
87
                        }
87
88
                }
88
89
                
181
182
                {
182
183
                        conditionalRegions.Add (region);
183
184
                }
 
185
 
 
186
                List<FoldingRegion> EnsureFoldingList ()
 
187
                {
 
188
                        if (this.foldings == null || !(foldings is List<FoldingRegion>))
 
189
                                this.foldings = new List<FoldingRegion> ();
 
190
                        return (List<FoldingRegion>)foldings;
 
191
                }
184
192
                
185
193
                public void Add (FoldingRegion region)
186
194
                {
187
 
                        foldings.Add (region);
 
195
                        EnsureFoldingList ().Add (region);
188
196
                }
189
197
                
190
198
                public void Add (IEnumerable<Comment> comments)
204
212
                
205
213
                public void Add (IEnumerable<FoldingRegion> folds)
206
214
                {
207
 
                        this.foldings.AddRange (folds);
 
215
                        if (foldings == null) {
 
216
                                this.foldings = folds;
 
217
                                return;
 
218
                        }
 
219
                        if (foldings != null && !(foldings is List<FoldingRegion>))
 
220
                                EnsureFoldingList ().AddRange (foldings);
 
221
                        EnsureFoldingList ().AddRange (folds);
208
222
                }
209
223
                
210
224
                public void Add (IEnumerable<ConditionalRegion> conditionalRegions)
212
226
                        this.conditionalRegions.AddRange (conditionalRegions);
213
227
                }
214
228
                
215
 
                #region IParsedFile delegation
 
229
                #region IUnresolvedFile delegation
216
230
                public virtual IUnresolvedTypeDefinition GetTopLevelTypeDefinition (TextLocation location)
217
231
                {
218
232
                        return null;
234
248
                        }
235
249
                }
236
250
 
237
 
                public virtual ITypeResolveContext GetTypeResolveContext (ICompilation compilation, TextLocation loc)
238
 
                {
239
 
                        return null;
240
 
                }
241
251
                #endregion
 
252
 
 
253
                public Func<MonoDevelop.Ide.Gui.Document, CancellationToken, object> CreateRefactoringContext;
 
254
                public Func<TextEditorData, object, CancellationToken, object> CreateRefactoringContextWithEditor;
242
255
        }
243
256
        
244
 
        public class DefaultParsedDocument : ParsedDocument, IParsedFile
 
257
        public class DefaultParsedDocument : ParsedDocument, IUnresolvedFile
245
258
        {
246
259
 
247
 
                public override IParsedFile ParsedFile {
 
260
                public override IUnresolvedFile ParsedFile {
248
261
                        get { return this; }
249
262
                }
250
263
                
261
274
                        
262
275
                }
263
276
                
264
 
                #region IParsedFile implementation
 
277
                #region IUnresolvedFile implementation
265
278
                public override IUnresolvedTypeDefinition GetTopLevelTypeDefinition(TextLocation location)
266
279
                {
267
280
                        return TopLevelTypeDefinitions.FirstOrDefault (t => t.Region.IsInside (location));
299
312
                                return attributes;
300
313
                        }
301
314
                }
302
 
                
303
 
                public ITypeResolveContext GetTypeResolveContext (ICompilation compilation, TextLocation loc)
304
 
                {
305
 
                        return null;
306
 
                }
307
315
 
308
316
                public IList<IUnresolvedAttribute> ModuleAttributes {
309
317
                        get {
322
330
                        this.errors.AddRange (errors);
323
331
                }
324
332
 
325
 
                #region IParsedFile implementation
326
 
                DateTime? IParsedFile.LastWriteTime {
 
333
                #region IUnresolvedFile implementation
 
334
                DateTime? IUnresolvedFile.LastWriteTime {
327
335
                        get {
328
336
                                return LastWriteTimeUtc;
329
337
                        }
337
345
        [Serializable]
338
346
        public class ParsedDocumentDecorator : ParsedDocument
339
347
        {
340
 
                IParsedFile parsedFile;
 
348
                IUnresolvedFile parsedFile;
341
349
                
342
 
                public override IParsedFile ParsedFile {
 
350
                public override IUnresolvedFile ParsedFile {
343
351
                        get { return parsedFile; }
344
352
                        set { parsedFile = value; FileName = parsedFile.FileName; }
345
353
                }
350
358
                        }
351
359
                }
352
360
                
353
 
                public ParsedDocumentDecorator (IParsedFile parsedFile) : base (parsedFile.FileName)
 
361
                public ParsedDocumentDecorator (IUnresolvedFile parsedFile) : base (parsedFile.FileName)
354
362
                {
355
363
                        this.parsedFile = parsedFile;
356
364
                }
359
367
                {
360
368
                }
361
369
                
362
 
                #region IParsedFile implementation
 
370
                #region IUnresolvedFile implementation
363
371
                public override IUnresolvedTypeDefinition GetTopLevelTypeDefinition (TextLocation location)
364
372
                {
365
373
                        return parsedFile.GetTopLevelTypeDefinition (location);
366
374
                }
367
 
                
 
375
 
368
376
                public override IUnresolvedTypeDefinition GetInnermostTypeDefinition (TextLocation location)
369
377
                {
370
378
                        return parsedFile.GetInnermostTypeDefinition (location);
380
388
                                return parsedFile.TopLevelTypeDefinitions;
381
389
                        }
382
390
                }
383
 
                
384
 
                public override ITypeResolveContext GetTypeResolveContext (ICompilation compilation, TextLocation loc)
385
 
                {
386
 
                        return parsedFile.GetTypeResolveContext (compilation, loc);
387
 
                }
388
391
                #endregion
389
392
        }
390
393
        
493
496
                        // tab widths. Maybe that would work best by performing the ellipsis in the editor, instead of the parser.
494
497
                        const int TRUNC_LEN = 60;
495
498
                        
 
499
                        if (start == 0 && length == str.Length)
 
500
                                return str;
 
501
 
496
502
                        if (str.Length == 0 || length == 0)
497
503
                                return " ...";
498
504
                        
503
509
                                        if (wordBoundaryLen > TRUNC_LEN - 20)
504
510
                                                length = wordBoundaryLen;
505
511
                                }
506
 
                                str = str.Substring (start, length);
507
512
                        }
508
 
                        
 
513
                        str = str.Substring (start, length);
 
514
                                
509
515
                        if (str [str.Length - 1] == '.')
510
516
                                return str + "..";
511
517
                        else if (char.IsPunctuation (str [str.Length - 1]))