diff options
author | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 14:09:36 +0400 |
---|---|---|
committer | Mike Krüger <mkrueger@xamarin.com> | 2011-12-02 14:09:36 +0400 |
commit | 5fbb8ebf78f8b5bb9962e600af2c3e2ac027bfaa (patch) | |
tree | c48e1f795c68d2d4de169748a70503d4754532b5 /main/src | |
parent | 9f9cdee250d3a8e7e9b66488586c48011fa506ce (diff) |
[Stetic] Track nrefactory api changes.
Diffstat (limited to 'main/src')
14 files changed, 103 insertions, 109 deletions
diff --git a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/VerifyCodeBehindBuildStep.cs b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/VerifyCodeBehindBuildStep.cs index 8e0209a03d..45e278c3eb 100644 --- a/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/VerifyCodeBehindBuildStep.cs +++ b/main/src/addins/AspNet/MonoDevelop.AspNet/MonoDevelop.AspNet/VerifyCodeBehindBuildStep.cs @@ -109,8 +109,8 @@ namespace MonoDevelop.AspNet if (!updatedParseDb) { updatedParseDb = true; monitor.Log.Write (GettextCatalog.GetString ("Waiting for project type database to finish updating...")); - var dom = TypeSystemService.GetContext (aspProject); - TypeSystemService.ForceUpdate (dom); + //var dom = TypeSystemService.GetContext (aspProject); + //TypeSystemService.ForceUpdate (dom); monitor.Log.WriteLine (GettextCatalog.GetString (" complete.")); } diff --git a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs index 8507ab30a0..7c0d206310 100644 --- a/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs +++ b/main/src/addins/CSharpBinding/MonoDevelop.CSharp.Completion/CSharpCompletionTextEditorExtension.cs @@ -175,7 +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.ctx = CSharpParsedFile.GetTypeResolveContext (Document.Compilation, document.Editor.Caret.Location) as CSharpTypeResolveContext; engine.Unit = Unit; engine.CSharpParsedFile = CSharpParsedFile; engine.FormattingPolicy = FormattingPolicy.CreateOptions (); @@ -317,7 +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.ctx = CSharpParsedFile.GetTypeResolveContext (Document.Compilation, document.Editor.Caret.Location) as CSharpTypeResolveContext; engine.Unit = Unit; engine.CSharpParsedFile = CSharpParsedFile; engine.ProjectContent = Document.GetProjectContext (); diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs index a6445e80f1..c1f9b176c8 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ActionGroupDisplayBinding.cs @@ -105,8 +105,8 @@ namespace MonoDevelop.GtkCore.GuiBuilder ArrayList list = new ArrayList (); var ctx = gproject.GetParserContext (); - foreach (var cls in ctx.GetTypes ()) - if (IsValidClass (ctx, cls)) + foreach (var cls in ctx.MainAssembly.GetAllTypeDefinitions ()) + if (IsValidClass (cls)) list.Add (cls.FullName); // Ask what to do @@ -124,7 +124,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder return gproject.GetSourceCodeFile (group); } - static ITypeDefinition CreateClass (Project project, Stetic.ActionGroupComponent group, string name, string namspace, string folder) + static IUnresolvedTypeDefinition CreateClass (Project project, Stetic.ActionGroupComponent group, string name, string namspace, string folder) { string fullName = namspace.Length > 0 ? namspace + "." + name : name; @@ -169,14 +169,14 @@ namespace MonoDevelop.GtkCore.GuiBuilder return CodeGenerationService.AddType ((DotNetProject)project, folder, namspace, type); } - internal static bool IsValidClass (ITypeResolveContext ctx, IType cls) + internal static bool IsValidClass (IType cls) { - foreach (var bt in cls.GetBaseTypes (ctx)) { + foreach (var bt in cls.GetAllBaseTypeDefinitions ()) { if (bt.ReflectionName == "Gtk.ActionGroup") return true; var baseCls = bt; - if (baseCls != null && IsValidClass (ctx, baseCls)) + if (baseCls != null && IsValidClass (baseCls)) return true; } return false; diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ClassUtils.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ClassUtils.cs index 408d6f150a..15ad4bc0ca 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ClassUtils.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/ClassUtils.cs @@ -37,21 +37,21 @@ namespace MonoDevelop.GtkCore.GuiBuilder { internal class ClassUtils { - public static IField FindWidgetField (ITypeResolveContext ctx, ITypeDefinition cls, string name) + public static IField FindWidgetField (ITypeDefinition cls, string name) { foreach (IField field in cls.Fields) { - if (name == GetWidgetFieldName (ctx, field)) + if (name == GetWidgetFieldName (field)) return field; } return null; } - public static string GetWidgetFieldName (ITypeResolveContext ctx, IField field) + public static string GetWidgetFieldName (IField field) { foreach (IAttribute att in field.Attributes) { - var type = att.AttributeType.Resolve (ctx); + var type = att.AttributeType; if (type.ReflectionName == "Glade.Widget" || type.ReflectionName == "Widget" || type.ReflectionName == "Glade.WidgetAttribute" || type.ReflectionName == "WidgetAttribute") { - var pArgs = att.GetPositionalArguments (ctx); + var pArgs = att.PositionalArguments; if (pArgs != null && pArgs.Count > 0) { var exp = pArgs[0] as ConstantResolveResult; if (exp != null) diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs index 81faeefaf5..642d72af99 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/CodeBinder.cs @@ -42,7 +42,6 @@ using MonoDevelop.TypeSystem; using MonoDevelop.Ide.FindInFiles; using ICSharpCode.NRefactory.TypeSystem.Implementation; - namespace MonoDevelop.GtkCore.GuiBuilder { /// This class provides several methods for managing the relation @@ -103,7 +102,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder } } - void UpdateBindings (Stetic.Component obj, ITypeDefinition cls) + void UpdateBindings (Stetic.Component obj, IUnresolvedTypeDefinition cls) { if (targetObject == null) return; @@ -114,9 +113,9 @@ namespace MonoDevelop.GtkCore.GuiBuilder if (objectSignals != null) { Stetic.Signal[] signals = new Stetic.Signal [objectSignals.Count]; objectSignals.CopyTo (signals, 0); - + var resolved = cls.Resolve (project); foreach (Stetic.Signal signal in signals) { - if (FindSignalHandler (cls, signal) == null) { + if (FindSignalHandler (resolved, signal) == null) { obj.RemoveSignal (signal); } } @@ -128,9 +127,9 @@ namespace MonoDevelop.GtkCore.GuiBuilder UpdateBindings (ob, cls); } - IMethod FindSignalHandler (ITypeDefinition cls, Stetic.Signal signal) + IMethod FindSignalHandler (IType cls, Stetic.Signal signal) { - foreach (var met in cls.Methods) { + foreach (var met in cls.GetMethods ()) { if (met.Name == signal.Handler) { return met; } @@ -146,16 +145,16 @@ namespace MonoDevelop.GtkCore.GuiBuilder if (obj == targetObject) return; // The root widget name can only be changed internally. - ITypeDefinition cls = GetClass (false); + var cls = GetClass (false); string newName = GetObjectName (obj); if (newName.Length == 0) return; if (cls != null) { - var f = ClassUtils.FindWidgetField (cls.GetProjectContent (), cls, oldName); + var f = ClassUtils.FindWidgetField (cls.Resolve (project).GetDefinition (), oldName); if (f != null) { - MonoDevelop.Refactoring.Rename.RenameRefactoring.Rename (TypeSystemService.GetContext (project), f, newName); + MonoDevelop.Refactoring.Rename.RenameRefactoring.Rename (f, newName); } } } @@ -170,16 +169,16 @@ namespace MonoDevelop.GtkCore.GuiBuilder if (cls == null) return; - if (FindSignalHandler (cls, signal) != null) + if (FindSignalHandler (cls.Resolve (project), signal) != null) return; - var met = new DefaultMethod (cls, signal.Handler) { + var met = new DefaultUnresolvedMethod (cls, signal.Handler) { Accessibility = Accessibility.Protected, - ReturnType = new GetClassTypeReference (signal.SignalDescriptor.HandlerReturnTypeName) + ReturnType = new DefaultUnresolvedTypeDefinition (signal.SignalDescriptor.HandlerReturnTypeName) }; foreach (Stetic.ParameterDescriptor pinfo in signal.SignalDescriptor.HandlerParameters) - met.Parameters.Add (new DefaultParameter (new GetClassTypeReference (pinfo.TypeName), pinfo.Name)); - CodeGenerationService.AddNewMember (TypeSystemService.GetContext (project), cls, met); + met.Parameters.Add (new DefaultUnresolvedParameter (new DefaultUnresolvedTypeDefinition (pinfo.TypeName), pinfo.Name)); + CodeGenerationService.AddNewMember (cls, met); } public void UpdateSignal (Stetic.Signal oldSignal, Stetic.Signal newSignal) @@ -193,11 +192,10 @@ namespace MonoDevelop.GtkCore.GuiBuilder var cls = GetClass (); if (cls == null) return; - - IMethod met = FindSignalHandler (cls, oldSignal); + IMethod met = FindSignalHandler (cls.Resolve (project), oldSignal); if (met == null) return; - MonoDevelop.Refactoring.Rename.RenameRefactoring.Rename (TypeSystemService.GetContext (project), met, newSignal.Handler); + MonoDevelop.Refactoring.Rename.RenameRefactoring.Rename (met, newSignal.Handler); } /// Adds a field to the class @@ -209,39 +207,39 @@ namespace MonoDevelop.GtkCore.GuiBuilder string name = GetMemberName (obj); var cls = GetClass (); - if (FindField (cls, name) != null) + if (FindField (cls.Resolve (project), name) != null) return; Document doc = IdeApp.Workbench.OpenDocument (cls.Region.FileName, true); IEditableTextFile editor = doc.GetContent<IEditableTextFile> (); if (editor != null) { - CodeGenerationService.AddNewMember (TypeSystemService.GetContext (project), cls, GetFieldCode (cls, obj, name)); + CodeGenerationService.AddNewMember (cls, GetFieldCode (cls, obj, name)); } } - DefaultField GetFieldCode (ITypeDefinition cls, Stetic.Component obj, string name) + IUnresolvedField GetFieldCode (IUnresolvedTypeDefinition cls, Stetic.Component obj, string name) { - return new DefaultField (cls, name) { - ReturnType = new GetClassTypeReference (obj.Type.ClassName), + return new DefaultUnresolvedField (cls, name) { + ReturnType = new DefaultUnresolvedTypeDefinition (obj.Type.ClassName), Accessibility = Accessibility.Protected }; } - IField FindField (ITypeDefinition cls, string name) + IField FindField (IType cls, string name) { - foreach (IField field in cls.Fields) + foreach (IField field in cls.GetFields ()) if (field.Name == name) return field; return null; } - public ITypeDefinition GetClass () + public IUnresolvedTypeDefinition GetClass () { return GetClass (true); } - public ITypeDefinition GetClass (bool getUserClass) + public IUnresolvedTypeDefinition GetClass (bool getUserClass) { if (targetObject == null) return null; @@ -252,14 +250,14 @@ namespace MonoDevelop.GtkCore.GuiBuilder // The class name may have changed. Try to guess the new name. - var matches = new List<ITypeDefinition> (); + var matches = new List<IUnresolvedTypeDefinition> (); ParsedDocument unit = null; var ctx = gproject.GetParserContext (); var doc = TypeSystemService.ParseFile (project, classFile); if (doc != null) { unit = doc; foreach (var fcls in unit.TopLevelTypeDefinitions) { - if (IsValidClass (ctx, fcls, targetObject)) + if (IsValidClass (fcls.Resolve (project), targetObject)) matches.Add (fcls); } } @@ -276,7 +274,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder // If not found, warn the user. if (unit != null && unit.TopLevelTypeDefinitions.Count > 0) { - using (SelectRenamedClassDialog dialog = new SelectRenamedClassDialog (unit.TopLevelTypeDefinitions)) { + using (SelectRenamedClassDialog dialog = new SelectRenamedClassDialog (unit.TopLevelTypeDefinitions.Select (c => c.Resolve (project)))) { if (dialog.Run ()) { className = dialog.SelectedClass; if (className == null) @@ -295,16 +293,15 @@ namespace MonoDevelop.GtkCore.GuiBuilder return null; } - static bool IsValidClass (ITypeResolveContext ctx, IType cls, Stetic.Component obj) + static bool IsValidClass (IType cls, Stetic.Component obj) { string typeName = obj.Type.ClassName; - foreach (var bt in cls.GetBaseTypes (ctx)) { + foreach (var bt in cls.GetAllBaseTypeDefinitions ()) { if (bt.FullName == typeName) return true; - var baseCls = bt.Resolve (ctx); - if (baseCls != null && IsValidClass (ctx, baseCls, obj)) + if (IsValidClass (bt, obj)) return true; } return false; diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs index 49b036c82e..614946354a 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderProject.cs @@ -39,6 +39,7 @@ using MonoDevelop.Projects; using MonoDevelop.Ide; using ICSharpCode.NRefactory.TypeSystem; using MonoDevelop.TypeSystem; +using System.Linq; namespace MonoDevelop.GtkCore.GuiBuilder { @@ -478,24 +479,24 @@ namespace MonoDevelop.GtkCore.GuiBuilder return null; } - ITypeDefinition GetClass (Stetic.ProjectItemInfo obj, bool getUserClass) + IUnresolvedTypeDefinition GetClass (Stetic.ProjectItemInfo obj, bool getUserClass) { string name = CodeBinder.GetClassName (obj); return FindClass (name, getUserClass); } - public ITypeDefinition FindClass (string className) + public IUnresolvedTypeDefinition FindClass (string className) { return FindClass (className, true); } - public ITypeDefinition FindClass (string className, bool getUserClass) + public IUnresolvedTypeDefinition FindClass (string className, bool getUserClass) {
FilePath gui_folder = GtkDesignInfo.FromProject (project).GtkGuiFolder; var ctx = GetParserContext (); if (ctx == null) return null; - var classes = ctx.GetTypes (); + var classes = ctx.MainAssembly.GetAllTypeDefinitions (); if (classes == null) return null; foreach (var cls in classes) { @@ -503,7 +504,7 @@ namespace MonoDevelop.GtkCore.GuiBuilder if (getUserClass) { // Return this class only if it is declared outside the gtk-gui // folder. Generated partial classes will be ignored. - foreach (var part in cls.GetParts ()) { + foreach (var part in cls.Parts) { if (!string.IsNullOrEmpty (part.Region.FileName) && !((FilePath)cls.Region.FileName).IsChildPathOf (gui_folder)) { return part; } @@ -512,15 +513,15 @@ namespace MonoDevelop.GtkCore.GuiBuilder } if (getUserClass && !string.IsNullOrEmpty (cls.Region.FileName) && ((FilePath)cls.Region.FileName).IsChildPathOf (gui_folder)) continue; - return cls; + return cls.Parts.First (); } } return null; } - public ITypeResolveContext GetParserContext () + public ICompilation GetParserContext () { - var dom = TypeSystemService.GetProjectContext (Project); + var dom = TypeSystemService.GetCompilation (Project); if (dom != null && needsUpdate) { needsUpdate = false; // dom.ForceUpdate (); diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs index 9597e4255d..15104a9775 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore.GuiBuilder/GuiBuilderWindow.cs @@ -107,8 +107,8 @@ namespace MonoDevelop.GtkCore.GuiBuilder // Find the classes that could be bound to this design var ctx = fproject.GetParserContext (); ArrayList list = new ArrayList (); - foreach (var cls in ctx.GetAllTypes ()) { - if (IsValidClass (ctx, cls)) + foreach (var cls in ctx.MainAssembly.GetAllTypeDefinitions ()) { + if (IsValidClass (cls)) list.Add (cls.FullName); } @@ -224,14 +224,14 @@ namespace MonoDevelop.GtkCore.GuiBuilder } } - internal bool IsValidClass (ITypeResolveContext ctx, IType cls) + internal bool IsValidClass (IType cls) { - foreach (var bt in cls.GetBaseTypes (ctx)) { - if (bt.Resolve (ctx).ReflectionName == rootWidget.Component.Type.ClassName) + foreach (var bt in cls.GetAllBaseTypeDefinitions ()) { + if (bt.ReflectionName == rootWidget.Component.Type.ClassName) return true; - var baseCls = bt.Resolve (ctx); - if (baseCls != null && IsValidClass (ctx, baseCls)) + var baseCls = bt; + if (baseCls != null && IsValidClass (baseCls)) return true; } return false; diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ObjectsDocument.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ObjectsDocument.cs index 03c5ad5591..22220cfbbd 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ObjectsDocument.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/ObjectsDocument.cs @@ -123,10 +123,10 @@ namespace MonoDevelop.GtkCore var cls = parser.GetClass (clsname); if (cls == null) continue; - CodeGenerationService.AddAttribute (parser.Ctx, cls, "System.ComponentModel.ToolboxItem", true); + CodeGenerationService.AddAttribute (cls, "System.ComponentModel.ToolboxItem", true); XmlElement elem = DocumentElement.SelectSingleNode ("object[@type='" + clsname + "']") as XmlElement; if (elem != null && elem.HasAttribute ("palette-category")) { - CodeGenerationService.AddAttribute (parser.Ctx, cls, "System.ComponentModel.Category", elem.GetAttribute ("palette-category")); + CodeGenerationService.AddAttribute (cls, "System.ComponentModel.Category", elem.GetAttribute ("palette-category")); } } } diff --git a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetParser.cs b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetParser.cs index 2caf805855..a5a0f709d6 100644 --- a/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetParser.cs +++ b/main/src/addins/MonoDevelop.GtkCore/MonoDevelop.GtkCore/WidgetParser.cs @@ -41,15 +41,15 @@ namespace MonoDevelop.GtkCore public class WidgetParser { - ITypeResolveContext ctx; + ICompilation ctx; - public ITypeResolveContext Ctx { + public ICompilation Ctx { get { return ctx; } } - public WidgetParser (ITypeResolveContext ctx) + public WidgetParser (ICompilation ctx) { this.ctx = ctx; } @@ -58,10 +58,10 @@ namespace MonoDevelop.GtkCore { Dictionary<string, ITypeDefinition> tb_items = new Dictionary<string, ITypeDefinition> (); - var wt = ctx.GetTypeDefinition ("Gtk", "Widget", 0, StringComparer.Ordinal); + var wt = ctx.FindType ("Gtk.Widget"); if (wt != null) { - foreach (var t in wt.GetSubTypeDefinitions (ctx)) { - if (t.ProjectContent == ctx && IsToolboxWidget (t)) + foreach (var t in wt.GetSubTypeDefinitions ()) { + if (IsToolboxWidget (t)) tb_items [t.FullName] = t; } } @@ -83,8 +83,7 @@ namespace MonoDevelop.GtkCore events [ev.Name] = ev; if (inherited) { - foreach (var bt in cls.BaseTypes) { - var bcls = bt.Resolve (ctx).GetDefinition (); + foreach (var bcls in cls.GetAllBaseTypeDefinitions ()) { if (bcls != null && bcls.Kind != TypeKind.Class) CollectMembers (bcls, true, topType, properties, events); } @@ -93,14 +92,13 @@ namespace MonoDevelop.GtkCore public string GetBaseType (ITypeDefinition cls, Hashtable knownTypes) { - foreach (var bt in cls.BaseTypes) { - string name = bt.Resolve (ctx).ReflectionName; + foreach (var bt in cls.GetAllBaseTypeDefinitions ()) { + string name = bt.ReflectionName; if (knownTypes.Contains (name)) return name; } - foreach (var bt in cls.BaseTypes) { - var bcls = bt.Resolve (ctx).GetDefinition (); + foreach (var bcls in cls.GetAllBaseTypeDefinitions ()) { if (bcls != null) { string ret = GetBaseType (bcls, knownTypes); if (ret != null) @@ -114,7 +112,7 @@ namespace MonoDevelop.GtkCore { // foreach (IAttributeSection section in decoration.Attributes) { foreach (IAttribute at in decoration.Attributes) { - var type = at.AttributeType.Resolve (ctx); + var type = at.AttributeType; switch (type.ReflectionName) { case "Category": case "CategoryAttribute": @@ -124,7 +122,7 @@ namespace MonoDevelop.GtkCore default: continue; } - var pargs = at.GetPositionalArguments (ctx); + var pargs = at.PositionalArguments; if (pargs != null && pargs.Count > 0) { var val = pargs[0] as ConstantResolveResult; if (val is string) @@ -146,7 +144,7 @@ namespace MonoDevelop.GtkCore ns = ""; name = classname; } - return ctx.GetTypeDefinition (ns, name, 0, StringComparer.Ordinal); + return ctx.MainAssembly.GetTypeDefinition (ns, name, 0); } public bool IsBrowsable (IMember member) @@ -158,13 +156,13 @@ namespace MonoDevelop.GtkCore if (prop != null) { if (!prop.CanGet || !prop.CanSet) return false; - if (Array.IndexOf (supported_types, prop.ReturnType.Resolve (ctx).ReflectionName) == -1) + if (Array.IndexOf (supported_types, prop.ReturnType.ReflectionName) == -1) return false; } // foreach (IAttributeSection section in member.Attributes) { foreach (IAttribute at in member.Attributes) { - var type = at.AttributeType.Resolve (ctx); + var type = at.AttributeType; switch (type.ReflectionName) { case "Browsable": case "BrowsableAttribute": @@ -174,7 +172,7 @@ namespace MonoDevelop.GtkCore default: continue; } - var pargs = at.GetPositionalArguments (ctx); + var pargs = at.PositionalArguments; if (pargs != null && pargs.Count > 0) { var val = pargs[0] as ConstantResolveResult; if (val.ConstantValue is bool) { @@ -192,7 +190,7 @@ namespace MonoDevelop.GtkCore return false; foreach (IAttribute at in cls.Attributes) { - var type = at.AttributeType.Resolve (ctx); + var type = at.AttributeType; switch (type.ReflectionName) { case "ToolboxItem": case "ToolboxItemAttribute": @@ -202,7 +200,7 @@ namespace MonoDevelop.GtkCore default: continue; } - var pargs = at.GetPositionalArguments (ctx); + var pargs = at.PositionalArguments; if (pargs != null && pargs.Count > 0) { var val = pargs[0] as ConstantResolveResult; if (val.ConstantValue == null) @@ -214,8 +212,7 @@ namespace MonoDevelop.GtkCore } } - foreach (var bt in cls.BaseTypes) { - var bcls = bt.Resolve (ctx).GetDefinition (); + foreach (var bcls in cls.GetAllBaseTypeDefinitions ()) { if (bcls != null && bcls.Kind != TypeKind.Interface) return IsToolboxWidget (bcls); } diff --git a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs index c05c97b4e0..00fa35ffb1 100644 --- a/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs +++ b/main/src/addins/MonoDevelop.Refactoring/MonoDevelop.Refactoring.Rename/RenameRefactoring.cs @@ -71,7 +71,7 @@ namespace MonoDevelop.Refactoring.Rename return false; } - public static void Rename (ITypeResolveContext ctx, IEntity entity, string newName) + public static void Rename (IEntity entity, string newName) { using (var monitor = new NullProgressMonitor ()) { var col = ReferenceFinder.FindReferences (entity, monitor); diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs index 2d37ebc75a..9bc6b2e673 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.Ide.Gui.Pads.ClassPad/ProjectNodeBuilder.cs @@ -107,7 +107,6 @@ namespace MonoDevelop.Ide.Gui.Pads.ClassPad } bool publicOnly = builder.Options ["PublicApiOnly"]; var dom = TypeSystemService.GetCompilation (project); - var ctx = TypeSystemService.GetContext (project); bool nestedNamespaces = builder.Options ["NestedNamespaces"]; HashSet<string> addedNames = new HashSet<string> (); foreach (var ns in dom.RootNamespace.ChildNamespaces) { diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/CodeGenerationService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/CodeGenerationService.cs index 8c3c9922b8..0681469340 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/CodeGenerationService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/CodeGenerationService.cs @@ -372,7 +372,7 @@ namespace MonoDevelop.TypeSystem } #endregion - public static void AddAttribute (ITypeResolveContext ctx, ITypeDefinition cls, string name, params object[] parameters) + public static void AddAttribute (ITypeDefinition cls, string name, params object[] parameters) { bool isOpen; string fileName = cls.Region.FileName; diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/ParsedDocument.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/ParsedDocument.cs index 90e89bf68e..52b490b747 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/ParsedDocument.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/ParsedDocument.cs @@ -186,6 +186,10 @@ namespace MonoDevelop.TypeSystem } } + public virtual ITypeResolveContext GetTypeResolveContext (ICompilation compilation, TextLocation loc) + { + return null; + } #endregion #region IFreezable implementation @@ -407,6 +411,13 @@ namespace MonoDevelop.TypeSystem { return base.GenerateFolds ().Concat (AddFolds ()); } + + + public override ITypeResolveContext GetTypeResolveContext (ICompilation compilation, TextLocation loc) + { + return parsedFile.GetTypeResolveContext (compilation, loc); + } + /* #region IFreezable implementation public override void Freeze () @@ -619,6 +630,7 @@ namespace MonoDevelop.TypeSystem } return false; } + } } diff --git a/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/TypeSystemService.cs b/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/TypeSystemService.cs index fb04150d92..a63f8779f3 100644 --- a/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/TypeSystemService.cs +++ b/main/src/core/MonoDevelop.Ide/MonoDevelop.TypeSystem/TypeSystemService.cs @@ -92,6 +92,13 @@ namespace MonoDevelop.TypeSystem // TODO: Implement me! return false; } + + public static IType Resolve (this IUnresolvedTypeDefinition def, Project project) + { + var pf = TypeSystemService.GetProjectContext (project).GetFile (def.Region.FileName); + var ctx = pf.GetTypeResolveContext (TypeSystemService.GetCompilation (project), def.Region.Begin); + return def.Resolve (ctx); + } } public static class TypeSystemService @@ -919,25 +926,6 @@ namespace MonoDevelop.TypeSystem static Dictionary<Project, ITypeResolveContext> cachedProjectContents = new Dictionary<Project, ITypeResolveContext> (); static Dictionary<string, AssemblyContext> cachedAssemblyContents = new Dictionary<string, AssemblyContext> (); - - - public static ITypeResolveContext GetContext (Project project) - { - throw new NotImplementedException (); -/* lock (cachedProjectContents) { - ITypeResolveContext result; - if (cachedProjectContents.TryGetValue (project, out result)) - return result; - - ProjectContentWrapper content; - if (projectContents.TryGetValue (project, out content)) - contexts.Add (content); - - result = new CompositeTypeResolveContext (contexts); - cachedProjectContents [project] = result; - return result; - }*/ - } public static void ForceUpdate (ITypeResolveContext context) { |