File tree Expand file tree Collapse file tree 8 files changed +1596
-1520
lines changed Expand file tree Collapse file tree 8 files changed +1596
-1520
lines changed Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change @@ -525,7 +525,7 @@ unrestrictedIdentifier : identifier | statementKeyword | markerKeyword;
525525identifier : untypedIdentifier | typedIdentifier;
526526untypedIdentifier : identifierValue;
527527typedIdentifier : identifierValue typeHint;
528- identifierValue : IDENTIFIER | keyword | foreignName;
528+ identifierValue : IDENTIFIER | keyword | foreignName | BF ;
529529foreignName : L_SQUARE_BRACKET foreignIdentifier* R_SQUARE_BRACKET ;
530530foreignIdentifier : ~(L_SQUARE_BRACKET | R_SQUARE_BRACKET ) | foreignName;
531531
Original file line number Diff line number Diff line change 88// </auto-generated>
99//------------------------------------------------------------------------------
1010
11- // Generated from C:\Work \Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
11+ // Generated from C:\Dev \Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
1212
1313// Unreachable code detected
1414#pragma warning disable 0162
Original file line number Diff line number Diff line change 88// </auto-generated>
99//------------------------------------------------------------------------------
1010
11- // Generated from C:\Work \Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
11+ // Generated from C:\Dev \Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
1212
1313// Unreachable code detected
1414#pragma warning disable 0162
Original file line number Diff line number Diff line change 88// </auto-generated>
99//------------------------------------------------------------------------------
1010
11- // Generated from C:\Work \Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
11+ // Generated from C:\Dev \Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
1212
1313// Unreachable code detected
1414#pragma warning disable 0162
Original file line number Diff line number Diff line change 88// </auto-generated>
99//------------------------------------------------------------------------------
1010
11- // Generated from C:\Work \Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
11+ // Generated from C:\Dev \Rubberduck\Rubberduck.Parsing\Grammar\VBAParser.g4 by ANTLR 4.3
1212
1313// Unreachable code detected
1414#pragma warning disable 0162
Original file line number Diff line number Diff line change 305305 <Compile Include =" VBA\VBAModuleParser.cs" />
306306 </ItemGroup >
307307 <ItemGroup >
308- <Antlr4 Include =" Grammar\VBAParser.g4" >
308+ <None Include =" Grammar\VBAParser.g4" >
309309 <Generator >MSBuild:Compile</Generator >
310310 <CustomToolNamespace >Rubberduck.Parsing.Grammar</CustomToolNamespace >
311311 <CopyToOutputDirectory >Always</CopyToOutputDirectory >
312- </Antlr4 >
312+ </None >
313313 <None Include =" packages.config" />
314314 <None Include =" Grammar\VBALexer.g4" >
315315 <Generator >MSBuild:Compile</Generator >
Original file line number Diff line number Diff line change @@ -2422,5 +2422,67 @@ End Sub
24222422
24232423 Assert . IsTrue ( declaration . References . ElementAt ( 0 ) . IsAssignment ) ;
24242424 }
2425+
2426+ //https://github.com/rubberduck-vba/Rubberduck/issues/2478
2427+ [ TestMethod ]
2428+ public void VariableNamedBfResolvesAsAVariable ( )
2429+ {
2430+ // arrange
2431+ var code = @"
2432+ Public Sub Test()
2433+ Dim bf As Integer
2434+ Debug.Print bf
2435+ End Sub
2436+ " ;
2437+ // act
2438+ var state = Resolve ( code ) ;
2439+
2440+ // assert
2441+ var declaration = state . AllUserDeclarations . SingleOrDefault ( item =>
2442+ item . DeclarationType == DeclarationType . Variable && item . IdentifierName == "bf" ) ;
2443+
2444+ Assert . IsNotNull ( declaration ) ;
2445+ }
2446+
2447+ //https://github.com/rubberduck-vba/Rubberduck/issues/2478
2448+ [ TestMethod ]
2449+ public void ProcedureNamedBfResolvesAsAProcedure ( )
2450+ {
2451+ // arrange
2452+ var code = @"
2453+ Public Sub Bf()
2454+ Debug.Print ""I'm cool with that""
2455+ End Sub
2456+ " ;
2457+ // act
2458+ var state = Resolve ( code ) ;
2459+
2460+ // assert
2461+ var declaration = state . AllUserDeclarations . SingleOrDefault ( item =>
2462+ item . DeclarationType == DeclarationType . Procedure && item . IdentifierName == "Bf" ) ;
2463+
2464+ Assert . IsNotNull ( declaration ) ;
2465+ }
2466+
2467+ //https://github.com/rubberduck-vba/Rubberduck/issues/2478
2468+ [ TestMethod ]
2469+ public void TypeNamedBfResolvesAsAType ( )
2470+ {
2471+ // arrange
2472+ var code = @"
2473+ Private Type Bf
2474+ b As Long
2475+ f As Long
2476+ End Type
2477+ " ;
2478+ // act
2479+ var state = Resolve ( code ) ;
2480+
2481+ // assert
2482+ var declaration = state . AllUserDeclarations . SingleOrDefault ( item =>
2483+ item . DeclarationType == DeclarationType . UserDefinedType && item . IdentifierName == "Bf" ) ;
2484+
2485+ Assert . IsNotNull ( declaration ) ;
2486+ }
24252487 }
24262488}
You can’t perform that action at this time.
0 commit comments