Skip to content

Commit 5cc554d

Browse files
Andrin Meierretailcoder
authored andcommitted
fix redim statement / type hints / wrong call statement tree (#1592)
1 parent 96b57ad commit 5cc554d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+4263
-4412
lines changed

RetailCoder.VBE/Inspections/ConvertToProcedureQuickFix.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Linq;
88
using System.Text.RegularExpressions;
99
using Microsoft.Vbe.Interop;
10+
using Rubberduck.Parsing.Symbols;
1011

1112
namespace Rubberduck.Inspections
1213
{
@@ -55,13 +56,13 @@ public override void Fix()
5556
: Tokens.Property;
5657

5758
string visibility = context.visibility() == null ? string.Empty : context.visibility().GetText() + ' ';
58-
string name = ' ' + functionName.identifier().identifierValue().GetText();
59-
bool hasTypeHint = functionName.identifier().typeHint() != null;
59+
string name = ' ' + Identifier.GetName(functionName.identifier());
60+
bool hasTypeHint = Identifier.GetTypeHintValue(functionName.identifier()) != null;
6061

6162
string args = context.argList().GetText();
6263
string asType = context.asTypeClause() == null ? string.Empty : ' ' + context.asTypeClause().GetText();
6364

64-
string oldSignature = visibility + token + name + (hasTypeHint ? functionName.identifier().typeHint().GetText() : string.Empty) + args + asType;
65+
string oldSignature = visibility + token + name + (hasTypeHint ? Identifier.GetTypeHintValue(functionName.identifier()) : string.Empty) + args + asType;
6566
string newSignature = visibility + Tokens.Sub + name + args;
6667

6768
string procedure = Context.GetText();

RetailCoder.VBE/Inspections/ObsoleteTypeHintInspectionResult.cs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using Rubberduck.Parsing.Grammar;
88
using Rubberduck.Parsing.Symbols;
99
using Rubberduck.VBEditor;
10+
using Rubberduck.Parsing.Symbols;
1011

1112
namespace Rubberduck.Inspections
1213
{
@@ -74,7 +75,7 @@ private void FixTypeHintUsage(string hint, CodeModule module, Selection selectio
7475

7576
if (isDeclaration && Context is VBAParser.FunctionStmtContext)
7677
{
77-
var typeHint = ((VBAParser.FunctionStmtContext)Context).functionName().identifier().typeHint();
78+
var typeHint = Identifier.GetTypeHintContext(((VBAParser.FunctionStmtContext)Context).functionName().identifier());
7879
var argList = ((VBAParser.FunctionStmtContext)Context).argList();
7980
var endLine = argList.Stop.Line;
8081
var endColumn = argList.Stop.Column;
@@ -86,7 +87,7 @@ private void FixTypeHintUsage(string hint, CodeModule module, Selection selectio
8687
}
8788
else if (isDeclaration && Context is VBAParser.PropertyGetStmtContext)
8889
{
89-
var typeHint = ((VBAParser.PropertyGetStmtContext)Context).functionName().identifier().typeHint();
90+
var typeHint = Identifier.GetTypeHintContext(((VBAParser.PropertyGetStmtContext)Context).functionName().identifier());
9091
var argList = ((VBAParser.PropertyGetStmtContext)Context).argList();
9192
var endLine = argList.Stop.Line;
9293
var endColumn = argList.Stop.Column;

RetailCoder.VBE/Inspections/ProcedureShouldBeFunctionInspectionResult.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Rubberduck.Parsing.Symbols;
77
using Rubberduck.Parsing.VBA;
88
using Rubberduck.VBEditor;
9+
using Rubberduck.Parsing.Symbols;
910

1011
namespace Rubberduck.Inspections
1112
{
@@ -115,7 +116,7 @@ private void UpdateSignature()
115116

116117
private void UpdateCalls()
117118
{
118-
var procedureName = _subStmtQualifiedContext.Context.subroutineName().identifier().identifierValue().GetText();
119+
var procedureName = Identifier.GetName(_subStmtQualifiedContext.Context.subroutineName().identifier());
119120

120121
var procedure =
121122
_state.AllDeclarations.SingleOrDefault(d =>

Rubberduck.Parsing/Binding/ArgumentList.cs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
using Rubberduck.Parsing.Symbols;
2-
using System;
3-
using System.Collections.Generic;
1+
using System.Collections.Generic;
42
using System.Linq;
53

64
namespace Rubberduck.Parsing.Binding

Rubberduck.Parsing/Binding/DefaultBindingContext.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ private IExpressionBinding VisitType(Declaration module, Declaration parent, Par
116116

117117
private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.SimpleNameExprContext expression, IBoundExpression withBlockVariable, StatementResolutionContext statementContext)
118118
{
119-
return new SimpleNameDefaultBinding(_declarationFinder, Declaration.GetProjectParent(parent), module, parent, expression, statementContext);
119+
return new SimpleNameDefaultBinding(_declarationFinder, Declaration.GetProjectParent(parent), module, parent, expression, Identifier.GetName(expression.identifier()), statementContext);
120120
}
121121

122122
private IExpressionBinding Visit(Declaration module, Declaration parent, VBAParser.MemberAccessExprContext expression, IBoundExpression withBlockVariable, StatementResolutionContext statementContext)

Rubberduck.Parsing/Binding/MemberAccessDefaultBinding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public MemberAccessDefaultBinding(
3333
parent,
3434
expression,
3535
null,
36-
ExpressionName.GetName(expression.unrestrictedIdentifier()),
36+
Identifier.GetName(expression.unrestrictedIdentifier()),
3737
statementContext,
3838
unrestrictedNameContext)
3939
{

Rubberduck.Parsing/Binding/MemberAccessProcedurePointerBinding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public IBoundExpression Resolve()
4040
{
4141
return lExpression;
4242
}
43-
string name = ExpressionName.GetName(_expression.unrestrictedIdentifier());
43+
string name = Identifier.GetName(_expression.unrestrictedIdentifier());
4444
if (lExpression.Classification != ExpressionClassification.ProceduralModule)
4545
{
4646
return null;

Rubberduck.Parsing/Binding/MemberAccessTypeBinding.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ public IBoundExpression Resolve()
4848
{
4949
return lExpression;
5050
}
51-
string unrestrictedName = ExpressionName.GetName(_expression.unrestrictedIdentifier());
51+
string unrestrictedName = Identifier.GetName(_expression.unrestrictedIdentifier());
5252
boundExpression = ResolveLExpressionIsProject(lExpression, unrestrictedName);
5353
if (boundExpression != null)
5454
{

0 commit comments

Comments
 (0)