diff options
author | Lluis Sanchez Gual <lluis@novell.com> | 2011-01-27 19:41:34 +0300 |
---|---|---|
committer | Lluis Sanchez Gual <lluis@novell.com> | 2011-01-27 19:47:54 +0300 |
commit | 2ad9c81d71d1d5fee8d2f5738fe93083a0b1b292 (patch) | |
tree | 1b7c0cd0864d71b469ac4ade818011b6bc8e0189 /extras/MonoDevelop.AddinAuthoring | |
parent | 3a2272c7103a1dcb9386d01b1a5bd625668cfbf1 (diff) |
Ongoing work. Basic dom based assembly reflector now works.
Diffstat (limited to 'extras/MonoDevelop.AddinAuthoring')
12 files changed, 481 insertions, 45 deletions
diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.CodeCompletion/CodeCompletionExtension.cs b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.CodeCompletion/CodeCompletionExtension.cs index 81416b82f9..ceafef167b 100644 --- a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.CodeCompletion/CodeCompletionExtension.cs +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.CodeCompletion/CodeCompletionExtension.cs @@ -37,7 +37,6 @@ using MonoDevelop.Projects; using MonoDevelop.Ide.CodeCompletion; using MonoDevelop.Ide.Gui.Content; using MonoDevelop.Ide.Gui; -using MonoDevelop.Ide.CodeCompletion; using MonoDevelop.XmlEditor; using MonoDevelop.Xml.StateEngine; using MonoDevelop.XmlEditor.Gui; diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.NodeBuilders/ExtensionNodeNodeBuilder.cs b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.NodeBuilders/ExtensionNodeNodeBuilder.cs index 45af4d115c..be47000797 100644 --- a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.NodeBuilders/ExtensionNodeNodeBuilder.cs +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.NodeBuilders/ExtensionNodeNodeBuilder.cs @@ -269,7 +269,6 @@ namespace MonoDevelop.AddinAuthoring.NodeBuilders ExtensionNodeTypeCollection GetAllowedChildTypes () { - ExtensionNodeTypeCollection types = null; ExtensionNodeInfo en = (ExtensionNodeInfo) CurrentNode.DataItem; object parent = en.Node.Parent; diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.csproj b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.csproj index efc97dac9b..a515f3599a 100644 --- a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.csproj +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.csproj @@ -122,6 +122,8 @@ <Compile Include="MonoDevelop.AddinAuthoring\AddinDescriptionDisplayBinding.cs" /> <Compile Include="MonoDevelop.AddinAuthoring\AddinDescriptionView.cs" /> <Compile Include="MonoDevelop.AddinAuthoring\DomAssemblyReflector.cs" /> + <Compile Include="MonoDevelop.AddinAuthoring\AddinFileSystem.cs" /> + <Compile Include="MonoDevelop.AddinAuthoring\RegistryEventArgs.cs" /> </ItemGroup> <ItemGroup> <EmbeddedResource Include="gtk-gui\gui.stetic"> @@ -171,79 +173,102 @@ <Reference Include="gtk-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> <Reference Include="MonoDevelop.Ide, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="NRefactory, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="Mono.Cecil, Version=0.6.8.8607, Culture=neutral"> <Package>monodevelop</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="Mono.TextEditor, Version=1.0.0.0, Culture=neutral"> <Package>monodevelop</Package> </Reference> <Reference Include="MonoDevelop.VersionControl, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.NUnit, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.XmlEditor, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.Gettext, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.Deployment, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.Deployment.Linux, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.GtkCore, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.DesignerSupport, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.VBNetBinding, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.CSharpBinding, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.SourceEditor2, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.Debugger, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System" /> <Reference Include="System.Xml" /> <Reference Include="MonoDevelop.Core, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.AspNet, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.CBinding, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.Autotools, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="System.Core"> </Reference> <Reference Include="MonoDevelop.Refactoring, Version=2.1.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.Moonlight, Version=2.2.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="MonoDevelop.Debugger.Soft, Version=2.2.0.0, Culture=neutral"> <Package>monodevelop-core-addins</Package> + <SpecificVersion>False</SpecificVersion> </Reference> <Reference Include="glib-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> - <Reference Include="gtkhtml-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f" /> + <Reference Include="gtkhtml-sharp, Version=2.12.0.0, Culture=neutral, PublicKeyToken=35e10195dab3c99f"> + </Reference> <Reference Include="Mono.Debugger.Soft, Version=0.0.0.0, Culture=neutral, PublicKeyToken=0738eb9f132ed756"> <Package>monodevelop-core-addins</Package> </Reference> diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.make b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.make index b275948011..27c5767f8a 100644 --- a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.make +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring.make @@ -93,6 +93,7 @@ FILES = \ MonoDevelop.AddinAuthoring/AddinDescriptionWidget.cs \ MonoDevelop.AddinAuthoring/AddinFeatureWidget.cs \ MonoDevelop.AddinAuthoring/AddinFileDescriptionTemplate.cs \ + MonoDevelop.AddinAuthoring/AddinFileSystem.cs \ MonoDevelop.AddinAuthoring/AddinOptionPanelWidget.cs \ MonoDevelop.AddinAuthoring/AddinProjectExtension.cs \ MonoDevelop.AddinAuthoring/AddinProjectReference.cs \ @@ -113,6 +114,7 @@ FILES = \ MonoDevelop.AddinAuthoring/NodeSetEditorDialog.cs \ MonoDevelop.AddinAuthoring/NodeSetEditorWidget.cs \ MonoDevelop.AddinAuthoring/NodeTypeEditorDialog.cs \ + MonoDevelop.AddinAuthoring/RegistryEventArgs.cs \ MonoDevelop.AddinAuthoring/RegistryExtensionNode.cs \ MonoDevelop.AddinAuthoring/RegistrySelector.cs \ MonoDevelop.AddinAuthoring/SelectNodeSetDialog.cs \ diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/AddinAuthoringService.cs b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/AddinAuthoringService.cs index e982c8a861..8dd854eec1 100644 --- a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/AddinAuthoringService.cs +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/AddinAuthoringService.cs @@ -42,7 +42,6 @@ using MonoDevelop.Core.Serialization; using MonoDevelop.Projects.Formats.MSBuild; using MonoDevelop.Xml.Formatting; using MonoDevelop.Projects.Policies; -using MonoDevelop.Ide; namespace MonoDevelop.AddinAuthoring { @@ -51,6 +50,8 @@ namespace MonoDevelop.AddinAuthoring static AddinAuthoringServiceConfig config; static string configFile; + public static event EventHandler<RegistryEventArgs> RegistryChanged; + static AddinAuthoringService () { if (IdeApp.IsInitialized) { @@ -286,7 +287,6 @@ namespace MonoDevelop.AddinAuthoring public static void SaveFormatted (PolicyContainer policies, AddinDescription adesc) { XmlDocument doc = adesc.SaveToXml (); - XmlFormatter formatter = new XmlFormatter (); TextStylePolicy textPolicy = policies.Get<TextStylePolicy> (DesktopService.GetMimeTypeInheritanceChain ("application/x-addin+xml")); XmlFormattingPolicy xmlPolicy = policies.Get<XmlFormattingPolicy> (DesktopService.GetMimeTypeInheritanceChain ("application/x-addin+xml")); @@ -294,6 +294,12 @@ namespace MonoDevelop.AddinAuthoring string xml = XmlFormatter.FormatXml (textPolicy, xmlPolicy, doc.OuterXml); File.WriteAllText (adesc.FileName, xml); } + + public static void NotifyRegistryChanged (AddinRegistry reg) + { + if (RegistryChanged != null) + RegistryChanged (null, new RegistryEventArgs () { Registry = reg }); + } } class AddinAuthoringServiceConfig diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/AddinFileSystem.cs b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/AddinFileSystem.cs new file mode 100644 index 0000000000..97176a5ac3 --- /dev/null +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/AddinFileSystem.cs @@ -0,0 +1,268 @@ +// +// AddinFileSystem.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using System.Linq; +using System.Collections.Generic; +using MonoDevelop.Core; +using Mono.Addins.Database; +using System.IO; +using MonoDevelop.Projects; +using MonoDevelop.Ide; +using MonoDevelop.Projects.Dom.Parser; + +namespace MonoDevelop.AddinAuthoring +{ + public class AddinFileSystem: AddinFileSystemExtension, IDisposable + { + DomAssemblyReflector reflector; + Solution solution; + Dictionary<FilePath,List<FilePath>> folders = new Dictionary<FilePath, List<FilePath>> (); + Dictionary<FilePath,FilePath> fileMaps = new Dictionary<FilePath, FilePath> (); + Dictionary<FilePath,DotNetProject> projectMaps = new Dictionary<FilePath, DotNetProject> (); + Dictionary<DotNetProject,DateTime> projectTimestamps = new Dictionary<DotNetProject, DateTime> (); + + public event EventHandler Changed; + + public AddinFileSystem (Solution solution) + { + this.solution = solution; + solution.FileChangedInProject += HandleSolutionFileChangedInProject; + solution.EntrySaved += HandleSolutionEntrySaved; + solution.SolutionItemRemoved += HandleSolutionSolutionItemRemoved; + ProjectDomService.TypesUpdated += OnParseInfoChanged; + } + + public void Dispose () + { + solution.FileChangedInProject -= HandleSolutionFileChangedInProject; + solution.EntrySaved -= HandleSolutionEntrySaved; + ProjectDomService.TypesUpdated -= OnParseInfoChanged; + solution.SolutionItemRemoved -= HandleSolutionSolutionItemRemoved; + if (reflector != null) + reflector.UnloadAssemblyDoms (); + } + + void OnParseInfoChanged (object sender, MonoDevelop.Projects.Dom.TypeUpdateInformationEventArgs e) + { + if (e.Project is DotNetProject && e.Project.ParentSolution == solution) { + projectTimestamps [(DotNetProject)e.Project] = DateTime.Now; + OnChanged (); + } + } + + void HandleSolutionEntrySaved (object sender, SolutionItemEventArgs e) + { + if (e.SolutionItem is DotNetProject) { + projectTimestamps [(DotNetProject)e.SolutionItem] = DateTime.Now; + OnChanged (); + } + } + + void HandleSolutionFileChangedInProject (object sender, ProjectFileEventArgs e) + { + if (e.Project is DotNetProject) { + projectTimestamps [(DotNetProject)e.Project] = DateTime.Now; + OnChanged (); + } + } + + void HandleSolutionSolutionItemRemoved (object sender, SolutionItemChangeEventArgs e) + { + if (e.SolutionItem is DotNetProject) { + projectTimestamps.Remove ((DotNetProject)e.SolutionItem); + OnChanged (); + } + } + + void OnChanged () + { + if (Changed != null) + Changed (this, EventArgs.Empty); + } + + public override bool RequiresIsolation { + get { + return false; + } + } + + public override void ScanStarted () + { + base.ScanStarted (); + + folders.Clear (); + fileMaps.Clear (); + projectMaps.Clear (); + + // Locate all add-in folders + + foreach (DotNetProject p in solution.GetAllSolutionItems<DotNetProject> ()) { + foreach (DotNetProjectConfiguration conf in p.Configurations) { + + FilePath asmFile = p.GetOutputFileName (conf.Selector); + AddProjectMap (asmFile, p); + + // Map support files + foreach (var file in p.GetSupportFileList (conf.Selector)) { + FilePath tpath = conf.OutputDirectory.Combine (file.Target); + if (file.Src != tpath) + AddFileMap (tpath, file.Src); + } + + // Map references to other projects + foreach (ProjectReference pref in p.References) { + if (pref.ReferenceType == ReferenceType.Project) { + DotNetProject refProject = solution.FindProjectByName (pref.Reference) as DotNetProject; + if (refProject != null) { + FilePath refOutput = refProject.GetOutputFileName (conf.Selector); + if (refOutput.IsNull) + refOutput = refProject.GetOutputFileName (ConfigurationSelector.Default); + if (!refOutput.IsNullOrEmpty) + projectMaps [conf.OutputDirectory.Combine (refOutput.FileName)] = refProject; + } + } + } + } + } + } + + public override void ScanFinished () + { + base.ScanFinished (); + folders.Clear (); + fileMaps.Clear (); + projectMaps.Clear (); + if (reflector != null) + reflector.UnloadAssemblyDoms (); + } + + void AddFileMap (FilePath src, FilePath dst) + { + fileMaps [src] = dst; + RegPath (src); + } + + void AddProjectMap (FilePath src, DotNetProject p) + { + projectMaps [src] = p; + RegPath (src); + } + + void RegPath (FilePath src) + { + List<FilePath> files; + if (!folders.TryGetValue (src.ParentDirectory, out files)) + folders [src.ParentDirectory] = files = new List<FilePath> (); + if (!files.Any (f => f == src)) + files.Add (src); + } + + public override bool DirectoryExists (string dir) + { + FilePath path = dir; + if (folders.ContainsKey (path) || base.DirectoryExists (path)) + return true; + + foreach (FilePath f in folders.Keys) { + if (f.IsChildPathOf (dir)) + return true; + } + return false; + } + + public override bool FileExists (string path) + { + return base.FileExists (path) || fileMaps.ContainsKey (path) || projectMaps.ContainsKey (path); + } + + public override IEnumerable<string> GetDirectories (string path) + { + HashSet<FilePath> dirs = new HashSet<FilePath> (); + + if (base.DirectoryExists (path)) + dirs.UnionWith (base.GetDirectories (path).Select (s => (FilePath)s)); + + FilePath dir = path; + foreach (FilePath f in folders.Keys) { + if (f.IsChildPathOf (dir)) { + string s = f.ToRelative (dir); + int i = s.IndexOf (Path.DirectorySeparatorChar); + if (i != -1) + dirs.Add (dir.Combine (s.Substring (0,i))); + else + dirs.Add (dir.Combine (s)); + } + } + return dirs.Select (p => (string)p); + } + + public override IEnumerable<string> GetFiles (string path) + { + HashSet<FilePath> files = new HashSet<FilePath> (); + if (base.DirectoryExists (path)) + files.UnionWith (base.GetFiles (path).Select (s => (FilePath)s)); + + List<FilePath> dirFiles; + if (folders.TryGetValue (path, out dirFiles)) + files.UnionWith (dirFiles); + + return files.Select (p => (string)p); + } + + public override DateTime GetLastWriteTime (string filePath) + { + FilePath mapped; + if (fileMaps.TryGetValue (filePath, out mapped)) + return base.GetLastWriteTime (mapped); + + DotNetProject p; + if (projectMaps.TryGetValue (filePath, out p)) { + DateTime t; + if (!projectTimestamps.TryGetValue (p, out t)) + projectTimestamps [p] = t = DateTime.Now; + return t; + } + + return base.GetLastWriteTime (filePath); + } + + public override Stream OpenFile (string path) + { + FilePath mapped; + if (fileMaps.TryGetValue (path, out mapped)) + return base.OpenFile (mapped); + return base.OpenFile (path); + } + + public override IAssemblyReflector GetReflectorForFile (IAssemblyLocator locator, string path) + { + if (reflector == null) + reflector = new DomAssemblyReflector (solution); + return reflector; + } + } +} + diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/DomAssemblyReflector.cs b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/DomAssemblyReflector.cs index 7385fbc588..d36aab34c9 100644 --- a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/DomAssemblyReflector.cs +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/DomAssemblyReflector.cs @@ -37,12 +37,14 @@ using System.CodeDom; using System.Reflection; using MA = Mono.Addins.Database; using Mono.Addins; +using MonoDevelop.Core; namespace MonoDevelop.AddinAuthoring { public class DomAssemblyReflector: IAssemblyReflector { Solution solution; + List<FilePath> loadedDoms = new List<FilePath> (); public DomAssemblyReflector (Solution solution) { @@ -301,7 +303,7 @@ namespace MonoDevelop.AddinAuthoring } else if (exp is CodeTypeOfExpression) { CodeTypeOfExpression ce = (CodeTypeOfExpression) exp; - return new EvalResult () { Type = "String.Type", Value = ce.Type.BaseType }; + return new EvalResult () { Type = "System.Type", Value = ce.Type.BaseType }; } else throw new NotSupportedException (); @@ -315,11 +317,31 @@ namespace MonoDevelop.AddinAuthoring public object LoadAssembly (string file) { - DotNetProject p = solution.FindSolutionItem (file) as DotNetProject; - if (p != null) - return ProjectDomService.GetProjectDom (p); - else - return null; + DotNetProject project = null; + foreach (DotNetProject p in solution.GetAllSolutionItems<DotNetProject> ()) { + foreach (var conf in p.Configurations) { + if (p.GetOutputFileName (conf.Selector) == file) { + project = p; + break; + } + } + } + if (project != null) + return ProjectDomService.GetProjectDom (project); + else { + if (!loadedDoms.Contains (file)) { + loadedDoms.Add (file); + ProjectDomService.LoadAssembly (Runtime.SystemAssemblyService.DefaultRuntime, file); + } + return ProjectDomService.GetAssemblyDom (Runtime.SystemAssemblyService.DefaultRuntime, file); + } + } + + public void UnloadAssemblyDoms () + { + foreach (var f in loadedDoms) + ProjectDomService.UnloadAssembly (Runtime.SystemAssemblyService.DefaultRuntime, f); + loadedDoms.Clear (); } public object LoadAssemblyFromReference (object asmReference) diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionModelBrowser.cs b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionModelBrowser.cs index 2b2d5021da..25d8f7c551 100644 --- a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionModelBrowser.cs +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionModelBrowser.cs @@ -50,7 +50,7 @@ namespace MonoDevelop.AddinAuthoring } } - public void Dispose () + public override void Dispose () { if (widget != null) widget.Destroy (); diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionModelBrowserWidget.cs b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionModelBrowserWidget.cs index 9474195f32..e6ba966c31 100644 --- a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionModelBrowserWidget.cs +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/ExtensionModelBrowserWidget.cs @@ -25,6 +25,7 @@ // THE SOFTWARE. using System; +using System.Collections.Generic; using MonoDevelop.Ide.Gui.Components; using MonoDevelop.AddinAuthoring.NodeBuilders; using MonoDevelop.Ide; @@ -41,6 +42,8 @@ namespace MonoDevelop.AddinAuthoring { ExtensibleTreeView tree; Gtk.Widget docView; + Dictionary<AddinRegistry, RegistryInfo> registries = new Dictionary<AddinRegistry, RegistryInfo> (); + Dictionary<Solution, RegistryInfo> solutions = new Dictionary<Solution, RegistryInfo> (); public ExtensionModelBrowserWidget () { @@ -64,24 +67,67 @@ namespace MonoDevelop.AddinAuthoring tree.ShowAll (); paned.Add1 (tree); - foreach (var item in IdeApp.Workspace.Items) { - if (item is Solution) { - Solution sol = (Solution) item; - SolutionAddinData data = sol.GetAddinData (); - if (data != null) { - RegistryInfo reg = new RegistryInfo (); - reg.ApplicationName = data.ApplicationName; - reg.CachedRegistry = data.Registry; - tree.AddChild (reg); - } - } - } + foreach (Solution sol in IdeApp.Workspace.GetAllSolutions ()) + AddSolution (sol); docView = new Gtk.Label (); paned.Add2 (docView); tree.ShadowType = Gtk.ShadowType.In; tree.Tree.Selection.Changed += HandleSelectionChanged; + + AddinAuthoringService.RegistryChanged += OnRegistryChanged; + IdeApp.Workspace.WorkspaceItemLoaded += OnSolutionLoaded; + IdeApp.Workspace.WorkspaceItemUnloaded += OnSolutionUnloaded; + } + + protected override void OnDestroyed () + { + AddinAuthoringService.RegistryChanged -= OnRegistryChanged; + IdeApp.Workspace.WorkspaceItemLoaded -= OnSolutionLoaded; + IdeApp.Workspace.WorkspaceItemUnloaded -= OnSolutionUnloaded; + base.OnDestroyed (); + } + + void AddSolution (Solution sol) + { + SolutionAddinData data = sol.GetAddinData (); + if (data != null) { + RegistryInfo reg = new RegistryInfo (); + reg.ApplicationName = data.ApplicationName; + reg.CachedRegistry = data.Registry; + tree.AddChild (reg); + registries [reg.CachedRegistry] = reg; + solutions [sol] = reg; + } + } + + void OnSolutionLoaded (object sender, WorkspaceItemEventArgs e) + { + if (e.Item is Solution) + AddSolution ((Solution)e.Item); + } + + void OnSolutionUnloaded (object sender, WorkspaceItemEventArgs e) + { + if (e.Item is Solution) { + RegistryInfo reg; + if (solutions.TryGetValue ((Solution) e.Item, out reg)) { + var nav = tree.BuilderContext.GetTreeBuilder (reg); + if (nav != null) + nav.Remove (); + } + } + } + + void OnRegistryChanged (object sender, RegistryEventArgs e) + { + RegistryInfo reg; + if (registries.TryGetValue (e.Registry, out reg)) { + var nav = tree.BuilderContext.GetTreeBuilder (reg); + if (nav != null) + nav.UpdateAll (); + } } void HandleSelectionChanged (object sender, EventArgs e) diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/RegistryEventArgs.cs b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/RegistryEventArgs.cs new file mode 100644 index 0000000000..8c2aacca08 --- /dev/null +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/RegistryEventArgs.cs @@ -0,0 +1,36 @@ +// +// RegistryEventArgs.cs +// +// Author: +// Lluis Sanchez Gual <lluis@novell.com> +// +// Copyright (c) 2011 Novell, Inc (http://www.novell.com) +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. +using System; +using Mono.Addins; + +namespace MonoDevelop.AddinAuthoring +{ + public class RegistryEventArgs: EventArgs + { + public AddinRegistry Registry { get; set; } + } +} + diff --git a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/SolutionAddinData.cs b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/SolutionAddinData.cs index c35cae6585..1b96466796 100644 --- a/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/SolutionAddinData.cs +++ b/extras/MonoDevelop.AddinAuthoring/MonoDevelop.AddinAuthoring/SolutionAddinData.cs @@ -35,15 +35,27 @@ using MonoDevelop.Ide; namespace MonoDevelop.AddinAuthoring { - public class SolutionAddinData + public class SolutionAddinData: IDisposable { AddinRegistry registry; Solution solution; RegistryInfo regInfo; + AddinFileSystem customFileSystem; + bool registryNeedsUpdate; + bool updatePlanned; + + const int RegistryChangeNotifDelay = 1 * 1000; public SolutionAddinData (Solution sol) { solution = sol; + customFileSystem = new AddinFileSystem (sol); + customFileSystem.Changed += OnSolutionChanged; + } + + public void Dispose () + { + customFileSystem.Dispose (); } FilePath TempRegistryPath { @@ -99,6 +111,8 @@ namespace MonoDevelop.AddinAuthoring ResetRegistry (); UpdateRegistry (); } + else if (registryNeedsUpdate) + UpdateRegistry (); } return registry; } @@ -118,10 +132,13 @@ namespace MonoDevelop.AddinAuthoring FilePath path = TempRegistryPath; registry = new AddinRegistry (path, path); } + registry.RegisterExtension (customFileSystem); } public void UpdateRegistry () { + registryNeedsUpdate = false; + FilePath addinsPath = TempRegistryPath.Combine ("addins"); if (!Directory.Exists (addinsPath)) Directory.CreateDirectory (addinsPath); @@ -139,6 +156,26 @@ namespace MonoDevelop.AddinAuthoring tw.WriteEndElement (); } Registry.Update (new ConsoleProgressStatus (false)); + AddinAuthoringService.NotifyRegistryChanged (Registry); + } + + void OnSolutionChanged (object sender, EventArgs e) + { + lock (this) { + if (!updatePlanned) { + updatePlanned = true; + GLib.Timeout.Add (RegistryChangeNotifDelay, OnDelayedUpdate); + } + } + } + + bool OnDelayedUpdate () + { + lock (this) { + updatePlanned = false; + UpdateRegistry (); + } + return false; } public void NotifyChanged () diff --git a/extras/MonoDevelop.AddinAuthoring/gtk-gui/gui.stetic b/extras/MonoDevelop.AddinAuthoring/gtk-gui/gui.stetic index 8044ff37ea..563a9ef1cd 100644 --- a/extras/MonoDevelop.AddinAuthoring/gtk-gui/gui.stetic +++ b/extras/MonoDevelop.AddinAuthoring/gtk-gui/gui.stetic @@ -5,26 +5,23 @@ <target-gtk-version>2.12</target-gtk-version> </configuration> <import> - <widget-library name="MonoDevelop.Ide, Version=2.4.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.Ide, Version=2.6.0.0, Culture=neutral" /> <widget-library name="Mono.TextEditor, Version=1.0.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.VersionControl, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.NUnit, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.XmlEditor, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.Gettext, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.Deployment, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.Deployment.Linux, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.GtkCore, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.DesignerSupport, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.VBNetBinding, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.CSharpBinding, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.SourceEditor2, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.Debugger, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.AspNet, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.CBinding, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.Autotools, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.Refactoring, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.Moonlight, Version=2.4.0.0, Culture=neutral" /> - <widget-library name="MonoDevelop.Debugger.Soft, Version=2.4.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.VersionControl, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.NUnit, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.XmlEditor, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.Gettext, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.Deployment.Linux, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.GtkCore, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.DesignerSupport, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.VBNetBinding, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.CSharpBinding, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.SourceEditor2, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.Debugger, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.AspNet, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.Refactoring, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.Moonlight, Version=2.6.0.0, Culture=neutral" /> + <widget-library name="MonoDevelop.Debugger.Soft, Version=2.6.0.0, Culture=neutral" /> <widget-library name="../build/MonoDevelop.AddinAuthoring.dll" internal="true" /> </import> <widget class="Gtk.Bin" id="MonoDevelop.AddinAuthoring.AddinOptionPanelWidget" design-size="615 437"> @@ -2736,7 +2733,6 @@ </widget> <widget class="Gtk.Bin" id="MonoDevelop.AddinAuthoring.ExtensionModelBrowserWidget" design-size="586 402"> <property name="MemberName" /> - <property name="Visible">False</property> <child> <widget class="Gtk.VBox" id="vbox2"> <property name="MemberName" /> |