@@ -47,7 +47,7 @@ public SetObjectVariableQuickFix(IdentifierReference reference)
47
47
public override void Fix ( )
48
48
{
49
49
var codeModule = Selection . QualifiedName . Component . CodeModule ;
50
- var codeLine = codeModule . get_Lines ( Selection . Selection . StartLine , 1 ) ;
50
+ var codeLine = codeModule . Lines [ Selection . Selection . StartLine , 1 ] ;
51
51
52
52
var letStatementLeftSide = Context . GetText ( ) ;
53
53
var setStatementLeftSide = Tokens . Set + ' ' + letStatementLeftSide ;
@@ -86,19 +86,26 @@ public ObjectVariableNotSetInspection(RubberduckParserState state)
86
86
87
87
public override IEnumerable < InspectionResultBase > GetInspectionResults ( )
88
88
{
89
- return State . AllUserDeclarations
90
- . Where ( item => ! ValueTypes . Contains ( item . AsTypeName )
91
- && ! item . IsSelfAssigned
92
- && ( item . DeclarationType == DeclarationType . Variable
93
- || item . DeclarationType == DeclarationType . Parameter ) )
89
+ var interestingDeclarations =
90
+ State . AllUserDeclarations . Where ( item =>
91
+ ! item . IsSelfAssigned &&
92
+ ! ValueTypes . Contains ( item . AsTypeName ) &&
93
+ ( item . AsTypeDeclaration == null ||
94
+ item . AsTypeDeclaration . DeclarationType != DeclarationType . Enumeration &&
95
+ item . AsTypeDeclaration . DeclarationType != DeclarationType . UserDefinedType ) &&
96
+ ( item . DeclarationType == DeclarationType . Variable ||
97
+ item . DeclarationType == DeclarationType . Parameter ) ) ;
98
+
99
+ var interestingReferences = interestingDeclarations
94
100
. SelectMany ( declaration =>
95
101
declaration . References . Where ( reference =>
96
102
{
97
- var k = reference . Context . parent . GetType ( ) ;
98
103
var setStmtContext = ParserRuleContextHelper . GetParent < VBAParser . LetStmtContext > ( reference . Context ) ;
99
- return setStmtContext != null && setStmtContext . LET ( ) == null ;
100
- } ) )
101
- . Select ( reference => new ObjectVariableNotSetInspectionResult ( this , reference ) ) ;
104
+ return reference . IsAssignment && setStmtContext != null && setStmtContext . LET ( ) == null ;
105
+ } ) ) ;
106
+
107
+
108
+ return interestingReferences . Select ( reference => new ObjectVariableNotSetInspectionResult ( this , reference ) ) ;
102
109
}
103
110
}
104
111
}
0 commit comments