@@ -1092,8 +1092,7 @@ private Declaration FindProjectScopeDeclaration(string identifierName, Declarati
1092
1092
{
1093
1093
// the "$" in e.g. "UCase$" isn't picked up as part of the identifierName, so we need to add it manually:
1094
1094
var matches = _declarationFinder . MatchName ( identifierName ) . Where ( item =>
1095
- ( ! item . IsBuiltIn || item . IdentifierName == identifierName + ( hasStringQualifier ? "$" : string . Empty ) )
1096
- && item . ParentDeclaration != null && ( ( item . ParentDeclaration . DeclarationType == DeclarationType . Module
1095
+ item . ParentDeclaration != null && ( ( item . ParentDeclaration . DeclarationType == DeclarationType . Module
1097
1096
|| item . ParentDeclaration . HasPredeclaredId ) )
1098
1097
|| item . ParentScopeDeclaration . Equals ( localScope ) ) . ToList ( ) ;
1099
1098
@@ -1152,12 +1151,22 @@ private Declaration FindProjectScopeDeclaration(string identifierName, Declarati
1152
1151
1153
1152
Debug . WriteLine ( "Ambiguous match in '{0}': '{1}'" , localScope == null ? "(unknown)" : localScope . IdentifierName , identifierName ) ;
1154
1153
}
1155
- if ( temp . Count == 0 )
1156
- {
1157
- Debug . WriteLine ( "Unknown identifier in '{0}': '{1}'" , localScope == null ? "(unknown)" : localScope . IdentifierName , identifierName ) ;
1158
- }
1159
1154
}
1160
1155
1156
+ // VBA.Strings.Left function is actually called _B_var_Left;
1157
+ // VBA.Strings.Left$ is _B_str_Left.
1158
+ // same for all $-terminated functions.
1159
+ var surrogateName = hasStringQualifier
1160
+ ? "_B_str_" + identifierName
1161
+ : "_B_var_" + identifierName ;
1162
+
1163
+ matches = _declarationFinder . MatchName ( surrogateName ) . ToList ( ) ;
1164
+ if ( matches . Count == 1 )
1165
+ {
1166
+ return matches . Single ( ) ;
1167
+ }
1168
+
1169
+ Debug . WriteLine ( "Unknown identifier in '{0}': '{1}'" , localScope == null ? "(unknown)" : localScope . IdentifierName , identifierName ) ;
1161
1170
return null ;
1162
1171
}
1163
1172
0 commit comments