diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-12-01 18:40:11 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-12-01 18:40:11 +0400 |
commit | b4d5199daf6492f88d350e1701c750752120b838 (patch) | |
tree | 7e2f38acedbd2eea90f77743511bedeac78dbe02 /main/src | |
parent | e671ab729696d6b66baa6bffad8ca01e8596bd45 (diff) |
[Moonlight] Track API changes.
Diffstat (limited to 'main/src')
3 files changed, 47 insertions, 51 deletions
diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanelWidget.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanelWidget.cs index 9f866a585e..155afdb78e 100644 --- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanelWidget.cs +++ b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight.Gui/MoonlightOptionsPanelWidget.cs @@ -94,11 +94,11 @@ namespace MonoDevelop.Moonlight.Gui return; classesFilled = true; try { - var dom = TypeSystemService.GetContext (project); - IType appType = dom.GetTypeDefinition ("System.Windows", "Application", 0, StringComparer.Ordinal); + var dom = TypeSystemService.GetCompilation (project); + IType appType = dom.FindType ("System.Windows.Application"); if (appType == null) return; - foreach (IType type in appType.GetAllBaseTypes (dom)) + foreach (IType type in appType.GetAllBaseTypes ()) classListStore.AppendValues (type.FullName); } catch (InvalidOperationException) { // Project not found in parser database diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightEditorExtension.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightEditorExtension.cs index 2d7dd173ae..7b0b7b1861 100644 --- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightEditorExtension.cs +++ b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightEditorExtension.cs @@ -54,34 +54,20 @@ namespace MonoDevelop.Moonlight // "System.Windows", GetProjectTargetFramework (project))); // } - public static IEnumerable<IType> ListControlClasses (ITypeResolveContext database, string namespac) + public static IEnumerable<IType> ListControlClasses (ICompilation database, INamespace namespac) { if (database == null) yield break; - var swd = database.GetTypeDefinition ("System.Windows", "DependencyObject", 0, StringComparer.Ordinal); + var swd = database.FindType ("System.Windows.DependencyObject"); //return classes if they derive from system.web.ui.control - foreach (IType cls in database.GetTypes (namespac, StringComparer.Ordinal)) { - if (cls != null && !cls.GetDefinition ().IsAbstract && cls.GetDefinition ().IsPublic && cls.IsBaseType (database, swd)) + foreach (var cls in namespac.Types) { + if (cls != null && !cls.IsAbstract && cls.IsPublic && cls.IsBaseType (swd)) yield return cls; } } - static IEnumerable<IProperty> GetAllProperties ( - ITypeResolveContext projectDatabase, - IType cls) - { - return cls.GetProperties (projectDatabase); - } - - static IEnumerable<IEvent> GetAllEvents ( - ITypeResolveContext projectDatabase, - IType cls) - { - return cls.GetEvents (projectDatabase); - } - static IEnumerable<T> GetUniqueMembers<T> (IEnumerable<T> members) where T : IMember { Dictionary <string, bool> existingItems = new Dictionary<string,bool> (); @@ -93,35 +79,35 @@ namespace MonoDevelop.Moonlight } } - static void AddControlMembers (CompletionDataList list, ITypeResolveContext database, IType controlClass, + static void AddControlMembers (CompletionDataList list, IType controlClass, Dictionary<string, string> existingAtts) { //add atts only if they're not already in the tag - foreach (IProperty prop in GetUniqueMembers<IProperty> (GetAllProperties (database, controlClass))) + foreach (IProperty prop in GetUniqueMembers<IProperty> (controlClass.GetProperties ())) if (prop.IsPublic && (existingAtts == null || !existingAtts.ContainsKey (prop.Name))) list.Add (prop.Name, prop.GetStockIcon (), prop.Documentation); //similarly add events foreach (var eve - in GetUniqueMembers<IEvent> (GetAllEvents (database, controlClass))) { + in GetUniqueMembers<IEvent> (controlClass.GetEvents ())) { string eveName = eve.Name; if (eve.IsPublic && (existingAtts == null || !existingAtts.ContainsKey (eveName))) list.Add (eveName, eve.GetStockIcon (), eve.Documentation); } } - ITypeResolveContext GetDb () + ICompilation GetDb () { - return Document.TypeResolveContext; + return Document.Compilation; } - void GetType (IAttributedXObject attributedOb, Action<IType, ITypeResolveContext> action) + void GetType (IAttributedXObject attributedOb, Action<IType, ICompilation> action) { - ITypeResolveContext database = GetDb (); + var database = GetDb (); if (database == null) return; foreach (string namespc in namespaces) { - IType controlType = database.GetTypeDefinition (namespc, attributedOb.Name.Name, 0, StringComparer.Ordinal); + var controlType = database.MainAssembly.GetTypeDefinition (namespc, attributedOb.Name.Name, 0); if (controlType != null) { action (controlType, database); break; @@ -135,17 +121,22 @@ namespace MonoDevelop.Moonlight protected override void GetElementCompletions(CompletionDataList list) { base.GetElementCompletions (list); - ITypeResolveContext database = GetDb (); + var database = GetDb (); if (database == null) return; - IType type = database.GetTypeDefinition ("System.Windows", "DependencyObject", 0, StringComparer.Ordinal); + IType type = database.FindType ("System.Windows.DependencyObject"); if (type == null) return; - foreach (string namespc in namespaces) - foreach (IType t in ListControlClasses (database, namespc)) + foreach (string namespc in namespaces) { + INamespace ns = database.RootNamespace; + foreach (var sn in namespc.Split ('.')) { + ns = ns.GetChildNamespace (sn); + } + foreach (IType t in ListControlClasses (database, ns)) list.Add (t.Name, Gtk.Stock.GoForward, t.GetDocumentation ()); + } } // static MonoDevelop.Core.TargetFramework GetProjectTargetFramework (MoonlightProject project) @@ -160,8 +151,8 @@ namespace MonoDevelop.Moonlight if (!existingAtts.ContainsKey ("x:Name")) list.Add ("x:Name"); - GetType (attributedOb, delegate (IType type, ITypeResolveContext dom) { - AddControlMembers (list, dom, type, existingAtts); + GetType (attributedOb, delegate (IType type, ICompilation dom) { + AddControlMembers (list, type, existingAtts); }); return list.Count > 0? list : null; } @@ -169,21 +160,21 @@ namespace MonoDevelop.Moonlight protected override CompletionDataList GetAttributeValueCompletions (IAttributedXObject attributedOb, XAttribute att) { var list = base.GetAttributeValueCompletions (attributedOb, att) ?? new CompletionDataList (); - ITypeResolveContext ctx = document.TypeResolveContext; - GetType (attributedOb, delegate (IType type, ITypeResolveContext dom) { - foreach (IProperty prop in GetAllProperties (dom, type)) { + var ctx = document.Compilation; + GetType (attributedOb, delegate (IType type, ICompilation dom) { + foreach (IProperty prop in type.GetProperties ()) { if (prop.Name != att.Name.FullName) continue; //boolean completion - if (prop.ReturnType.Resolve (ctx).Equals (ctx.GetTypeDefinition (typeof (bool)))) { + if (prop.ReturnType.Equals (ctx.FindType (typeof (bool)))) { list.Add ("true", "md-literal"); list.Add ("false", "md-literal"); return; } //color completion - if (prop.ReturnType.Resolve (ctx).ReflectionName == "System.Windows.Media.Color") { + if (prop.ReturnType.ReflectionName == "System.Windows.Media.Color") { System.Drawing.ColorConverter conv = new System.Drawing.ColorConverter (); foreach (System.Drawing.Color c in conv.GetStandardValues (null)) { if (c.IsSystemColor) @@ -195,9 +186,9 @@ namespace MonoDevelop.Moonlight } //enum completion - var retCls = prop.ReturnType.Resolve (ctx); - if (retCls != null && retCls.IsEnum ()) { - foreach (var enumVal in retCls.GetFields (ctx)) + var retCls = prop.ReturnType; + if (retCls != null && retCls.Kind == TypeKind.Enum) { + foreach (var enumVal in retCls.GetFields ()) if (enumVal.IsPublic && enumVal.IsStatic) list.Add (enumVal.Name, "md-literal", enumVal.Documentation); return; diff --git a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightParser.cs b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightParser.cs index 85d11460bd..696fbdaef9 100644 --- a/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightParser.cs +++ b/main/src/addins/MonoDevelop.Moonlight/MonoDevelop.Moonlight/MoonlightParser.cs @@ -36,12 +36,13 @@ using MonoDevelop.Xml.StateEngine; using MonoDevelop.TypeSystem; using ICSharpCode.NRefactory.TypeSystem; using ICSharpCode.NRefactory.TypeSystem.Implementation; +using MonoDevelop.Projects; namespace MonoDevelop.Moonlight { public class MoonlightParser : AbstractTypeSystemParser { - public override ParsedDocument Parse (IProjectContent projectContent, bool storeAst, string fileName, TextReader tr) + public override ParsedDocument Parse (bool storeAst, string fileName, TextReader tr, Project project = null) { XmlParsedDocument doc = new XmlParsedDocument (fileName); try { @@ -53,7 +54,7 @@ namespace MonoDevelop.Moonlight if (doc.XDocument != null && doc.XDocument.RootElement != null) { if (!doc.XDocument.RootElement.IsEnded) doc.XDocument.RootElement.End (xmlParser.Location); - GenerateCU (projectContent, doc); + GenerateCU (doc); } } catch (Exception ex) { @@ -62,7 +63,7 @@ namespace MonoDevelop.Moonlight return doc; } - static void GenerateCU (IProjectContent projectContent, XmlParsedDocument doc) + static void GenerateCU (XmlParsedDocument doc) { if (doc.XDocument == null || doc.XDocument.RootElement == null) { doc.Add (new Error (ErrorType.Error, "No root node found.", 1, 1)); @@ -86,20 +87,20 @@ namespace MonoDevelop.Moonlight if (doc.XDocument.RootElement.IsClosed) rootRegion = new DomRegion (doc.XDocument.RootElement.Region.FileName, doc.XDocument.RootElement.Region.Begin, doc.XDocument.RootElement.ClosingTag.Region.End); - var declType = new DefaultTypeDefinition (projectContent, rootNamespace, rootType) { + var declType = new DefaultUnresolvedTypeDefinition (rootNamespace, rootType) { Kind = TypeKind.Class, Accessibility = Accessibility.Public, Region = rootRegion }; cu.TopLevelTypeDefinitions.Add (declType); - var initcomp = new DefaultMethod (declType, "InitializeComponent") { + var initcomp = new DefaultUnresolvedMethod (declType, "InitializeComponent") { ReturnType = KnownTypeReference.Void, Accessibility = Accessibility.Public }; - declType.Methods.Add (initcomp); + declType.Members.Add (initcomp); - var _contentLoaded = new DefaultField (declType, "_contentLoaded") { + var _contentLoaded = new DefaultUnresolvedField (declType, "_contentLoaded") { ReturnType = KnownTypeReference.Boolean }; // was missing in the original code: correct ? @@ -130,7 +131,11 @@ namespace MonoDevelop.Moonlight if (type == null || type.Length == 0) cu.Add (new Error (ErrorType.Error, "Could not find namespace for '" + el.Name.FullName + "'.", el.Region.Begin)); else - declType.Fields.Add (new DefaultField (declType, name.Value) { Accessibility = Accessibility.Internal, Region = el.Region, ReturnType = new GetClassTypeReference (type, 0) }); + declType.Members.Add (new DefaultUnresolvedField (declType, name.Value) { + Accessibility = Accessibility.Internal, + Region = el.Region, + ReturnType = new DefaultUnresolvedTypeDefinition (type) + }); } } } |