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 1
1
using System . Collections . Generic ;
2
2
using System . Linq ;
3
3
using System . Runtime . InteropServices ;
4
+ using Antlr4 . Runtime ;
5
+ using Rubberduck . Parsing ;
6
+ using Rubberduck . Parsing . Grammar ;
4
7
using Rubberduck . Parsing . Symbols ;
5
8
using Rubberduck . Parsing . VBA ;
6
9
using Rubberduck . Refactorings . ExtractInterface ;
@@ -41,14 +44,27 @@ protected override bool EvaluateCanExecute(object parameter)
41
44
item . QualifiedName . QualifiedModuleName . Equals ( selection . Value . QualifiedName )
42
45
&& ModuleTypes . Contains ( item . DeclarationType ) ) ;
43
46
47
+ if ( interfaceClass == null )
48
+ {
49
+ return false ;
50
+ }
51
+
44
52
// interface class must have members to be implementable
45
53
var hasMembers = _state . AllUserDeclarations . Any ( item =>
46
54
item . DeclarationType . HasFlag ( DeclarationType . Member )
47
55
&& item . ParentDeclaration != null
48
56
&& 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 > ( ) ;
49
65
50
66
// true if active code pane is for a class/document/form module
51
- return interfaceClass != null && hasMembers ;
67
+ return ! context . Any ( ) ;
52
68
}
53
69
54
70
protected override void OnExecute ( object parameter )
You can’t perform that action at this time.
0 commit comments