~ubuntu-branches/ubuntu/wily/monodevelop/wily

« back to all changes in this revision

Viewing changes to src/addins/CSharpBinding/MonoDevelop.CSharp.ContextAction/MDRefactoringContext.cs

  • Committer: Package Import Robot
  • Author(s): Jo Shields
  • Date: 2012-05-27 18:08:20 UTC
  • mfrom: (19.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20120527180820-fydl21qnbnfr8w2t
Tags: 3.0.2+dfsg-3
* [fcecfe7] Fix monodevelop-core-addins.pc.in to point to actual 
  installed location of assemblies.
* [26e1a07] DebSrc 3.0 does not support Quilt's -p parameter, so 
  manually adjust the path in the patch file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
// 
2
 
// MDRefactoringContext.cs
3
 
//  
4
 
// Author:
5
 
//       Mike Krüger <mkrueger@novell.com>
6
 
// 
7
 
// Copyright (c) 2011 Novell, Inc (http://www.novell.com)
8
 
// 
9
 
// Permission is hereby granted, free of charge, to any person obtaining a copy
10
 
// of this software and associated documentation files (the "Software"), to deal
11
 
// in the Software without restriction, including without limitation the rights
12
 
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 
// copies of the Software, and to permit persons to whom the Software is
14
 
// furnished to do so, subject to the following conditions:
15
 
// 
16
 
// The above copyright notice and this permission notice shall be included in
17
 
// all copies or substantial portions of the Software.
18
 
// 
19
 
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22
 
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
 
// THE SOFTWARE.
26
 
 
27
 
using System;
28
 
using MonoDevelop.CSharp.Resolver;
29
 
using ICSharpCode.NRefactory.CSharp;
30
 
using System.Collections.Generic;
31
 
using Mono.TextEditor;
32
 
using MonoDevelop.Projects;
33
 
using MonoDevelop.Core;
34
 
using MonoDevelop.Refactoring;
35
 
using ICSharpCode.NRefactory.CSharp.Refactoring;
36
 
using ICSharpCode.NRefactory.TypeSystem;
37
 
using ICSharpCode.NRefactory.TypeSystem.Implementation;
38
 
using ICSharpCode.NRefactory.CSharp.Resolver;
39
 
 
40
 
namespace MonoDevelop.CSharp.ContextAction
41
 
{
42
 
        public class MDRefactoringContext : RefactoringContext
43
 
        {
44
 
                public MonoDevelop.Ide.Gui.Document Document {
45
 
                        get;
46
 
                        private set;
47
 
                }
48
 
                
49
 
                public override bool HasCSharp3Support {
50
 
                        get {
51
 
                                var project = Document.Project as DotNetProject;
52
 
                                if (project == null)
53
 
                                        return true;
54
 
                                switch (project.TargetFramework.ClrVersion) {
55
 
                                case ClrVersion.Net_1_1:
56
 
                                case ClrVersion.Net_2_0:
57
 
                                case ClrVersion.Clr_2_1:
58
 
                                        return false;
59
 
                                default:
60
 
                                        return true;
61
 
                                }
62
 
                        }
63
 
                }
64
 
                
65
 
                SimpleProjectContent content;
66
 
                public override ITypeResolveContext TypeResolveContext {
67
 
                        get {
68
 
                                return new SimpleProjectContent ();
69
 
/*                              if (content == null) {
70
 
                                        content = new SimpleProjectContent ();
71
 
                                        var newTypes = new List<ITypeDefinition> ();
72
 
                                        
73
 
                                        foreach (var file in Document.Project.Files) {
74
 
                                                if (!string.Equals (file.BuildAction, "compile", StringComparison.OrdinalIgnoreCase)) 
75
 
                                                        continue;
76
 
                                                var visitor = new TypeSystemConvertVisitor (content, file.FilePath);
77
 
                                                CSharpParser parser = new CSharpParser ();
78
 
                                                using (var stream = System.IO.File.OpenRead (file.FilePath)) {
79
 
                                                        var unit = parser.Parse (stream);
80
 
                                                        unit.AcceptVisitor (visitor, null);
81
 
                                                }
82
 
                                                Console.WriteLine (file.FilePath + ": add:" + visitor.ParsedFile.TopLevelTypeDefinitions.Count);
83
 
                                                content.UpdateProjectContent (null, visitor.ParsedFile.TopLevelTypeDefinitions, null, null);
84
 
                                        }
85
 
                                }
86
 
                                return content;*/
87
 
                        }
88
 
                }
89
 
                
90
 
                public override CSharpFormattingOptions FormattingOptions {
91
 
                        get {
92
 
                                var dom = Document.Dom;
93
 
                                var policyParent = dom != null && dom.Project != null ? dom.Project.Policies : null;
94
 
                                var types = MonoDevelop.Ide.DesktopService.GetMimeTypeInheritanceChain (MonoDevelop.CSharp.Formatting.CSharpFormatter.MimeType);
95
 
                                var codePolicy = policyParent != null ? policyParent.Get<MonoDevelop.CSharp.Formatting.CSharpFormattingPolicy> (types) : MonoDevelop.Projects.Policies.PolicyService.GetDefaultPolicy<MonoDevelop.CSharp.Formatting.CSharpFormattingPolicy> (types);
96
 
                                return codePolicy.CreateOptions ();
97
 
                        }
98
 
                }
99
 
                
100
 
                public override string EolMarker {
101
 
                        get {
102
 
                                return Document.Editor.EolMarker;
103
 
                        }
104
 
                }
105
 
                
106
 
                public override bool IsSomethingSelected { 
107
 
                        get {
108
 
                                return Document.Editor.IsSomethingSelected;
109
 
                        }
110
 
                }
111
 
                
112
 
                public override string SelectedText {
113
 
                        get {
114
 
                                return Document.Editor.SelectedText;
115
 
                        }
116
 
                }
117
 
                
118
 
                public override int SelectionStart {
119
 
                        get {
120
 
                                return Document.Editor.SelectionRange.Offset;
121
 
                        }
122
 
                }
123
 
                
124
 
                public override int SelectionEnd { 
125
 
                        get {
126
 
                                return Document.Editor.SelectionRange.EndOffset;
127
 
                        }
128
 
                }
129
 
                
130
 
                public override int SelectionLength {
131
 
                        get {
132
 
                                return Document.Editor.SelectionRange.Length;
133
 
                        }
134
 
                }
135
 
 
136
 
                public override int GetOffset (AstLocation location)
137
 
                {
138
 
                        return Document.Editor.LocationToOffset (location.Line, location.Column);
139
 
                }
140
 
                
141
 
                public override AstLocation GetLocation (int offset)
142
 
                {
143
 
                        var loc = Document.Editor.OffsetToLocation (offset);
144
 
                        return new AstLocation (loc.Line, loc.Column);
145
 
                }
146
 
 
147
 
                public override string GetText (int offset, int length)
148
 
                {
149
 
                        return Document.Editor.GetTextAt (offset, length);
150
 
                }
151
 
                
152
 
                #region IChangeFactory implementation
153
 
                
154
 
                class MdTextReplaceAction : TextReplaceAction
155
 
                {
156
 
                        MonoDevelop.Ide.Gui.Document doc;
157
 
                        
158
 
                        public MdTextReplaceAction (MonoDevelop.Ide.Gui.Document doc, int offset, int removedChars, string insertedText) : base (offset, removedChars, insertedText)
159
 
                        {
160
 
                                if (doc == null)
161
 
                                        throw new ArgumentNullException ("doc");
162
 
                                this.doc = doc;
163
 
                        }
164
 
                        
165
 
                        public override void Perform (Script script)
166
 
                        {
167
 
                                doc.Editor.Replace (Offset, RemovedChars, InsertedText);
168
 
                        }
169
 
                }
170
 
                
171
 
                public override TextReplaceAction CreateTextReplaceAction (int offset, int removedChars, string insertedText)
172
 
                {
173
 
                        return new MdTextReplaceAction (Document, offset, removedChars, insertedText);
174
 
                }
175
 
                
176
 
                class MdNodeOutputAction : NodeOutputAction
177
 
                {
178
 
                        MonoDevelop.Ide.Gui.Document doc;
179
 
                        
180
 
                        public MdNodeOutputAction (MonoDevelop.Ide.Gui.Document doc, int offset, int removedChars, NodeOutput output) : base (offset, removedChars, output)
181
 
                        {
182
 
                                if (doc == null)
183
 
                                        throw new ArgumentNullException ("doc");
184
 
                                if (output == null)
185
 
                                        throw new ArgumentNullException ("output");
186
 
                                this.doc = doc;
187
 
                        }
188
 
                        
189
 
                        public override void Perform (Script script)
190
 
                        {
191
 
                                doc.Editor.Replace (Offset, RemovedChars, NodeOutput.Text);
192
 
                        }
193
 
                }
194
 
                
195
 
                public override NodeOutputAction CreateNodeOutputAction (int offset, int removedChars, NodeOutput output)
196
 
                {
197
 
                        return new MdNodeOutputAction (Document, offset, removedChars, output);
198
 
                }
199
 
                
200
 
                class MdNodeSelectionAction : NodeSelectionAction
201
 
                {
202
 
                        MonoDevelop.Ide.Gui.Document doc;
203
 
                        
204
 
                        public MdNodeSelectionAction (MonoDevelop.Ide.Gui.Document doc, AstNode node) : base (node)
205
 
                        {
206
 
                                if (doc == null)
207
 
                                        throw new ArgumentNullException ("doc");
208
 
                                this.doc = doc;
209
 
                        }
210
 
                        
211
 
                        public override void Perform (Script script)
212
 
                        {
213
 
                                foreach (var action in script.Actions) {
214
 
                                        if (action == this)
215
 
                                                break;
216
 
                                        var noa = action as NodeOutputAction;
217
 
                                        if (noa == null)
218
 
                                                continue;
219
 
                                        NodeOutput.Segment segment;
220
 
                                        if (noa.NodeOutput.NodeSegments.TryGetValue (AstNode, out segment)) {
221
 
                                                var lead = noa.Offset + segment.EndOffset;
222
 
                                                doc.Editor.Caret.Offset = lead;
223
 
                                                doc.Editor.SetSelection (noa.Offset + segment.Offset, lead);
224
 
                                        }
225
 
                                }
226
 
                        }
227
 
                }
228
 
                
229
 
                public override NodeSelectionAction CreateNodeSelectionAction (AstNode node)
230
 
                {
231
 
                        return new MdNodeSelectionAction (this.Document, node);
232
 
                }
233
 
                
234
 
                class MdFormatTextAction : FormatTextAction
235
 
                {
236
 
                        MDRefactoringContext ctx;
237
 
 
238
 
                        public MdFormatTextAction (MDRefactoringContext ctx, Func<RefactoringContext, AstNode> callback) : base (callback)
239
 
                        {
240
 
                                this.ctx = ctx;
241
 
                        }
242
 
 
243
 
                        public override void Perform (Script script)
244
 
                        {
245
 
                                ctx.Document.UpdateParseDocument ();
246
 
                                ctx.Unit = ctx.Document.ParsedDocument.LanguageAST as ICSharpCode.NRefactory.CSharp.CompilationUnit;
247
 
                        
248
 
                                var node = Callback (ctx);
249
 
                                if (node != null)
250
 
                                        node.FormatText (ctx.Document);
251
 
                        }
252
 
                }
253
 
                
254
 
                public override FormatTextAction CreateFormatTextAction (Func<RefactoringContext, AstNode> callback)
255
 
                {
256
 
                        return new MdFormatTextAction (this, callback);
257
 
                }
258
 
                
259
 
                class MdLinkAction : CreateLinkAction
260
 
                {
261
 
                        MDRefactoringContext ctx;
262
 
                        
263
 
                        public MdLinkAction (MDRefactoringContext ctx, IEnumerable<AstNode> linkedNodes) : base (linkedNodes)
264
 
                        {
265
 
                                this.ctx = ctx;
266
 
                        }
267
 
                        
268
 
                        public override void Perform (Script script)
269
 
                        {
270
 
                                List<Segment> segments = new List<Segment> ();
271
 
                                foreach (var action in script.Actions) {
272
 
                                        if (action == this)
273
 
                                                break;
274
 
                                        var noa = action as NodeOutputAction;
275
 
                                        if (noa == null)
276
 
                                                continue;
277
 
                                        foreach (var astNode in Linked) {
278
 
                                                NodeOutput.Segment segment;
279
 
                                                if (noa.NodeOutput.NodeSegments.TryGetValue (astNode, out segment))
280
 
                                                        segments.Add (new Segment (noa.Offset + segment.Offset, segment.Length));
281
 
                                        }
282
 
                                }
283
 
                                segments.Sort ((x, y) => x.Offset.CompareTo (y.Offset));
284
 
                                var link = new TextLink ("name");
285
 
                                segments.ForEach (s => link.AddLink (s));
286
 
                                var links = new List<TextLink> ();
287
 
                                links.Add (link);
288
 
                                var tle = new TextLinkEditMode (ctx.Document.Editor.Parent, 0, links);
289
 
                                tle.SetCaretPosition = false;
290
 
                                if (tle.ShouldStartTextLinkMode) {
291
 
                                        tle.OldMode = ctx.Document.Editor.CurrentMode;
292
 
                                        tle.StartMode ();
293
 
                                        ctx.Document.Editor.CurrentMode = tle;
294
 
                                }
295
 
                        }
296
 
                }
297
 
                
298
 
                public override CreateLinkAction CreateLinkAction (IEnumerable<AstNode> linkedNodes)
299
 
                {
300
 
                        return new MdLinkAction (this, linkedNodes);
301
 
                }
302
 
                
303
 
                #endregion
304
 
                
305
 
                public class MdScript : Script
306
 
                {
307
 
                        MDRefactoringContext ctx;
308
 
                        
309
 
                        public MdScript (MDRefactoringContext ctx) : base(ctx)
310
 
                        {
311
 
                                this.ctx = ctx;
312
 
                        }
313
 
 
314
 
                        public static void RunActions (IList<ICSharpCode.NRefactory.CSharp.Refactoring.Action> actions, Script script)
315
 
                        {
316
 
                                for (int i = 0; i < actions.Count; i++) {
317
 
                                        actions [i].Perform (script);
318
 
                                        var replaceChange = actions [i] as TextReplaceAction;
319
 
                                        if (replaceChange == null)
320
 
                                                continue;
321
 
                                        for (int j = 0; j < actions.Count; j++) {
322
 
                                                if (i == j)
323
 
                                                        continue;
324
 
                                                var change = actions [j] as TextReplaceAction;
325
 
                                                if (change == null)
326
 
                                                        continue;
327
 
                                                if (replaceChange.Offset >= 0 && change.Offset >= 0) {
328
 
                                                        if (replaceChange.Offset < change.Offset) {
329
 
                                                                change.Offset -= replaceChange.RemovedChars;
330
 
                                                                if (!string.IsNullOrEmpty (replaceChange.InsertedText))
331
 
                                                                        change.Offset += replaceChange.InsertedText.Length;
332
 
                                                        } else if (replaceChange.Offset < change.Offset + change.RemovedChars) {
333
 
                                                                change.RemovedChars = Math.Max (0, change.RemovedChars - replaceChange.RemovedChars);
334
 
                                                                change.Offset = replaceChange.Offset + (!string.IsNullOrEmpty (replaceChange.InsertedText) ? replaceChange.InsertedText.Length : 0);
335
 
                                                        }
336
 
                                                }
337
 
                                        }
338
 
                                }
339
 
                        }
340
 
                        
341
 
                        public override void Dispose ()
342
 
                        {
343
 
                                RunActions (changes, this);
344
 
                        }
345
 
                        
346
 
                        public override void InsertWithCursor (string operation, AstNode node, InsertPosition defaultPosition)
347
 
                        {
348
 
                                var editor = ctx.Document.Editor;
349
 
                                var mode = new InsertionCursorEditMode (editor.Parent, MonoDevelop.Ide.CodeGenerationService.GetInsertionPoints (ctx.Document, ctx.Document.CompilationUnit.GetTypeAt (ctx.Location.Line, ctx.Location.Column)));
350
 
                                var helpWindow = new Mono.TextEditor.PopupWindow.ModeHelpWindow ();
351
 
                                helpWindow.TransientFor = MonoDevelop.Ide.IdeApp.Workbench.RootWindow;
352
 
                                helpWindow.TitleText = string.Format (GettextCatalog.GetString ("<b>{0} -- Targeting</b>"), operation);
353
 
                                helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Key</b>"), GettextCatalog.GetString ("<b>Behavior</b>")));
354
 
                                helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Up</b>"), GettextCatalog.GetString ("Move to <b>previous</b> target point.")));
355
 
                                helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Down</b>"), GettextCatalog.GetString ("Move to <b>next</b> target point.")));
356
 
                                helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Enter</b>"), GettextCatalog.GetString ("<b>Accept</b> target point.")));
357
 
                                helpWindow.Items.Add (new KeyValuePair<string, string> (GettextCatalog.GetString ("<b>Esc</b>"), GettextCatalog.GetString ("<b>Cancel</b> this operation.")));
358
 
                                mode.HelpWindow = helpWindow;
359
 
                                
360
 
                                switch (defaultPosition) {
361
 
                                case InsertPosition.Start:
362
 
                                        mode.CurIndex = 0;
363
 
                                        break;
364
 
                                case InsertPosition.End:
365
 
                                        mode.CurIndex = mode.InsertionPoints.Count - 1;
366
 
                                        break;
367
 
                                case InsertPosition.Before:
368
 
                                        for (int i = 0; i < mode.InsertionPoints.Count; i++) {
369
 
                                                if (mode.InsertionPoints [i].Location < new DocumentLocation (ctx.Location.Line, ctx.Location.Column))
370
 
                                                        mode.CurIndex = i;
371
 
                                        }
372
 
                                        break;
373
 
                                case InsertPosition.After:
374
 
                                        for (int i = 0; i < mode.InsertionPoints.Count; i++) {
375
 
                                                if (mode.InsertionPoints [i].Location > new DocumentLocation (ctx.Location.Line, ctx.Location.Column)) {
376
 
                                                        mode.CurIndex = i;
377
 
                                                        break;
378
 
                                                }
379
 
                                        }
380
 
                                        break;
381
 
                                }
382
 
                                
383
 
                                mode.StartMode ();
384
 
                                mode.Exited += delegate(object s, InsertionCursorEventArgs iCArgs) {
385
 
                                        if (iCArgs.Success) {
386
 
                                                var output = OutputNode (GetIndentLevelAt (editor.LocationToOffset (iCArgs.InsertionPoint.Location)), node);
387
 
                                                iCArgs.InsertionPoint.Insert (editor, output.Text);
388
 
                                        }
389
 
                                };
390
 
                        }
391
 
                        
392
 
                }
393
 
                
394
 
                public override Script StartScript ()
395
 
                {
396
 
                        return new MdScript (this);
397
 
                }
398
 
                
399
 
                public MDRefactoringContext (MonoDevelop.Ide.Gui.Document document, MonoDevelop.Projects.Dom.DomLocation loc)
400
 
                {
401
 
                        if (document == null)
402
 
                                throw new ArgumentNullException ("document");
403
 
                        this.Document = document;
404
 
                        this.Location = new AstLocation (loc.Line, loc.Column);
405
 
                        this.Unit = document.ParsedDocument.LanguageAST as ICSharpCode.NRefactory.CSharp.CompilationUnit;
406
 
                }
407
 
                
408
 
        /*      public override AstType CreateShortType (AstType fullType)
409
 
                {
410
 
                        return MonoDevelop.ContextAction.ContextAction.ShortenTypeName (Document, fullType.ConvertToReturnType ());
411
 
                }
412
 
                
413
 
                public override AstType CreateShortType (string fullTypeName)
414
 
                {
415
 
                        return MonoDevelop.ContextAction.ContextAction.ShortenTypeName (Document, fullTypeName);
416
 
                }
417
 
                */
418
 
                
419
 
                NRefactoryResolver resolver;
420
 
                public NRefactoryResolver Resolver {
421
 
                        get {
422
 
                                if (resolver == null)
423
 
                                        resolver = new NRefactoryResolver (Document.Dom, Document.CompilationUnit, Document.Editor, Document.FileName); 
424
 
                                return resolver;
425
 
                        }
426
 
                }
427
 
        /*      
428
 
                Dictionary<AstNode, MonoDevelop.Projects.Dom.ResolveResult> resolveCache = new Dictionary<AstNode, MonoDevelop.Projects.Dom.ResolveResult> ();
429
 
                MonoDevelop.Projects.Dom.ResolveResult Resolve (AstNode node)
430
 
                {
431
 
                        MonoDevelop.Projects.Dom.ResolveResult result;
432
 
                        if (!resolveCache.TryGetValue (node, out result))
433
 
                                resolveCache [node] = result = Resolver.Resolve (node.ToString (), new  MonoDevelop.Projects.Dom.DomLocation (Location.Line, Location.Column));
434
 
                        return result;
435
 
                }
436
 
                
437
 
                public override AstType ResolveType (AstNode node)
438
 
                {
439
 
                        var resolveResult = Resolve (node);
440
 
                        if (resolveResult == null || resolveResult.ResolvedType == null || string.IsNullOrEmpty (resolveResult.ResolvedType.FullName))
441
 
                                return null;
442
 
                        return MonoDevelop.ContextAction.ContextAction.ShortenTypeName (Document, resolveResult.ResolvedType);
443
 
                }
444
 
                
445
 
                */
446
 
                ParsedFile ParsedFile {
447
 
                        get {
448
 
                                var visitor = new TypeSystemConvertVisitor ((IProjectContent) TypeResolveContext, Document.FileName);
449
 
                                Unit.AcceptVisitor (visitor, null);
450
 
                                return visitor.ParsedFile;
451
 
                        }
452
 
                }
453
 
                
454
 
        /*      public override IEnumerable<ICSharpCode.NRefactory.TypeSystem.IMember> ResolveMember (Expression expression)
455
 
                {
456
 
                        var pf = ParsedFile;
457
 
                        var csResolver = new CSharpResolver (TypeResolveContext, System.Threading.CancellationToken.None);
458
 
                        var navigator = new NodeListResolveVisitorNavigator (new[] { expression });
459
 
                        
460
 
                        var visitor = new ICSharpCode.NRefactory.CSharp.Resolver.ResolveVisitor (csResolver, pf, navigator);
461
 
                
462
 
                        visitor.VisitCompilationUnit (Unit, null);
463
 
                        var resolveResult = visitor.Resolve (expression);
464
 
                        if (resolveResult == null)
465
 
                                yield break;
466
 
                        if (resolveResult is MemberResolveResult) {
467
 
                                yield return ((MemberResolveResult)resolveResult).Member;
468
 
                        } else if (resolveResult is MethodGroupResolveResult) {
469
 
                                var mgg = (MethodGroupResolveResult)resolveResult;
470
 
                                foreach (var m in mgg.Methods)
471
 
                                        yield return m;
472
 
                        }
473
 
                }*/     
474
 
                
475
 
                public override void ReplaceReferences (ICSharpCode.NRefactory.TypeSystem.IMember member, MemberDeclaration replaceWidth)
476
 
                {
477
 
                        // TODO
478
 
                }
479
 
                
480
 
//              public override ICSharpCode.NRefactory.TypeSystem.ITypeDefinition GetDefinition (AstType resolvedType)
481
 
//              {
482
 
//                      var rr = Resolve (resolvedType);
483
 
//                      if (rr == null)
484
 
//                              return null;
485
 
//                      var type = Document.Dom.GetType (rr.ResolvedType);
486
 
//                      if (type == null)
487
 
//                              return null;
488
 
//                      return TypeResolveContext.GetClass (type.Namespace, type.Name, type.TypeParameters.Count, StringComparer.InvariantCulture);
489
 
//              }
490
 
                
491
 
                /*
492
 
                public bool IsValid {
493
 
                        get {
494
 
                                return Unit != null;
495
 
                        }
496
 
                }
497
 
                
498
 
                public int GetIndentLevel (AstNode node)
499
 
                {
500
 
                        return GetIndentLevel (node.StartLocation.Line);
501
 
                }
502
 
                                
503
 
                public int GetIndentLevel (int line)
504
 
                {
505
 
                        return Document.CalcIndentLevel (Document.Editor.GetLineIndent (line));
506
 
                }
507
 
                
508
 
                public void SetSelection (AstNode node)
509
 
                {
510
 
                        this.selectNode = node;
511
 
                }
512
 
                
513
 
                AstNode selectNode = null;
514
 
                
515
 
                
516
 
                NodeOutput OutputNode (AstNode node, int indentLevel, Action<int, AstNode> outputStarted = null)
517
 
                {
518
 
                        NodeOutput result = new NodeOutput ();
519
 
                        
520
 
                        return Document.OutputNode (node, indentLevel, delegate(int outOffset, AstNode outNode) {
521
 
                                result.nodeSegments [outNode] = new Segment (outOffset, 0);
522
 
                                if (outputStarted != null)
523
 
                                        outputStarted (outOffset, outNode);
524
 
                        }, delegate(int outOffset, AstNode outNode) {
525
 
                                result.nodeSegments [outNode].Length = outOffset - result.nodeSegments [outNode].Offset;
526
 
                        });
527
 
                }
528
 
                
529
 
                public void StartTextLinkMode (int baseOffset, int replaceLength, IEnumerable<int> offsets)
530
 
                {
531
 
                        CommitChanges ();
532
 
                }
533
 
                
534
 
                
535
 
 
536
 
                public string GetText (AstNode node)
537
 
                {
538
 
                        return Document.Editor.GetTextAt (GetSegment (node));
539
 
                }
540
 
                
541
 
                public ISegment GetSegment (AstNode node)
542
 
                {
543
 
                        var startOffset = Document.Editor.LocationToOffset (node.StartLocation.Line, node.StartLocation.Column);
544
 
                        var endOffset   = Document.Editor.LocationToOffset (node.EndLocation.Line, node.EndLocation.Column);
545
 
                        
546
 
                        return new Segment (startOffset, endOffset - startOffset);
547
 
                }
548
 
                
549
 
                public void FormatText (Func<MDRefactoringContext, AstNode> update)
550
 
                {
551
 
                }
552
 
                
553
 
                
554
 
                
555
 
                
556
 
 
557
 
                */
558
 
                
559
 
                //these methods don't get used in 2.8
560
 
                
561
 
                public override AstType CreateShortType (AstType fullType)
562
 
                {
563
 
                        throw new NotImplementedException ();
564
 
                }
565
 
                
566
 
                public override AstType CreateShortType (ICSharpCode.NRefactory.TypeSystem.IType fullType)
567
 
                {
568
 
                        throw new NotImplementedException ();
569
 
                }
570
 
                
571
 
                public override ResolveResult Resolve (AstNode expression)
572
 
                {
573
 
                        throw new NotImplementedException ();
574
 
                }
575
 
        }
576
 
}