diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 12:48:15 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 12:48:15 +0400 |
commit | 6694ff12a73edab02a7a805435f06d8e3a3025b5 (patch) | |
tree | 74e65e5d5c7e47d93b0e2cd54d34add25d9d65d5 /main/src | |
parent | ee2d0b4c759506548fe27cbad776c8add326e23c (diff) |
[DocFood] Track API changes.
Diffstat (limited to 'main/src')
3 files changed, 40 insertions, 32 deletions
diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs index b6bd6b7c3b..33b65a45f7 100644 --- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs +++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/Commands.cs @@ -30,6 +30,7 @@ using System.Collections.Generic; using System.Text; using Mono.TextEditor; using ICSharpCode.NRefactory.TypeSystem; +using ICSharpCode.NRefactory.CSharp.TypeSystem; namespace MonoDevelop.DocFood { @@ -73,24 +74,26 @@ namespace MonoDevelop.DocFood if (unit == null) return; TextEditorData data = IdeApp.Workbench.ActiveDocument.Editor; - var types = new Stack<ITypeDefinition> (unit.TopLevelTypeDefinitions); + var types = new Stack<IUnresolvedTypeDefinition> (unit.TopLevelTypeDefinitions); var docs = new List<KeyValuePair<int, string>> (); while (types.Count > 0) { - ITypeDefinition curType = types.Pop (); + var curType = types.Pop (); foreach (var member in curType.Members) { - if (member is ITypeDefinition) { - types.Push ((ITypeDefinition)member); + if (member is IUnresolvedTypeDefinition) { + types.Push ((IUnresolvedTypeDefinition)member); continue; } if (!member.IsPublic) { - if (member.DeclaringType != null && member.DeclaringType.GetDefinition ().Kind != TypeKind.Interface) + if (member.DeclaringTypeDefinition != null && member.DeclaringTypeDefinition.Kind != TypeKind.Interface) continue; } if (!NeedsDocumentation (data, member)) continue; int offset; - string indent = GetIndent (data, member, out offset); - string documentation = GenerateDocumentation (document.TypeResolveContext, data, member, indent); + var ctx = (unit.ParsedFile as CSharpParsedFile).GetTypeResolveContext (document.Compilation, member.Region.Begin); + var resolvedMember = member.CreateResolved (ctx); + string indent = GetIndent (data, resolvedMember, out offset); + string documentation = GenerateDocumentation (data, resolvedMember, indent); if (documentation.Trim ().Length == 0) continue; docs.Add (new KeyValuePair <int, string> (offset, documentation)); @@ -102,7 +105,7 @@ namespace MonoDevelop.DocFood } } - static bool NeedsDocumentation (TextEditorData data, IEntity member) + static bool NeedsDocumentation (TextEditorData data, IUnresolvedEntity member) { int lineNr = member.Region.BeginLine; LineSegment line; @@ -122,17 +125,17 @@ namespace MonoDevelop.DocFood return data.Document.GetLineIndent (line); } - internal static string GenerateDocumentation (ITypeResolveContext ctx, TextEditorData data, IEntity member, string indent) + internal static string GenerateDocumentation (TextEditorData data, IEntity member, string indent) { - return GenerateDocumentation (ctx, data, member, indent, "/// "); + return GenerateDocumentation (data, member, indent, "/// "); } - internal static string GenerateDocumentation (ITypeResolveContext ctx, TextEditorData data, IEntity member, string indent, string prefix) + internal static string GenerateDocumentation (TextEditorData data, IEntity member, string indent, string prefix) { StringBuilder result = new StringBuilder (); DocGenerator generator = new DocGenerator (data); - generator.GenerateDoc (ctx, member); + generator.GenerateDoc (member); bool first = true; foreach (Section section in generator.sections) { @@ -195,12 +198,12 @@ namespace MonoDevelop.DocFood return result.ToString (); } - internal static string GenerateEmptyDocumentation (ITypeResolveContext ctx, TextEditorData data, IEntity member, string indent) + internal static string GenerateEmptyDocumentation (TextEditorData data, IEntity member, string indent) { StringBuilder result = new StringBuilder (); DocGenerator generator = new DocGenerator (data); - generator.GenerateDoc (ctx, member); + generator.GenerateDoc (member); bool first = true; foreach (Section section in generator.sections) { diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs index c80c451e95..9daec736c2 100644 --- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs +++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocFoodTextEditorExtension.cs @@ -32,6 +32,7 @@ using ICSharpCode.NRefactory.TypeSystem; using MonoDevelop.TypeSystem; using ICSharpCode.NRefactory.CSharp; using ICSharpCode.NRefactory; +using ICSharpCode.NRefactory.CSharp.TypeSystem; namespace MonoDevelop.DocFood { @@ -45,16 +46,16 @@ namespace MonoDevelop.DocFood textEditorData = Document.Editor; } - string GenerateDocumentation (ITypeResolveContext ctx, IEntity member, string indent) + string GenerateDocumentation (IEntity member, string indent) { - string doc = DocumentBufferHandler.GenerateDocumentation (ctx, textEditorData, member, indent); + string doc = DocumentBufferHandler.GenerateDocumentation (textEditorData, member, indent); int trimStart = (Math.Min (doc.Length-1, indent.Length + "//".Length)); return doc.Substring (trimStart).TrimEnd ('\n', '\r'); } - string GenerateEmptyDocumentation (ITypeResolveContext ctx, IEntity member, string indent) + string GenerateEmptyDocumentation (IEntity member, string indent) { - string doc = DocumentBufferHandler.GenerateEmptyDocumentation (ctx, textEditorData, member, indent); + string doc = DocumentBufferHandler.GenerateEmptyDocumentation (textEditorData, member, indent); int trimStart = (Math.Min (doc.Length-1, indent.Length + "//".Length)); return doc.Substring (trimStart).TrimEnd ('\n', '\r'); } @@ -74,11 +75,11 @@ namespace MonoDevelop.DocFood if (member == null) return base.KeyPress (key, keyChar, modifier); var ctx = document.TypeResolveContext; - string documentation = GenerateDocumentation (ctx, member, textEditorData.Document.GetLineIndent (line)); + string documentation = GenerateDocumentation (member, textEditorData.Document.GetLineIndent (line)); if (string.IsNullOrEmpty (documentation)) return base.KeyPress (key, keyChar, modifier); - string documentationEmpty = GenerateEmptyDocumentation (ctx, member, textEditorData.Document.GetLineIndent (line)); + string documentationEmpty = GenerateEmptyDocumentation (member, textEditorData.Document.GetLineIndent (line)); int offset = textEditorData.Caret.Offset; @@ -108,11 +109,14 @@ namespace MonoDevelop.DocFood IEntity GetMemberToDocument () { var parsedDocument = Document.UpdateParseDocument (); + var type = parsedDocument.GetInnermostTypeDefinition (textEditorData.Caret.Line, textEditorData.Caret.Column); if (type == null) { foreach (var t in parsedDocument.TopLevelTypeDefinitions) { - if (t.Region.BeginLine > textEditorData.Caret.Line) - return t; + if (t.Region.BeginLine > textEditorData.Caret.Line) { + var ctx = (parsedDocument.ParsedFile as CSharpParsedFile).GetTypeResolveContext (Document.Compilation, t.Region.Begin); + return t.Resolve (ctx).GetDefinition (); + } } return null; } @@ -120,7 +124,8 @@ namespace MonoDevelop.DocFood IMember result = null; foreach (var member in type.Members) { if (member.Region.Begin > new TextLocation (textEditorData.Caret.Line, textEditorData.Caret.Column) && (result == null || member.Region.Begin < result.Region.Begin) && IsEmptyBetweenLines (textEditorData.Caret.Line, member.Region.BeginLine)) { - result = member; + var ctx = (parsedDocument.ParsedFile as CSharpParsedFile).GetTypeResolveContext (Document.Compilation, member.Region.Begin); + result = member.CreateResolved (ctx); } } return result; diff --git a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs index 65566ec329..33fe38476d 100644 --- a/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs +++ b/main/src/addins/MonoDevelop.DocFood/MonoDevelop.DocFood/DocGenerator.cs @@ -52,13 +52,13 @@ namespace MonoDevelop.DocFood this.data = data; } - public static string GetBaseDocumentation (ITypeResolveContext ctx, IEntity member) + public static string GetBaseDocumentation (IEntity member) { if (member.DeclaringTypeDefinition == null) return null; if (member is IMethod && (((IMethod)member).IsConstructor || ((IMethod)member).IsDestructor)) return null; - foreach (var type in member.DeclaringTypeDefinition.GetAllBaseTypeDefinitions (ctx)) { + foreach (var type in member.DeclaringTypeDefinition.GetAllBaseTypeDefinitions ()) { if (type.Equals (member.DeclaringTypeDefinition)) continue; IMember documentMember = null; @@ -122,7 +122,7 @@ namespace MonoDevelop.DocFood } } - public IEntity member; + public INamedElement member; MemberVisitor visitor = new MemberVisitor (); string currentType; int wordCount; @@ -302,9 +302,9 @@ namespace MonoDevelop.DocFood } internal string curName; - public void GenerateDoc (ITypeResolveContext ctx, IEntity member) + public void GenerateDoc (IEntity member) { - Init (ctx, member); + Init (member); this.member = member; this.currentType = GetType (member); @@ -381,9 +381,9 @@ namespace MonoDevelop.DocFood // } } - void Init (ITypeResolveContext ctx, IEntity member) + void Init (IEntity member) { - FillDocumentation (GetBaseDocumentation (ctx, member)); + FillDocumentation (GetBaseDocumentation (member)); // if (provider != null && !member.Location.IsEmpty && member.BodyRegion.EndLine > 1) { // LineSegment start = data.Document.GetLine (member.Region.BeginLine); // LineSegment end = data.Document.GetLine (member.BodyRegion.EndLine); @@ -556,9 +556,9 @@ namespace MonoDevelop.DocFood } #region implemented abstract members of MonoDevelop.Projects.Text.DocGenerator - public override string GenerateDocumentation (ITypeResolveContext ctx, IMember member, string linePrefix) + public override string GenerateDocumentation (IMember member, string linePrefix) { - return DocumentBufferHandler.GenerateDocumentation (ctx, null, member, "", linePrefix); + return DocumentBufferHandler.GenerateDocumentation (null, member, "", linePrefix); } #endregion } |