File tree Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Expand file tree Collapse file tree 2 files changed +37
-0
lines changed Original file line number Diff line number Diff line change 51
51
* - added support for Option Compare Database.
52
52
* - added support for numbered lines (amended lineLabel rule).
53
53
* - added support for VBA 7.0 PtrSafe attribute for Declare statements.
54
+ * - implemented a fileNumber rule to locate identifier usages in file numbers.
54
55
*
55
56
*======================================================================================
56
57
*
Original file line number Diff line number Diff line change 2
2
using System . Collections . Generic ;
3
3
using System . Linq ;
4
4
using Antlr4 . Runtime ;
5
+ using Antlr4 . Runtime . Tree ;
5
6
using Rubberduck . Parsing . Grammar ;
6
7
7
8
namespace Rubberduck . Parsing . Symbols
@@ -44,6 +45,41 @@ private void SetCurrentScope(string name)
44
45
_currentScope = _qualifiedName . ProjectName + "." + _qualifiedName . ModuleName + "." + name ;
45
46
}
46
47
48
+ public override void EnterLiteral ( VBAParser . LiteralContext context )
49
+ {
50
+ var stringLiteral = context . STRINGLITERAL ( ) ;
51
+ if ( stringLiteral != null )
52
+ {
53
+ HandleEmptyStringLiteral ( stringLiteral ) ;
54
+ return ;
55
+ }
56
+
57
+ var numberLiteral = context . INTEGERLITERAL ( ) ;
58
+ if ( numberLiteral != null )
59
+ {
60
+ HandleNumberLiteral ( numberLiteral ) ;
61
+ return ;
62
+ }
63
+ }
64
+
65
+ private void HandleEmptyStringLiteral ( ITerminalNode stringLiteral )
66
+ {
67
+ if ( stringLiteral . Symbol . Text . Length == 2 ) // string literal only contains opening & closing quotes
68
+ {
69
+ // todo: track that value + implement an inspection that recommends replacing it with vbNullString (#363)
70
+ }
71
+ }
72
+
73
+ private void HandleNumberLiteral ( ITerminalNode numberLiteral )
74
+ {
75
+ // todo: verify whether the string representation ends with a type hint; flag as such if needed.
76
+
77
+ // todo: track that value + implement an inspection that checks for magic numbers (#359)
78
+ // also, don't do anything here if tree walker is currently in a ConstSubStmtContext
79
+
80
+
81
+ }
82
+
47
83
public override void EnterSubStmt ( VBAParser . SubStmtContext context )
48
84
{
49
85
SetCurrentScope ( context . ambiguousIdentifier ( ) . GetText ( ) ) ;
You can’t perform that action at this time.
0 commit comments