@@ -93,23 +93,17 @@ public static bool RequiresSetAssignment(IdentifierReference reference, IDeclara
93
93
}
94
94
95
95
// todo resolve expression return type
96
+ var project = Declaration . GetProjectParent ( reference . ParentScoping ) ;
97
+ var module = Declaration . GetModuleParent ( reference . ParentScoping ) ;
96
98
97
-
98
- //var memberRefs = declarationFinderProvider.DeclarationFinder.IdentifierReferences(reference.ParentScoping.QualifiedName);
99
- //var lastRef = memberRefs.LastOrDefault(r => r.IsAssignment && !Equals(r, reference) && r.Context.GetAncestor<VBAParser.LetStmtContext>() == letStmtContext);
100
- //if (lastRef?.Declaration.AsTypeDeclaration?.DeclarationType.HasFlag(DeclarationType.ClassModule) ?? false)
101
- //{
102
- // // the last reference in the expression is referring to an object type
103
- // return true;
104
- //}
105
- //if (lastRef?.Declaration.AsTypeName == Tokens.Object)
106
- //{
107
- // return true;
108
- //}
99
+ var simpleName = expression . GetDescendent < VBAParser . SimpleNameExprContext > ( ) ;
100
+ if ( simpleName != null )
101
+ {
102
+ return declarationFinderProvider . DeclarationFinder . MatchName ( simpleName . identifier ( ) . GetText ( ) )
103
+ . Any ( d => AccessibilityCheck . IsAccessible ( project , module , reference . ParentScoping , d ) && d . IsObject ) ;
104
+ }
109
105
110
106
// is the reference referring to something else in scope that's a object?
111
- var project = Declaration . GetProjectParent ( reference . ParentScoping ) ;
112
- var module = Declaration . GetModuleParent ( reference . ParentScoping ) ;
113
107
return declarationFinderProvider . DeclarationFinder . MatchName ( expression . GetText ( ) )
114
108
. Any ( decl => ( decl . DeclarationType . HasFlag ( DeclarationType . ClassModule ) || Tokens . Object . Equals ( decl . AsTypeName ) )
115
109
&& AccessibilityCheck . IsAccessible ( project , module , reference . ParentScoping , decl ) ) ;
0 commit comments