diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 12:54:09 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 12:54:09 +0400 |
commit | 53f94e824373911043765358880ba066b3dac06c (patch) | |
tree | 8f72ed3fdf448524990d4bad381d5af584cb457a /main/src | |
parent | 38fa27f9e109d0cd7825896fe7db0e31b052df34 (diff) |
[CSharpBinding] Track nrefactory API changes.
Diffstat (limited to 'main/src')
4 files changed, 25 insertions, 19 deletions
diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs index 143f87379b..8507ab30a0 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs @@ -175,6 +175,7 @@ namespace MonoDevelop.CSharp.Completion return null; var list = new CompletionDataList (); var engine = new CSharpCompletionEngine (textEditorData.Document, this); + engine.ctx = CSharpParsedFile.GetTypeResolveContext (Document.Compilation, document.Editor.Caret.Location); engine.Unit = Unit; engine.CSharpParsedFile = CSharpParsedFile; engine.FormattingPolicy = FormattingPolicy.CreateOptions (); @@ -316,6 +317,7 @@ namespace MonoDevelop.CSharp.Completion if (Unit == null || CSharpParsedFile == null) return null; var engine = new CSharpParameterCompletionEngine (textEditorData.Document, this); + engine.ctx = CSharpParsedFile.GetTypeResolveContext (Document.Compilation, document.Editor.Caret.Location); engine.Unit = Unit; engine.CSharpParsedFile = CSharpParsedFile; engine.ProjectContent = Document.GetProjectContext (); diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethod/ExtractMethodRefactoring.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethod/ExtractMethodRefactoring.cs index 10a7ab4a80..05cf663911 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethod/ExtractMethodRefactoring.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Refactoring/ExtractMethod/ExtractMethodRefactoring.cs @@ -45,6 +45,7 @@ using ICSharpCode.NRefactory.TypeSystem.Implementation; using ICSharpCode.NRefactory.TypeSystem; using MonoDevelop.TypeSystem; using ICSharpCode.NRefactory; +using ICSharpCode.NRefactory.CSharp.TypeSystem; namespace MonoDevelop.CSharp.Refactoring.ExtractMethod { @@ -468,7 +469,6 @@ namespace MonoDevelop.CSharp.Refactoring.ExtractMethod EolMarker = options.Document.Editor.EolMarker, TabSize = options.Document.Editor.Options.TabSize }; - var ctx = options.Document.TypeResolveContext; IUnresolvedTypeDefinition callingType = null; var cu = options.Document.ParsedDocument; if (cu != null) @@ -476,9 +476,11 @@ namespace MonoDevelop.CSharp.Refactoring.ExtractMethod var newMethod = GenerateMethodStub (options, callingType, param); var createdMethod = codeGenerator.CreateMemberImplementation (callingType, newMethod, false); - - if (param.GenerateComment && DocGenerator.Instance != null) - methodText.AppendLine (DocGenerator.Instance.GenerateDocumentation (newMethod, indent + "/// ")); + + if (param.GenerateComment && DocGenerator.Instance != null) { + var ctx = (cu.ParsedFile as CSharpParsedFile).GetTypeResolveContext (options.Document.Compilation, callingType.Region.Begin); + methodText.AppendLine (DocGenerator.Instance.GenerateDocumentation (newMethod.CreateResolved (ctx), indent + "/// ")); + } string code = createdMethod.Code; int idx1 = code.LastIndexOf ("throw"); int idx2 = code.LastIndexOf (";"); diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs index 8ce2dbc524..12933388ef 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp/PathedDocumentTextEditorExtension.cs @@ -249,20 +249,24 @@ namespace MonoDevelop.CSharp var result = new List<PathEntry> (); var amb = GetAmbience (); var ctx = (unit.ParsedFile as CSharpParsedFile).GetTypeResolveContext (document.Compilation, loc); - - var type = unit.GetInnermostTypeDefinition (loc).Resolve (ctx); - var curType = type.GetDefinition (); - while (curType != null) { - var flags = OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates | OutputFlags.IncludeMarkup; - if (curType.DeclaringTypeDefinition == null) - flags |= OutputFlags.UseFullInnerTypeName; - var markup = amb.GetString ((IEntity)curType, flags); - result.Insert (0, new PathEntry (ImageService.GetPixbuf (type.GetStockIcon (), Gtk.IconSize.Menu), curType.IsObsolete () ? "<s>" + markup + "</s>" : markup) { Tag = (object)curType.DeclaringTypeDefinition ?? unit }); - curType = curType.DeclaringTypeDefinition; + var typeDef = unit.GetInnermostTypeDefinition (loc); + IType type = null; + if (typeDef != null) { + type = typeDef.Resolve (ctx); + var curType = type.GetDefinition (); + while (curType != null) { + var flags = OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates | OutputFlags.IncludeMarkup; + if (curType.DeclaringTypeDefinition == null) + flags |= OutputFlags.UseFullInnerTypeName; + var markup = amb.GetString ((IEntity)curType, flags); + result.Insert (0, new PathEntry (ImageService.GetPixbuf (type.GetStockIcon (), Gtk.IconSize.Menu), curType.IsObsolete () ? "<s>" + markup + "</s>" : markup) { Tag = (object)curType.DeclaringTypeDefinition ?? unit }); + curType = curType.DeclaringTypeDefinition; + } } - var member = type != null && type.Kind != TypeKind.Delegate ? unit.GetMember (loc.Line, loc.Column).CreateResolved (ctx) : null; - if (member != null) { + var unresolvedMember = type != null && type.Kind != TypeKind.Delegate ? unit.GetMember (loc.Line, loc.Column) : null; + if (unresolvedMember != null) { + var member = unresolvedMember.CreateResolved (ctx); var markup = amb.GetString (member, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates | OutputFlags.IncludeMarkup); result.Add (new PathEntry (ImageService.GetPixbuf (member.GetStockIcon (), Gtk.IconSize.Menu), member.IsObsolete () ? "<s>" + markup + "</s>" : markup) { Tag = member.DeclaringTypeDefinition }); } @@ -274,7 +278,7 @@ namespace MonoDevelop.CSharp PathEntry noSelection = null; if (type == null) { noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = unit }; - } else if (member == null && type.Kind != TypeKind.Delegate) + } else if (unresolvedMember == null && type.Kind != TypeKind.Delegate) noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = type }; if (noSelection != null) result.Add (noSelection); diff --git a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Text/DocGenerator.cs b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Text/DocGenerator.cs index c89eb2c7fa..7d5a752b09 100644 --- a/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Text/DocGenerator.cs +++ b/main/src/core/MonoDevelop.Core/MonoDevelop.Projects.Text/DocGenerator.cs @@ -39,8 +39,6 @@ namespace MonoDevelop.Projects.Text public abstract string GenerateDocumentation (IMember member, string linePrefix); - public abstract string GenerateDocumentation (IUnresolvedMember member, string linePrefix); - static DocGenerator () { AddinManager.AddExtensionNodeHandler ("/MonoDevelop/ProjectModel/DocumentationGenerator", delegate (object sender, ExtensionNodeEventArgs args) { |