diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 18:33:52 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 18:33:52 +0400 |
commit | 6a71bc1cfc9ba1945d874380276a16c1c64dc476 (patch) | |
tree | 0881a78833c496fc8d52081cc666153b09624310 /main/src | |
parent | 32132381cdc908bccb91df8fa121f1c0bcfb5c6d (diff) |
[CBinding] Track nrefactory API changes.
Diffstat (limited to 'main/src')
-rwxr-xr-x[-rw-r--r--] | main/src/addins/CBinding/Gui/CTextEditorExtension.cs | 8 | ||||
-rwxr-xr-x[-rw-r--r--] | main/src/addins/CBinding/Parser/CDocumentParser.cs | 42 | ||||
-rwxr-xr-x[-rw-r--r--] | main/src/addins/CBinding/Parser/DataProvider.cs | 21 |
3 files changed, 35 insertions, 36 deletions
diff --git a/main/src/addins/CBinding/Gui/CTextEditorExtension.cs b/main/src/addins/CBinding/Gui/CTextEditorExtension.cs index b3a4b098af..bd98a66240 100644..100755 --- a/main/src/addins/CBinding/Gui/CTextEditorExtension.cs +++ b/main/src/addins/CBinding/Gui/CTextEditorExtension.cs @@ -684,12 +684,11 @@ namespace CBinding var result = new List<PathEntry> (); var amb = GetAmbience (); - var ctx = document.TypeResolveContext; var type = unit.GetInnermostTypeDefinition (loc.Line, loc.Column) ?? unit.TopLevelTypeDefinitions.FirstOrDefault (); var curType = type; object lastTag = unit; while (curType != null) { - var markup = amb.GetString (ctx, (IEntity)curType, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates | OutputFlags.IncludeMarkup); + var markup = amb.GetString ((IEntity)curType, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates | OutputFlags.IncludeMarkup); result.Insert (0, new PathEntry (ImageService.GetPixbuf (type.GetStockIcon (), Gtk.IconSize.Menu), curType.IsObsolete () ? "<s>" + markup + "</s>" : markup) { Tag = lastTag }); lastTag = curType; curType = curType.DeclaringTypeDefinition; @@ -697,14 +696,15 @@ namespace CBinding var member = type.Members.FirstOrDefault (m => m.Region.IsInside (loc.Line, loc.Column)); if (member != null) { - var markup = amb.GetString (ctx, member, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates | OutputFlags.IncludeMarkup); + var ctx = Document.ParsedDocument.ParsedFile.GetTypeResolveContext (Document.Compilation, member.Region.Begin);; + var markup = amb.GetString (member.CreateResolved (ctx), 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 = lastTag }); } PathEntry noSelection = null; if (type == null) { noSelection = new PathEntry (GettextCatalog.GetString ("No selection")) { Tag = unit }; - } else if (member == null && !type.IsDelegate ()) + } else if (member == 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/addins/CBinding/Parser/CDocumentParser.cs b/main/src/addins/CBinding/Parser/CDocumentParser.cs index d83c5c9e01..e297d9f502 100644..100755 --- a/main/src/addins/CBinding/Parser/CDocumentParser.cs +++ b/main/src/addins/CBinding/Parser/CDocumentParser.cs @@ -43,24 +43,21 @@ namespace CBinding.Parser /// </summary> public class CDocumentParser: AbstractTypeSystemParser { - public override ParsedDocument Parse (IProjectContent dom, bool storeAst, string fileName, TextReader reader) + public override ParsedDocument Parse (bool storeAst, string fileName, TextReader reader, Project project = null) { var doc = new DefaultParsedDocument (fileName); doc.Flags |= ParsedDocumentFlags.NonSerializable; - Project p = (null == dom || null == dom.GetProject ())? - IdeApp.Workspace.GetProjectContainingFile (fileName): - dom.GetProject (); - ProjectInformation pi = ProjectInformationManager.Instance.Get (p); + ProjectInformation pi = ProjectInformationManager.Instance.Get (project); string content = reader.ReadToEnd (); string[] contentLines = content.Split (new string[]{Environment.NewLine}, StringSplitOptions.None); - var globals = new DefaultTypeDefinition (dom, "", GettextCatalog.GetString ("(Global Scope)")); + var globals = new DefaultUnresolvedTypeDefinition ("", GettextCatalog.GetString ("(Global Scope)")); lock (pi) { // Add containers to type list foreach (LanguageItem li in pi.Containers ()) { if (null == li.Parent && FilePath.Equals (li.File, fileName)) { - var tmp = AddLanguageItem (dom, pi, globals, li, contentLines) as ITypeDefinition; + var tmp = AddLanguageItem (pi, globals, li, contentLines) as IUnresolvedTypeDefinition; if (null != tmp){ doc.TopLevelTypeDefinitions.Add (tmp); } } } @@ -68,13 +65,12 @@ namespace CBinding.Parser // Add global category for unscoped symbols foreach (LanguageItem li in pi.InstanceMembers ()) { if (null == li.Parent && FilePath.Equals (li.File, fileName)) { - AddLanguageItem (dom, pi, globals, li, contentLines); + AddLanguageItem (pi, globals, li, contentLines); } } } doc.TopLevelTypeDefinitions.Add (globals); - Console.WriteLine (doc.TopLevelTypeDefinitions.Count); return doc; } @@ -146,23 +142,23 @@ namespace CBinding.Parser static readonly Regex paramExpression = new Regex (@"(?<type>[^\s]+)\s+(?<subtype>[*&]*)(?<name>[^\s[]+)(?<array>\[.*)?", RegexOptions.Compiled); - static object AddLanguageItem (IProjectContent dom, ProjectInformation pi, DefaultTypeDefinition klass, LanguageItem li, string[] contentLines) + static object AddLanguageItem (ProjectInformation pi, DefaultUnresolvedTypeDefinition klass, LanguageItem li, string[] contentLines) { if (li is Class || li is Structure || li is Enumeration) { - var type = LanguageItemToIType (dom, pi, li, contentLines); + var type = LanguageItemToIType (pi, li, contentLines); klass.NestedTypes.Add (type); return type; } if (li is Function) { var method = FunctionToIMethod (pi, klass, (Function)li, contentLines); - klass.Methods.Add (method); + klass.Members.Add (method); return method; } var field = LanguageItemToIField (klass, li, contentLines); - klass.Fields.Add (field); + klass.Members.Add (field); return field; } @@ -179,15 +175,15 @@ namespace CBinding.Parser /// <param name="contentLines"> /// A <see cref="System.String[]"/>: The document in which item is defined. /// </param> - static DefaultTypeDefinition LanguageItemToIType (IProjectContent content, ProjectInformation pi, LanguageItem item, string[] contentLines) + static DefaultUnresolvedTypeDefinition LanguageItemToIType (ProjectInformation pi, LanguageItem item, string[] contentLines) { - var klass = new DefaultTypeDefinition (content, "", item.File); + var klass = new DefaultUnresolvedTypeDefinition ("", item.File); if (item is Class || item is Structure) { klass.Region = new DomRegion ((int)item.Line, 1, FindFunctionEnd (contentLines, (int)item.Line-1) + 2, 1); klass.Kind = item is Class ? TypeKind.Class : TypeKind.Struct; foreach (LanguageItem li in pi.AllItems ()) { if (klass.Equals (li.Parent) && FilePath.Equals (li.File, item.File)) - AddLanguageItem (content, pi, klass, li, contentLines); + AddLanguageItem (pi, klass, li, contentLines); } return klass; } @@ -197,29 +193,29 @@ namespace CBinding.Parser return klass; } - static IField LanguageItemToIField (ITypeDefinition type, LanguageItem item, string[] contentLines) + static IUnresolvedField LanguageItemToIField (IUnresolvedTypeDefinition type, LanguageItem item, string[] contentLines) { - var result = new DefaultField (type, item.Name); + var result = new DefaultUnresolvedField (type, item.Name); result.Region = new DomRegion ((int)item.Line, 1, (int)item.Line + 1, 1); return result; } - static IMethod FunctionToIMethod (ProjectInformation pi, ITypeDefinition type, Function function, string[] contentLines) + static IUnresolvedMethod FunctionToIMethod (ProjectInformation pi, IUnresolvedTypeDefinition type, Function function, string[] contentLines) { - var method = new DefaultMethod (type, function.Name); + var method = new DefaultUnresolvedMethod (type, function.Name); method.Region = new DomRegion ((int)function.Line, 1, FindFunctionEnd (contentLines, (int)function.Line-1)+2, 1); Match match; bool abort = false; - var parameters = new List<IParameter> (); + var parameters = new List<IUnresolvedParameter> (); foreach (string parameter in function.Parameters) { match = paramExpression.Match (parameter); if (null == match) { abort = true; break; } - var typeRef = new GetClassTypeReference (string.Format ("{0}{1}{2}", match.Groups["type"].Value, match.Groups["subtype"].Value, match.Groups["array"].Value), 0); - var p = new DefaultParameter (typeRef, match.Groups["name"].Value); + var typeRef = new DefaultUnresolvedTypeDefinition (string.Format ("{0}{1}{2}", match.Groups["type"].Value, match.Groups["subtype"].Value, match.Groups["array"].Value)); + var p = new DefaultUnresolvedParameter (typeRef, match.Groups["name"].Value); parameters.Add (p); } if (!abort) diff --git a/main/src/addins/CBinding/Parser/DataProvider.cs b/main/src/addins/CBinding/Parser/DataProvider.cs index 995858b5f9..b5e5025388 100644..100755 --- a/main/src/addins/CBinding/Parser/DataProvider.cs +++ b/main/src/addins/CBinding/Parser/DataProvider.cs @@ -47,8 +47,7 @@ namespace CBinding.Parser { object tag; Ambience amb; - ITypeResolveContext ctx; - List<IEntity> memberList = new List<IEntity> (); + List<IUnresolvedEntity> memberList = new List<IUnresolvedEntity> (); Document Document { get; @@ -58,7 +57,6 @@ namespace CBinding.Parser public DataProvider (Document doc, object tag, Ambience amb) { this.Document = doc; - this.ctx = doc.TypeResolveContext; this.tag = tag; this.amb = amb; Reset (); @@ -69,24 +67,29 @@ namespace CBinding.Parser { memberList.Clear (); if (tag is IParsedFile) { - var types = new Stack<ITypeDefinition> (((IParsedFile)tag).TopLevelTypeDefinitions); + var types = new Stack<IUnresolvedTypeDefinition> (((IParsedFile)tag).TopLevelTypeDefinitions); while (types.Count > 0) { var type = types.Pop (); memberList.Add (type); foreach (var innerType in type.NestedTypes) types.Push (innerType); } - } else if (tag is ITypeDefinition) { - memberList.AddRange (((ITypeDefinition)tag).Members); + } else if (tag is IUnresolvedTypeDefinition) { + memberList.AddRange (((IUnresolvedTypeDefinition)tag).Members); } memberList.Sort ((x, y) => String.Compare (GetString (amb, x), GetString (amb, y), StringComparison.OrdinalIgnoreCase)); } - string GetString (Ambience amb, IEntity x) + string GetString (Ambience amb, IUnresolvedEntity x) { + var ctx = Document.ParsedDocument.ParsedFile.GetTypeResolveContext (Document.Compilation, x.Region.Begin); + IEntity rx = null; + if (x is IUnresolvedMember) + rx = ((IUnresolvedMember)x).CreateResolved (ctx); + if (tag is IParsedFile) - return amb.GetString (ctx, x, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.UseFullInnerTypeName | OutputFlags.ReformatDelegates); - return amb.GetString (ctx, x, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates); + return amb.GetString (rx, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.UseFullInnerTypeName | OutputFlags.ReformatDelegates); + return amb.GetString (rx, OutputFlags.IncludeGenerics | OutputFlags.IncludeParameters | OutputFlags.ReformatDelegates); } public string GetMarkup (int n) |