Skip to content

Commit 7a21154

Browse files
authored
Merge pull request #4924 from MDoerner/MakeResolverNonDynamic
Removes dymanic bindings from resolver.
2 parents 63e529a + ca691d5 commit 7a21154

16 files changed

+356
-368
lines changed

Rubberduck.Core/Navigation/RegexSearchReplace/RegexSearchReplace.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Text.RegularExpressions;
5+
using Antlr4.Runtime;
56
using Rubberduck.Common;
67
using Rubberduck.Parsing;
78
using Rubberduck.Parsing.Symbols;
@@ -137,7 +138,15 @@ private List<RegexSearchResult> SearchCurrentBlock(string searchPattern)
137138
var results = GetResultsFromModule(module, searchPattern);
138139

139140
var qualifiedSelection = pane.GetQualifiedSelection();
140-
dynamic block = state.AllDeclarations.FindTarget(qualifiedSelection.Value, declarationTypes).Context
141+
142+
if (!qualifiedSelection.HasValue)
143+
{
144+
return new List<RegexSearchResult>();
145+
}
146+
147+
var block = (ParserRuleContext)state.AllDeclarations
148+
.FindTarget(qualifiedSelection.Value, declarationTypes)
149+
.Context
141150
.Parent;
142151
var selection = new Selection(block.Start.Line, block.Start.Column, block.Stop.Line,
143152
block.Stop.Column);

