Skip to content

Commit d52fe2e

Browse files
committed
Watch literals instead of let stmt's.
1 parent 35594c3 commit d52fe2e

File tree

2 files changed

+7
-9
lines changed

2 files changed

+7
-9
lines changed

RetailCoder.VBE/Inspections/EmptyStringLiteralInspectionResult.cs

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ public override void Fix()
3737
return;
3838
}
3939

40-
var letStmt = (VBAParser.LetStmtContext)Context;
40+
var literal = (VBAParser.LiteralContext)Context;
41+
var newCodeLines = module.Lines[literal.Start.Line, 1].Replace("\"\"", "vbNullString");
4142

42-
// remove line continuations to compare against context:
43-
var newCodeLines = module.Lines[letStmt.Stop.Line, 1].Replace("\"\"", "vbNullString");
44-
45-
module.ReplaceLine(letStmt.Stop.Line, newCodeLines);
43+
module.ReplaceLine(literal.Start.Line, newCodeLines);
4644
}
4745
}
4846
}

Rubberduck.Parsing/VBA/RubberduckParser.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,12 +239,12 @@ public override void EnterLetStmt(VBAParser.LetStmtContext context)
239239

240240
private class EmptyStringLiteralListener : VBABaseListener
241241
{
242-
private readonly IList<VBAParser.LetStmtContext> _contexts = new List<VBAParser.LetStmtContext>();
243-
public IEnumerable<VBAParser.LetStmtContext> Contexts { get { return _contexts; } }
242+
private readonly IList<VBAParser.LiteralContext> _contexts = new List<VBAParser.LiteralContext>();
243+
public IEnumerable<VBAParser.LiteralContext> Contexts { get { return _contexts; } }
244244

245-
public override void ExitLetStmt(VBAParser.LetStmtContext context)
245+
public override void ExitLiteral(VBAParser.LiteralContext context)
246246
{
247-
if (context.Stop.Text == "\"\"")
247+
if (context.STRINGLITERAL().GetText() == "\"\"")
248248
{
249249
_contexts.Add(context);
250250
}

0 commit comments

Comments
 (0)