File tree Expand file tree Collapse file tree 1 file changed +17
-1
lines changed 
RetailCoder.VBE/UI/Command/Refactorings Expand file tree Collapse file tree 1 file changed +17
-1
lines changed Original file line number Diff line number Diff line change 11using  System . Collections . Generic ; 
22using  System . Linq ; 
33using  System . Runtime . InteropServices ; 
4+ using  Antlr4 . Runtime ; 
5+ using  Rubberduck . Parsing ; 
6+ using  Rubberduck . Parsing . Grammar ; 
47using  Rubberduck . Parsing . Symbols ; 
58using  Rubberduck . Parsing . VBA ; 
69using  Rubberduck . Refactorings . ExtractInterface ; 
@@ -41,14 +44,27 @@ protected override bool EvaluateCanExecute(object parameter)
4144                item . QualifiedName . QualifiedModuleName . Equals ( selection . Value . QualifiedName ) 
4245                &&  ModuleTypes . Contains ( item . DeclarationType ) ) ; 
4346
47+             if  ( interfaceClass  ==  null ) 
48+             { 
49+                 return  false ; 
50+             } 
51+ 
4452            // interface class must have members to be implementable 
4553            var  hasMembers  =  _state . AllUserDeclarations . Any ( item =>  
4654                item . DeclarationType . HasFlag ( DeclarationType . Member )  
4755                &&  item . ParentDeclaration  !=  null  
4856                &&  item . ParentDeclaration . Equals ( interfaceClass ) ) ; 
57+             
58+             if  ( ! hasMembers ) 
59+             { 
60+                 return  false ; 
61+             } 
62+ 
63+             var  parseTree  =  _state . GetParseTree ( interfaceClass . QualifiedName . QualifiedModuleName ) ; 
64+             var  context  =  ( ( ParserRuleContext ) parseTree ) . FindChildren < VBAParser . ImplementsStmtContext > ( ) ; 
4965
5066            // true if active code pane is for a class/document/form module 
51-             return  interfaceClass   !=   null   &&   hasMembers ; 
67+             return  ! context . Any ( ) ; 
5268        } 
5369
5470        protected  override  void  OnExecute ( object  parameter ) 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments