@@ -47,7 +47,7 @@ public SetObjectVariableQuickFix(IdentifierReference reference)
4747        public  override  void  Fix ( ) 
4848        { 
4949            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 ] ; 
5151
5252            var  letStatementLeftSide  =  Context . GetText ( ) ; 
5353            var  setStatementLeftSide  =  Tokens . Set  +  ' '  +  letStatementLeftSide ; 
@@ -86,19 +86,26 @@ public ObjectVariableNotSetInspection(RubberduckParserState state)
8686
8787        public  override  IEnumerable < InspectionResultBase >  GetInspectionResults ( ) 
8888        { 
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 
94100                . SelectMany ( declaration => 
95101                    declaration . References . Where ( reference => 
96102                    { 
97-                         var  k  =  reference . Context . parent . GetType ( ) ; 
98103                        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 ) ) ; 
102109        } 
103110    } 
104111} 
0 commit comments