~ubuntu-branches/ubuntu/oneiric/monodevelop/oneiric

« back to all changes in this revision

Viewing changes to src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.RefactorImports/RemoveUnusedImportsRefactoring.cs

  • Committer: Bazaar Package Importer
  • Author(s): Jo Shields
  • Date: 2011-06-27 17:03:13 UTC
  • mto: (1.8.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 54.
  • Revision ID: james.westby@ubuntu.com-20110627170313-6cvz3s19x6e9hqe9
ImportĀ upstreamĀ versionĀ 2.5.92+dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
                public override List<Change> PerformChanges (RefactoringOptions options, object properties)
49
49
                {
50
50
                        List<Change> result = new List<Change> ();
51
 
                        ICSharpCode.NRefactory.Ast.CompilationUnit unit = options.GetASTProvider ().ParseFile (options.Document.TextEditor.Text);
 
51
                        ICSharpCode.NRefactory.Ast.CompilationUnit unit = options.GetASTProvider ().ParseFile (options.Document.Editor.Text);
52
52
                        FindTypeReferencesVisitor visitor = new FindTypeReferencesVisitor (options.GetTextEditorData (), options.GetResolver ());
53
53
                        visitor.VisitCompilationUnit (unit, null);
54
54
 
59
59
                        foreach (TypeReference r in visitor.PossibleTypeReferences) {
60
60
                                if (r.IsKeyword)
61
61
                                        continue;
62
 
                                IType type = dom.SearchType (compilationUnit, r.ConvertToReturnType ());
 
62
                                IType type = dom.SearchType (compilationUnit, options.ResolveResult.CallingType, new DomLocation (options.Document.Editor.Caret.Line, options.Document.Editor.Caret.Column), r.ConvertToReturnType ());
63
63
                                if (type != null) {
64
64
                                        usedUsings.Add (type.Namespace);
65
65
                                }
73
73
                                if (!u.Aliases.Any () && u.Namespaces.All (name => currentUsings.Contains (name) || !usedUsings.Contains (name)) ) {
74
74
                                        TextReplaceChange change = new TextReplaceChange ();
75
75
                                        change.FileName = options.Document.FileName;
76
 
                                        change.Offset = textEditorData.Document.LocationToOffset (u.Region.Start.Line - 1, u.Region.Start.Column - 1);
77
 
                                        change.RemovedChars = textEditorData.Document.LocationToOffset (u.Region.End.Line - 1, u.Region.End.Column - 1) - change.Offset;
 
76
                                        change.Offset = textEditorData.Document.LocationToOffset (u.Region.Start.Line, u.Region.Start.Column);
 
77
                                        change.RemovedChars = textEditorData.Document.LocationToOffset (u.Region.End.Line, u.Region.End.Column) - change.Offset;
78
78
                                        Mono.TextEditor.LineSegment line = textEditorData.Document.GetLineByOffset (change.Offset);
79
79
                                        if (line != null && line.EditableLength == change.RemovedChars)
80
80
                                                change.RemovedChars += line.DelimiterLength;