Skip to content

Commit

Permalink
replaced ParserRuleContextHelper with ParserRuleContextExtensions calls
Browse files Browse the repository at this point in the history
  • Loading branch information
retailcoder committed Jan 22, 2018
1 parent 03b7431 commit 433b948
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
Expand Up @@ -4,6 +4,7 @@
using System.Linq;
using Rubberduck.Inspections.Abstract;
using Rubberduck.Inspections.Results;
using Rubberduck.Parsing;
using Rubberduck.Parsing.Grammar;
using Rubberduck.Parsing.Inspections.Abstract;
using Rubberduck.Parsing.Inspections.Resources;
Expand Down Expand Up @@ -55,15 +56,15 @@ private IEnumerable<IdentifierReference> InterestingReferences()
continue;
}

var setStmtContext = ParserRuleContextHelper.GetParent<VBAParser.SetStmtContext>(reference.Context);
var setStmtContext = reference.Context.GetAncestor<VBAParser.SetStmtContext>();
if (setStmtContext != null)
{
// assignment already has a Set keyword
// (but is it misplaced? ...hmmm... beyond the scope of *this* inspection though)
continue;
}

var letStmtContext = ParserRuleContextHelper.GetParent<VBAParser.LetStmtContext>(reference.Context);
var letStmtContext = reference.Context.GetAncestor<VBAParser.LetStmtContext>();
if (letStmtContext == null)
{
// we're probably in a For Each loop
Expand Down Expand Up @@ -127,7 +128,7 @@ private IEnumerable<IdentifierReference> InterestingReferences()
// todo resolve expression return type

var memberRefs = State.DeclarationFinder.IdentifierReferences(reference.ParentScoping.QualifiedName);
var lastRef = memberRefs.LastOrDefault(r => !Equals(r, reference) && ParserRuleContextHelper.GetParent<VBAParser.LetStmtContext>(r.Context) == letStmtContext);
var lastRef = memberRefs.LastOrDefault(r => !Equals(r, reference) && r.Context.GetAncestor<VBAParser.LetStmtContext>() == letStmtContext);
if (lastRef?.Declaration.AsTypeDeclaration?.DeclarationType.HasFlag(DeclarationType.ClassModule) ?? false)
{
// the last reference in the expression is referring to an object type
Expand Down
Expand Up @@ -112,7 +112,7 @@ private static bool ObjectOrVariantRequiresSetAssignment(IdentifierReference obj
}

//Variants can be assigned with or without 'Set' depending...
var letStmtContext = ParserRuleContextHelper.GetParent<VBAParser.LetStmtContext>(objectOrVariantRef.Context);
var letStmtContext = objectOrVariantRef.Context.GetAncestor<VBAParser.LetStmtContext>();

//A potential error is only possible for let statements: rset, lset and other type specific assignments are always let assignments;
//assignemts in for each loop statements are do not require the set keyword.
Expand Down

0 comments on commit 433b948

Please sign in to comment.