Rubberduck.Parsing/Binding/BindingService.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,7 @@ public IBoundExpression ResolveDefault(Declaration module, Declaration parent, P
4242
public IBoundExpression ResolveType(Declaration module, Declaration parent, ParserRuleContext expression)
4343
{
4444
var context = expression;
45-
var opContext = expression as VBAParser.RelationalOpContext;
46-
if (opContext != null && opContext.Parent is VBAParser.ComplexTypeContext)
45+
if (context is VBAParser.RelationalOpContext opContext && opContext.Parent is VBAParser.ComplexTypeContext)
4746
{
4847
context = opContext.GetChild<VBAParser.LExprContext>(0);
4948
}

Rubberduck.Parsing/Binding/DefaultBindingContext.cs

Lines changed: 157 additions & 162 deletions
Large diffs are not rendered by default.

Rubberduck.Parsing/Binding/Expressions/IndexExpression.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ namespace Rubberduck.Parsing.Binding
55
{
66
public sealed class IndexExpression : BoundExpression
77
{
8-
private readonly IBoundExpression _lExpression;
9-
private readonly ArgumentList _argumentList;
10-
118
public IndexExpression(
129
Declaration referencedDeclaration,
1310
ExpressionClassification classification,
@@ -16,24 +13,11 @@ public IndexExpression(
1613
ArgumentList argumentList)
1714
: base(referencedDeclaration, classification, context)
1815
{
19-
_lExpression = lExpression;
20-
_argumentList = argumentList;
21-
}
22-
23-
public IBoundExpression LExpression
24-
{
25-
get
26-
{
27-
return _lExpression;
28-
}
16+
LExpression = lExpression;
17+
ArgumentList = argumentList;
2918
}
3019

31-
public ArgumentList ArgumentList
32-
{
33-
get
34-
{
35-
return _argumentList;
36-
}
37-
}
20+
public IBoundExpression LExpression { get; }
21+
public ArgumentList ArgumentList { get; }
3822
}
3923
}

Rubberduck.Parsing/Binding/Expressions/MemberAccessExpression.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,6 @@ namespace Rubberduck.Parsing.Binding
55
{
66
public sealed class MemberAccessExpression : BoundExpression
77
{
8-
private readonly IBoundExpression _lExpression;
9-
private readonly ParserRuleContext _unrestrictedNameContext;
10-
118
public MemberAccessExpression(
129
Declaration referencedDeclaration,
1310
ExpressionClassification classification,
@@ -16,24 +13,11 @@ public MemberAccessExpression(
1613
IBoundExpression lExpression)
1714
: base(referencedDeclaration, classification, context)
1815
{
19-
_lExpression = lExpression;
20-
_unrestrictedNameContext = unrestrictedNameContext;
21-
}
22-
23-
public IBoundExpression LExpression
24-
{
25-
get
26-
{
27-
return _lExpression;
28-
}
16+
LExpression = lExpression;
17+
UnrestrictedNameContext = unrestrictedNameContext;
2918
}
3019

31-
public ParserRuleContext UnrestrictedNameContext
32-
{
33-
get
34-
{
35-
return _unrestrictedNameContext;
36-
}
37-
}
20+
public IBoundExpression LExpression { get; }
21+
public ParserRuleContext UnrestrictedNameContext { get; }
3822
}
3923
}

Rubberduck.Parsing/Binding/Expressions/NewExpression.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,24 +5,16 @@ namespace Rubberduck.Parsing.Binding
55
{
66
public sealed class NewExpression : BoundExpression
77
{
8-
private readonly IBoundExpression _typeExpression;
9-
108
public NewExpression(
119
Declaration referencedDeclaration,
1210
ParserRuleContext context,
1311
IBoundExpression typeExpression)
1412
// Marked as Variable instead of Value to integrate into rest of binding process.
1513
: base(referencedDeclaration, ExpressionClassification.Variable, context)
1614
{
17-
_typeExpression = typeExpression;
15+
TypeExpression = typeExpression;
1816
}
1917

20-
public IBoundExpression TypeExpression
21-
{
22-
get
23-
{
24-
return _typeExpression;
25-
}
26-
}
18+
public IBoundExpression TypeExpression { get; }
2719
}
2820
}

Rubberduck.Parsing/Binding/Expressions/ParenthesizedExpression.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,15 @@ namespace Rubberduck.Parsing.Binding
55
{
66
public sealed class ParenthesizedExpression : BoundExpression
77
{
8-
private readonly IBoundExpression _expression;
9-
108
public ParenthesizedExpression(
119
Declaration referencedDeclaration,
1210
ParserRuleContext context,
1311
IBoundExpression expression)
1412
: base(referencedDeclaration, ExpressionClassification.Value, context)
1513
{
16-
_expression = expression;
14+
Expression = expression;
1715
}
1816

19-
public IBoundExpression Expression
20-
{
21-
get
22-
{
23-
return _expression;
24-
}
25-
}
17+
public IBoundExpression Expression { get; }
2618
}
2719
}

Rubberduck.Parsing/Binding/Expressions/ResolutionFailedExpression.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,9 @@ public sealed class ResolutionFailedExpression : BoundExpression
88

99
public ResolutionFailedExpression()
1010
: base(null, ExpressionClassification.ResolutionFailed, null)
11-
{
12-
_successfullyResolvedExpressions = new List<IBoundExpression>();
13-
}
11+
{}
1412

15-
public IReadOnlyList<IBoundExpression> SuccessfullyResolvedExpressions
16-
{
17-
get
18-
{
19-
return _successfullyResolvedExpressions;
20-
}
21-
}
13+
public IReadOnlyList<IBoundExpression> SuccessfullyResolvedExpressions => _successfullyResolvedExpressions;
2214

2315
public void AddSuccessfullyResolvedExpression(IBoundExpression expression)
2416
{

Rubberduck.Parsing/Binding/Expressions/TypeOfIsExpression.cs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,18 @@ namespace Rubberduck.Parsing.Binding
55
{
66
public sealed class TypeOfIsExpression : BoundExpression
77
{
8-
private readonly IBoundExpression _expression;
9-
private readonly IBoundExpression _typeExpression;
10-
118
public TypeOfIsExpression(
129
Declaration referencedDeclaration,
1310
ParserRuleContext context,
1411
IBoundExpression expression,
1512
IBoundExpression typeExpression)
1613
: base(referencedDeclaration, ExpressionClassification.Value, context)
1714
{
18-
_expression = expression;
19-
_typeExpression = typeExpression;
20-
}
21-
22-
public IBoundExpression Expression
23-
{
24-
get
25-
{
26-
return _expression;
27-
}
15+
Expression = expression;
16+
TypeExpression = typeExpression;
2817
}
2918

30-
public IBoundExpression TypeExpression
31-
{
32-
get
33-
{
34-
return _typeExpression;
35-
}
36-
}
19+
public IBoundExpression Expression { get; }
20+
public IBoundExpression TypeExpression { get; }
3721
}
3822
}

Rubberduck.Parsing/Binding/Expressions/UnaryOpExpression.cs

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,23 +5,15 @@ namespace Rubberduck.Parsing.Binding
55
{
66
public sealed class UnaryOpExpression : BoundExpression
77
{
8-
private readonly IBoundExpression _expr;
9-
108
public UnaryOpExpression(
119
Declaration referencedDeclaration,
1210
ParserRuleContext context,
1311
IBoundExpression expr)
1412
: base(referencedDeclaration, ExpressionClassification.Value, context)
1513
{
16-
_expr = expr;
14+
Expr = expr;
1715
}
1816

19-
public IBoundExpression Expr
20-
{
21-
get
22-
{
23-
return _expr;
24-
}
25-
}
17+
public IBoundExpression Expr { get; }
2618
}
2719
}

0 commit comments

Comments
 (0)