From cf8da3c94d19294c131f39ff53cb63320faeb86a Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Fri, 9 Mar 2012 13:56:33 +0100 Subject: [PATCH] Add C# context actions to AddInTree. --- .../CSharpBinding/Project/CSharpBinding.addin | 98 ++++++++++++++++--- .../Project/CSharpBinding.csproj | 2 + .../Project/Src/CSharpContextActionDoozer.cs | 84 ++++++++++++++++ .../Project/Src/ExtensionMethods.cs | 41 ++++++++ .../Project/ICSharpCode.SharpDevelop.csproj | 4 +- .../ContextActions/ContextAction.cs | 11 ++- .../ContextActions/ContextActionViewModel.cs | 2 +- .../ContextActionsBulbControl.xaml.cs | 13 +-- .../ContextActions/ContextActionsHelper.cs | 4 +- .../ContextActions/ContextActionsService.cs | 46 ++++----- .../ContextActions/EditorContext.cs | 61 ++++++++---- .../ContextActions/IContextAction.cs | 4 +- .../ContextActions/IContextActionCache.cs | 15 --- .../ContextActions/IContextActionsProvider.cs | 10 ++ .../RefactoringService/GoToClassAction.cs | 29 ------ ...oToMemberAction.cs => GoToEntityAction.cs} | 18 ++-- 16 files changed, 314 insertions(+), 128 deletions(-) create mode 100644 src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpContextActionDoozer.cs create mode 100644 src/AddIns/BackendBindings/CSharpBinding/Project/Src/ExtensionMethods.cs delete mode 100644 src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextActionCache.cs delete mode 100644 src/Main/Base/Project/Src/Services/RefactoringService/GoToClassAction.cs rename src/Main/Base/Project/Src/Services/RefactoringService/{GoToMemberAction.cs => GoToEntityAction.cs} (54%) diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin index 5bcdc2af82..d9ea3c9b84 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.addin @@ -9,8 +9,11 @@ - + + + + @@ -61,8 +64,8 @@ + class="CSharpBinding.CSharpLanguageBinding" + extensions=".cs" /> @@ -94,14 +97,6 @@ - - + + + + + + + + + + + + + + + + + - - diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj index 10684b7743..996b6517f6 100644 --- a/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/CSharpBinding.csproj @@ -74,9 +74,11 @@ + + diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpContextActionDoozer.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpContextActionDoozer.cs new file mode 100644 index 0000000000..f0223b680a --- /dev/null +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/CSharpContextActionDoozer.cs @@ -0,0 +1,84 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.IO; +using System.Threading; +using System.Threading.Tasks; +using CSharpBinding.Parser; +using ICSharpCode.Core; +using ICSharpCode.NRefactory.CSharp.Resolver; +using ICSharpCode.SharpDevelop.Refactoring; + +namespace CSharpBinding +{ + using NR5ContextAction = ICSharpCode.NRefactory.CSharp.Refactoring.IContextAction; + + /// + /// Doozer for C# context actions. + /// Expects a 'class' referencing an NR5 context action and provides an SD IContextActionsProvider. + /// + public class CSharpContextActionDoozer : IDoozer + { + public bool HandleConditions { + get { return false; } + } + + public object BuildItem(BuildItemArgs args) + { + return new CSharpContextActionWrapper(args.AddIn, args.Codon.Properties); + } + + sealed class CSharpContextActionWrapper : ContextAction + { + readonly AddIn addIn; + readonly string className; + readonly string displayName; + + public CSharpContextActionWrapper(AddIn addIn, Properties properties) + { + this.addIn = addIn; + this.className = properties["class"]; + this.displayName = properties["displayName"]; + } + + bool contextActionCreated; + NR5ContextAction contextAction; + + public override string ID { + get { return className; } + } + + public override string DisplayName { + get { return StringParser.Parse(displayName); } + } + + public override Task IsAvailableAsync(EditorContext context, CancellationToken cancellationToken) + { + if (!string.Equals(Path.GetExtension(context.FileName), ".cs", StringComparison.OrdinalIgnoreCase)) + return Task.FromResult(false); + return Task.Run( + async delegate { + var parseInfo = (await context.GetParseInformationAsync().ConfigureAwait(false)) as CSharpFullParseInformation; + if (parseInfo == null) + return false; + lock (this) { + if (!contextActionCreated) { + contextActionCreated = true; + contextAction = (NR5ContextAction)addIn.CreateObject(className); + } + } + if (contextAction == null) + return false; + CSharpAstResolver resolver = await context.GetAstResolverAsync().ConfigureAwait(false); + return true; + }, cancellationToken); + } + + public override void Execute(EditorContext context) + { + throw new NotImplementedException(); + } + } + } +} diff --git a/src/AddIns/BackendBindings/CSharpBinding/Project/Src/ExtensionMethods.cs b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/ExtensionMethods.cs new file mode 100644 index 0000000000..29ce6b1a27 --- /dev/null +++ b/src/AddIns/BackendBindings/CSharpBinding/Project/Src/ExtensionMethods.cs @@ -0,0 +1,41 @@ +// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) +// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) + +using System; +using System.Threading.Tasks; +using CSharpBinding.Parser; +using ICSharpCode.NRefactory.CSharp; +using ICSharpCode.NRefactory.CSharp.Resolver; +using ICSharpCode.NRefactory.CSharp.TypeSystem; +using ICSharpCode.SharpDevelop.Refactoring; + +namespace CSharpBinding +{ + /// + /// C#-specific extension methods. + /// + public static class ExtensionMethods + { + public static async Task GetCompilationUnitAsync(this EditorContext editorContext) + { + var parseInfo = (await editorContext.GetParseInformationAsync().ConfigureAwait(false)) as CSharpFullParseInformation; + if (parseInfo != null) + return parseInfo.CompilationUnit; + else + return new CompilationUnit(); + } + + public static Task GetAstResolverAsync(this EditorContext editorContext) + { + return editorContext.GetCachedAsync( + async ec => { + var parseInfo = (await ec.GetParseInformationAsync().ConfigureAwait(false)) as CSharpFullParseInformation; + var compilation = await ec.GetCompilationAsync().ConfigureAwait(false); + if (parseInfo != null) + return new CSharpAstResolver(compilation, parseInfo.CompilationUnit, parseInfo.ParsedFile); + else + return new CSharpAstResolver(compilation, new CompilationUnit(), new CSharpParsedFile(ec.FileName)); + }); + } + } +} diff --git a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj index 3b316564ac..95f3c45fee 100644 --- a/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj +++ b/src/Main/Base/Project/ICSharpCode.SharpDevelop.csproj @@ -421,12 +421,10 @@ - - - + diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextAction.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextAction.cs index b4a8295cb6..276f9e8114 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextAction.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextAction.cs @@ -16,16 +16,25 @@ namespace ICSharpCode.SharpDevelop.Refactoring /// public abstract class ContextAction : IContextActionsProvider, IContextAction { - public abstract string Title { get; } + public virtual string ID { + get { return GetType().FullName; } + } + + public abstract string DisplayName { get; } public bool IsVisible { get; set; } + /// + /// Gets whether this context action is available in the given context. + /// + /// public abstract Task IsAvailableAsync(EditorContext context, CancellationToken cancellationToken); public abstract void Execute(EditorContext context); async Task IContextActionsProvider.GetAvailableActionsAsync(EditorContext context, CancellationToken cancellationToken) { + cancellationToken.ThrowIfCancellationRequested(); if (await IsAvailableAsync(context, cancellationToken).ConfigureAwait(false)) return new IContextAction[] { this }; else diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionViewModel.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionViewModel.cs index 61c431d879..ca46e68133 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionViewModel.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionViewModel.cs @@ -32,7 +32,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring } public string Name { - get { return this.action != null ? this.action.Title : string.Empty; } + get { return this.action != null ? this.action.DisplayName : string.Empty; } } public string Comment { get; set; } diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml.cs index 3de65579d5..c2a700e172 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsBulbControl.xaml.cs @@ -4,6 +4,7 @@ using System; using System.Collections.Generic; using System.Text; +using System.Threading; using System.Windows; using System.Windows.Controls; using System.Windows.Data; @@ -30,14 +31,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring remove { this.ActionsTreeView.ActionExecuted -= value; } } - /* - public new ContextActionsBulbViewModel DataContext - { - get { return (ContextActionsBulbViewModel)base.DataContext; } - set { base.DataContext = value; } - } - */ - bool isOpen; public bool IsOpen { get { return isOpen; } @@ -70,9 +63,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring void Expander_Expanded(object sender, RoutedEventArgs e) { - throw new NotImplementedException(); - #warning NotImplementedException - //this.DataContext.LoadHiddenActions(); + ((ContextActionsBulbViewModel)this.DataContext).LoadHiddenActionsAsync(CancellationToken.None).FireAndForget(); } void CheckBox_Click(object sender, RoutedEventArgs e) diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHelper.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHelper.cs index 163fcd8ea2..361f6dce84 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHelper.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsHelper.cs @@ -61,7 +61,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring protected ContextActionViewModel MakeGoToClassAction(ITypeDefinition @class, ObservableCollection childActions) { return new ContextActionViewModel { - Action = new GoToClassAction(@class, this.LabelAmbience.ConvertEntity(@class)), + Action = new GoToEntityAction(@class, this.LabelAmbience), Image = CompletionImage.GetImage(@class), Comment = string.Format("(in {0})", @class.Namespace), ChildActions = childActions @@ -106,7 +106,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring return null; return new ContextActionViewModel { - Action = new GoToMemberAction(derivedMember, this.LabelAmbience), + Action = new GoToEntityAction(derivedMember, this.LabelAmbience), Image = CompletionImage.GetImage(derivedMember), Comment = string.Format("(in {0})", containingClass.FullName), ChildActions = childActions diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsService.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsService.cs index 5d348e0305..6294e81752 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsService.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/ContextActionsService.cs @@ -22,8 +22,6 @@ namespace ICSharpCode.SharpDevelop.Refactoring { static readonly ContextActionsService instance = new ContextActionsService(); - static ContextActionsService() {} - /// /// Key for storing the names of disabled providers in PropertyService. /// @@ -33,20 +31,19 @@ namespace ICSharpCode.SharpDevelop.Refactoring get { return instance; } } - List providers; - private ContextActionsService() { - this.providers = AddInTree.BuildItems("/SharpDevelop/ViewContent/AvalonEdit/ContextActions", null, false); - var disabledActions = LoadProviderVisibilities().ToLookup(s => s); - foreach (var provider in providers) { - provider.IsVisible = !disabledActions.Contains(provider.GetType().FullName); - } } public EditorActionsProvider CreateActionsProvider(ITextEditor editor) { - return new EditorActionsProvider(editor, this.providers); + var editorContext = new EditorContext(editor); + var providers = AddInTree.BuildItems("/SharpDevelop/ViewContent/AvalonEdit/ContextActions", editorContext, false); + var disabledActions = new HashSet(LoadProviderVisibilities()); + foreach (var provider in providers) { + provider.IsVisible = !disabledActions.Contains(provider.ID); + } + return new EditorActionsProvider(editorContext, providers); } static List LoadProviderVisibilities() @@ -54,9 +51,9 @@ namespace ICSharpCode.SharpDevelop.Refactoring return PropertyService.Get(PropertyServiceKey, new List()); } - public void SaveProviderVisibilities() + public void SaveProviderVisibilities(IEnumerable providers) { - List disabledProviders = this.providers.Where(p => !p.IsVisible).Select(p => p.GetType().FullName).ToList(); + List disabledProviders = providers.Where(p => !p.IsVisible).Select(p => p.ID).ToList(); PropertyService.Set(PropertyServiceKey, disabledProviders); } } @@ -67,17 +64,20 @@ namespace ICSharpCode.SharpDevelop.Refactoring public class EditorActionsProvider { readonly IList providers; - public EditorContext EditorContext { get; set; } + readonly EditorContext editorContext; + + public EditorContext EditorContext { + get { return editorContext; } + } - public EditorActionsProvider(ITextEditor editor, IList providers) + public EditorActionsProvider(EditorContext editorContext, IList providers) { - if (editor == null) - throw new ArgumentNullException("editor"); + if (editorContext == null) + throw new ArgumentNullException("editorContext"); if (providers == null) throw new ArgumentNullException("providers"); this.providers = providers; - - this.EditorContext = new EditorContext(editor); + this.editorContext = editorContext; } public Task> GetVisibleActionsAsync(CancellationToken cancellationToken) @@ -96,7 +96,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring if (providerForAction.TryGetValue(action, out provider)) { provider.IsVisible = isVisible; } - ContextActionsService.Instance.SaveProviderVisibilities(); + ContextActionsService.Instance.SaveProviderVisibilities(providers); } /// @@ -114,11 +114,13 @@ namespace ICSharpCode.SharpDevelop.Refactoring var providerList = providers.ToList(); var actions = await Task.WhenAll(providerList.Select(p => p.GetAvailableActionsAsync(this.EditorContext, cancellationToken))); for (int i = 0; i < actions.Length; i++) { - foreach (var action in actions[i]) { - providerForAction[action] = providerList[i]; + if (actions[i] != null) { + foreach (var action in actions[i]) { + providerForAction[action] = providerList[i]; + } } } - return actions.SelectMany(_ => _); + return actions.Where(a => a != null).SelectMany(a => a); } } } diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/EditorContext.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/EditorContext.cs index 902349e9d6..8470661a7b 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/EditorContext.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/EditorContext.cs @@ -2,6 +2,7 @@ // This code is distributed under the GNU LGPL (for details please see \doc\license.txt) using System; +using System.Collections.Concurrent; using System.Collections.Generic; using System.Diagnostics; using System.Linq; @@ -25,7 +26,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring /// public class EditorContext { - object syncRoot; + readonly object syncRoot = new object(); readonly ITextEditor editor; /// @@ -49,6 +50,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring public ITextSource TextSource { get; private set; } readonly int caretOffset; + readonly TextLocation caretLocation; /// /// Gets the offset of the caret, at the time when this editor context was created. @@ -58,7 +60,7 @@ namespace ICSharpCode.SharpDevelop.Refactoring } Task parseInformation; - ICompilation compilation; + Task compilation; /// /// Gets the ParseInformation for the file. @@ -78,14 +80,17 @@ namespace ICSharpCode.SharpDevelop.Refactoring /// public Task GetCompilationAsync() { - var c = LazyInitializer.EnsureInitialized(ref compilation, () => ParserService.GetCompilationForFile(this.FileName)); - return Task.FromResult(c); + lock (syncRoot) { + if (compilation == null) + compilation = Task.FromResult(ParserService.GetCompilationForFile(this.FileName)); + return compilation; + } } /// /// Caches values shared by Context actions. Used in . /// - readonly Dictionary cachedValues = new Dictionary(); + readonly ConcurrentDictionary cachedValues = new ConcurrentDictionary(); /// /// Fully initializes the EditorContext. @@ -96,36 +101,52 @@ namespace ICSharpCode.SharpDevelop.Refactoring throw new ArgumentNullException("editor"); this.editor = editor; caretOffset = editor.Caret.Offset; + caretLocation = editor.Caret.Location; this.FileName = editor.FileName; this.TextSource = editor.Document.CreateSnapshot(); } + Task currentSymbol; + /// /// The resolved symbol at editor caret. /// - public ResolveResult CurrentSymbol { - get { - throw new NotImplementedException(); + public Task GetCurrentSymbolAsync() + { + lock (syncRoot) { + if (currentSymbol == null) + currentSymbol = ResolveCurrentSymbolAsync(); + return currentSymbol; } } + async Task ResolveCurrentSymbolAsync() + { + var parser = ParserService.GetParser(this.FileName); + if (parser == null) + return null; + var parseInfo = await GetParseInformationAsync().ConfigureAwait(false); + if (parseInfo == null) + return null; + var compilation = await GetCompilationAsync().ConfigureAwait(false); + return await Task.Run(() => ParserService.ResolveAsync(this.FileName, caretLocation, this.TextSource, CancellationToken.None)).ConfigureAwait(false); + } + /// /// Gets cached value shared by context actions. Initializes a new value if not present. /// - public T GetCached() where T : IContextActionCache, new() + public Task GetCachedAsync(Func initializationFunc) { - lock (cachedValues) { - Type t = typeof(T); - if (cachedValues.ContainsKey(t)) { - return (T)cachedValues[t]; - } else { - T cached = new T(); - cached.Initialize(this); - cachedValues[t] = cached; - return cached; - } - } + return (Task)cachedValues.GetOrAdd(typeof(T), _ => Task.FromResult(initializationFunc(this))); + } + + /// + /// Gets cached value shared by context actions. Initializes a new value if not present. + /// + public Task GetCachedAsync(Func> initializationFunc) + { + return (Task)cachedValues.GetOrAdd(typeof(T), _ => initializationFunc(this)); } } } diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextAction.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextAction.cs index e791c44a2e..3c9237faab 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextAction.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextAction.cs @@ -12,9 +12,9 @@ namespace ICSharpCode.SharpDevelop.Refactoring public interface IContextAction { /// - /// Title displayed in the context actions popup. + /// Name displayed in the context actions popup. /// - string Title { get; } + string DisplayName { get; } /// /// Executes this action. Called when this action is selected from the context actions popup. /// diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextActionCache.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextActionCache.cs deleted file mode 100644 index 432cd83cb7..0000000000 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextActionCache.cs +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; - -namespace ICSharpCode.SharpDevelop.Refactoring -{ - /// - /// Temporary data shared by multiple Context actions. Stored in EditorContext.GetCached(). - /// - public interface IContextActionCache - { - void Initialize(EditorContext context); - } -} diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextActionsProvider.cs b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextActionsProvider.cs index e2a3b26af3..38ef0c7b03 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextActionsProvider.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/ContextActions/IContextActionsProvider.cs @@ -13,9 +13,19 @@ namespace ICSharpCode.SharpDevelop.Refactoring /// public interface IContextActionsProvider { + /// + /// Unique identifier for the context actions provider; used to hide context actions + /// that were disabled by the user. + /// + string ID { get; } + /// /// Gets actions available for current line of the editor. /// + /// + /// This method gets called on the GUI thread. The method implementation should use + /// 'Task.Run()' to move the implementation onto a background thread. + /// Task GetAvailableActionsAsync(EditorContext context, CancellationToken cancellationToken); /// diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/GoToClassAction.cs b/src/Main/Base/Project/Src/Services/RefactoringService/GoToClassAction.cs deleted file mode 100644 index df49ba13ab..0000000000 --- a/src/Main/Base/Project/Src/Services/RefactoringService/GoToClassAction.cs +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright (c) AlphaSierraPapa for the SharpDevelop Team (for details please see \doc\copyright.txt) -// This code is distributed under the GNU LGPL (for details please see \doc\license.txt) - -using System; -using ICSharpCode.NRefactory.TypeSystem; - -namespace ICSharpCode.SharpDevelop.Refactoring -{ - public class GoToClassAction : IContextAction - { - public string Title { get; private set; } - public ITypeDefinition Class { get; private set; } - - public GoToClassAction(ITypeDefinition c, string title) - { - if (c == null) - throw new ArgumentNullException("c"); - if (title == null) - throw new ArgumentNullException("title"); - this.Class = c; - this.Title = title; - } - - public void Execute(EditorContext context) - { - NavigationService.NavigateTo(this.Class); - } - } -} diff --git a/src/Main/Base/Project/Src/Services/RefactoringService/GoToMemberAction.cs b/src/Main/Base/Project/Src/Services/RefactoringService/GoToEntityAction.cs similarity index 54% rename from src/Main/Base/Project/Src/Services/RefactoringService/GoToMemberAction.cs rename to src/Main/Base/Project/Src/Services/RefactoringService/GoToEntityAction.cs index c5ac87ff72..f9dddd5e2e 100644 --- a/src/Main/Base/Project/Src/Services/RefactoringService/GoToMemberAction.cs +++ b/src/Main/Base/Project/Src/Services/RefactoringService/GoToEntityAction.cs @@ -7,24 +7,24 @@ using ICSharpCode.SharpDevelop.Parser; namespace ICSharpCode.SharpDevelop.Refactoring { - public class GoToMemberAction : IContextAction + public class GoToEntityAction : IContextAction { - public string Title { get; private set; } - public IMember Member { get; private set; } + public string DisplayName { get; private set; } + public IEntity Entity { get; private set; } - public GoToMemberAction(IMember member, IAmbience ambience) + public GoToEntityAction(IEntity entity, IAmbience ambience) { if (ambience == null) throw new ArgumentNullException("ambience"); - if (member == null) - throw new ArgumentNullException("member"); - this.Member = member; - this.Title = ambience.ConvertEntity(member); + if (entity == null) + throw new ArgumentNullException("entity"); + this.Entity = entity; + this.DisplayName = ambience.ConvertEntity(entity); } public void Execute(EditorContext context) { - NavigationService.NavigateTo(this.Member); + NavigationService.NavigateTo(this.Entity); } } }