@ -25,6 +25,7 @@ namespace SharpRefactoring.ContextActions
@@ -25,6 +25,7 @@ namespace SharpRefactoring.ContextActions
{
public IEnumerable < IContextAction > GetAvailableActions ( EditorASTProvider editorAST )
{
yield break ; // turned off temporarily
// Using CurrentLineAST is basically OK, but when the "class" keyword is on different line than class name,
// parsing only one line never tells us that we are looking at TypeDeclaration
@ -33,24 +34,34 @@ namespace SharpRefactoring.ContextActions
@@ -33,24 +34,34 @@ namespace SharpRefactoring.ContextActions
if ( currentLineAST = = null )
yield break ;
var editor = editorAST . Editor ;
var ambience = AmbienceService . GetCurrentAmbience ( ) ;
foreach ( var declaration in currentLineAST . FindTypeDeclarations ( ) ) {
if ( declaration . Type = = Ast . ClassType . Class | | declaration . Type = = Ast . ClassType . Struct ) {
var rr = ParserService . Resolve ( new ExpressionResult ( declaration . Name ) , editor . Caret . Line , editor . Caret . Column , editor . FileName , editor . Document . Text ) ;
var targetClass = rr . ResolvedType = = null ? null : rr . ResolvedType . GetUnderlyingClass ( ) ;
if ( targetClass ! = null ) {
foreach ( var implementAction in RefactoringService . GetImplementInterfaceActions ( targetClass , false ) ) {
var implementActionCopy = implementAction ;
yield return new DelegateAction {
Title = string . Format ( "Implement interface {0}" , ambience . Convert ( implementActionCopy . ClassToImplement ) ) ,
ExecuteAction = implementActionCopy . Execute
} ;
}
}
}
}
}
}
}
public class ImplementInterfaceAction : IContextAction
public class Delegat eAction : IContextAction
{
public string Title {
get { return "Dummy implement interface" ; }
}
public string Title { get ; set ; }
public System . Action ExecuteAction { get ; set ; }
public void Execute ( )
{
MessageBox . Show ( "Dummy implement interface" ) ;
if ( this . ExecuteAction ! = null )
this . ExecuteAction ( ) ;
}
}
}