@@ -12,12 +12,6 @@ namespace Rubberduck.Refactorings.Common
1212{
1313 public static class VBAIdentifierValidator
1414 {
15- // NOTE: ForbiddenAttribute marks the tokens that don't compile as identifier names. Includes "bad but legal" names.
16- // TODO: Compare with the unfiltered tokens if a client needs to tell "bad but legal" from "bad and illegal" names.
17- private static readonly IEnumerable < string > ReservedIdentifiers =
18- typeof ( Tokens ) . GetFields ( )
19- . Where ( item => item . GetType ( ) . GetCustomAttributes < ForbiddenAttribute > ( ) . Any ( ) )
20- . Select ( item => item . GetValue ( null ) . ToString ( ) ) . ToArray ( ) ;
2115
2216 /// <summary>
2317 /// Predicate function determining if an identifier string's content will trigger a result for the UseMeaningfulNames inspection.
@@ -111,7 +105,7 @@ public static bool TryMatchInvalidIdentifierCriteria(string name, DeclarationTyp
111105 //Is a reserved identifier
112106 if ( ! declarationType . HasFlag ( DeclarationType . UserDefinedTypeMember ) )
113107 {
114- if ( ReservedIdentifiers . Contains ( name , StringComparer . InvariantCultureIgnoreCase ) )
108+ if ( Tokens . IllegalIdentifierNames . Contains ( name , StringComparer . InvariantCultureIgnoreCase ) )
115109 {
116110 criteriaMatchMessage = string . Format ( RubberduckUI . InvalidNameCriteria_IsReservedKeywordFormat , name ) ;
117111 return true ;
@@ -124,7 +118,7 @@ public static bool TryMatchInvalidIdentifierCriteria(string name, DeclarationTyp
124118
125119 //Name is not a reserved identifier, but when used as a UDTMember array declaration
126120 //it collides with the 'Name' Statement (Renames a disk file, directory, or folder)
127- var invalidUDTArrayIdentifiers = ReservedIdentifiers . Concat ( new List < string > ( ) { "Name" } ) ;
121+ var invalidUDTArrayIdentifiers = Tokens . IllegalIdentifierNames . Concat ( new List < string > ( ) { "Name" } ) ;
128122
129123 if ( invalidUDTArrayIdentifiers . Contains ( name , StringComparer . InvariantCultureIgnoreCase ) )
130124 {
@@ -182,7 +176,7 @@ public static IReadOnlyList<string> SatisfiedInvalidIdentifierCriteria(string na
182176 //Is a reserved identifier
183177 if ( ! declarationType . HasFlag ( DeclarationType . UserDefinedTypeMember ) )
184178 {
185- if ( ReservedIdentifiers . Contains ( name , StringComparer . InvariantCultureIgnoreCase ) )
179+ if ( Tokens . IllegalIdentifierNames . Contains ( name , StringComparer . InvariantCultureIgnoreCase ) )
186180 {
187181 criteriaMatchMessages . Add ( string . Format ( RubberduckUI . InvalidNameCriteria_IsReservedKeywordFormat , name ) ) ;
188182 }
@@ -194,7 +188,7 @@ public static IReadOnlyList<string> SatisfiedInvalidIdentifierCriteria(string na
194188
195189 //Name is not a reserved identifier, but when used as a UDTMember array declaration
196190 //it collides with the 'Name' Statement (Renames a disk file, directory, or folder)
197- var invalidUDTArrayIdentifiers = ReservedIdentifiers . Concat ( new List < string > ( ) { "Name" } ) ;
191+ var invalidUDTArrayIdentifiers = Tokens . IllegalIdentifierNames . Concat ( new List < string > ( ) { "Name" } ) ;
198192
199193 if ( invalidUDTArrayIdentifiers . Contains ( name , StringComparer . InvariantCultureIgnoreCase ) )
200194 {
0 commit comments