using System;
namespace ICSharpCode.NRefactory.CSharp.Refactoring
{
///
/// A specialized code action creates a code action assoziated with one special type of ast nodes.
///
public abstract class SpecializedCodeAction : ICodeActionProvider where T : AstNode
{
///
/// Gets the action for the specified ast node.
///
///
/// The code action. May return null, if no action can be provided.
///
///
/// The refactoring conext.
///
///
/// The AstNode it's ensured that the node is always != null, if called.
///
protected abstract CodeAction GetAction(RefactoringContext context, T node);
#region ICodeActionProvider implementation
public System.Collections.Generic.IEnumerable GetActions(RefactoringContext context)
{
var node = context.GetNode();
if (node == null)
yield break;
var action = GetAction(context, node);
if (action == null)
yield break;
yield return action;
}
#endregion
}
}