Skip to content

Commit e567400

Browse files
committed
Recover lost updates for SubstmtContext to ArgListContext
1 parent 728a8e4 commit e567400

17 files changed

+55
-55
lines changed

RetailCoder.VBE/Inspections/Concrete/Inspector.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ before moving them into the ParseTreeResults after qualifying them
139139

140140
if (argListWithOneByRefParamListener != null)
141141
{
142-
result.AddRange(argListWithOneByRefParamListener.Contexts.Select(context => new QualifiedContext<VBAParser.SubstmtContext>(componentTreePair.Key, context)));
142+
result.AddRange(argListWithOneByRefParamListener.Contexts.Select(context => new QualifiedContext<VBAParser.ArgListContext>(componentTreePair.Key, context)));
143143
}
144144
if (emptyStringLiteralListener != null)
145145
{

RetailCoder.VBE/Inspections/ProcedureCanBeWrittenAsFunctionInspection.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public ProcedureCanBeWrittenAsFunctionInspection(RubberduckParserState state)
2727
public override string Description { get { return InspectionsUI.ProcedureCanBeWrittenAsFunctionInspectionName; } }
2828
public override CodeInspectionType InspectionType { get { return CodeInspectionType.LanguageOpportunities; } }
2929

30-
public IEnumerable<QualifiedContext<VBAParser.SubstmtContext>> ParseTreeResults { get { return _results.OfType<QualifiedContext<VBAParser.SubstmtContext>>(); } }
30+
public IEnumerable<QualifiedContext<VBAParser.ArgListContext>> ParseTreeResults { get { return _results.OfType<QualifiedContext<VBAParser.ArgListContext>>(); } }
3131

3232
public void SetResults(IEnumerable<QualifiedContext> results)
3333
{
@@ -62,17 +62,17 @@ public override IEnumerable<InspectionResultBase> GetInspectionResults()
6262
.Select(result => new ProcedureCanBeWrittenAsFunctionInspectionResult(
6363
this,
6464
State,
65-
new QualifiedContext<VBAParser.SubstmtContext>(result.QualifiedName,result.Context.GetChild<VBAParser.SubstmtContext>(0)),
65+
new QualifiedContext<VBAParser.ArgListContext>(result.QualifiedName,result.Context.GetChild<VBAParser.ArgListContext>(0)),
6666
new QualifiedContext<VBAParser.SubStmtContext>(result.QualifiedName, (VBAParser.SubStmtContext)result.Context))
6767
);
6868
}
6969

7070
public class SingleByRefParamArgListListener : VBAParserBaseListener
7171
{
72-
private readonly IList<VBAParser.SubstmtContext> _contexts = new List<VBAParser.SubstmtContext>();
73-
public IEnumerable<VBAParser.SubstmtContext> Contexts { get { return _contexts; } }
72+
private readonly IList<VBAParser.ArgListContext> _contexts = new List<VBAParser.ArgListContext>();
73+
public IEnumerable<VBAParser.ArgListContext> Contexts { get { return _contexts; } }
7474

75-
public override void ExitArgList(VBAParser.SubstmtContext context)
75+
public override void ExitArgList(VBAParser.ArgListContext context)
7676
{
7777
var args = context.arg();
7878
if (args != null && args.All(a => a.PARAMARRAY() == null && a.LPAREN() == null) && args.Count(a => a.BYREF() != null || (a.BYREF() == null && a.BYVAL() == null)) == 1)

RetailCoder.VBE/Inspections/QuickFixes/DeclareAsExplicitVariantQuickFix.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,9 @@ private string DeclareExplicitVariant(VBAParser.ArgContext context, out string i
6868
var fix = string.Empty;
6969
foreach (var child in memberContext.children)
7070
{
71-
if (child is VBAParser.SubstmtContext)
71+
if (child is VBAParser.ArgListContext)
7272
{
73-
foreach (var tree in ((VBAParser.SubstmtContext) child).children)
73+
foreach (var tree in ((VBAParser.ArgListContext) child).children)
7474
{
7575
if (tree.Equals(context))
7676
{

RetailCoder.VBE/Inspections/QuickFixes/PassParameterByReferenceQuickFix.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ private ArgContext GetArgContextForIdentifier(ParserRuleContext context, string
3939
var procStmtCtxChildren = procStmtCtx.children;
4040
for (int idx = 0; idx < procStmtCtxChildren.Count; idx++)
4141
{
42-
if (procStmtCtxChildren[idx] is SubstmtContext)
42+
if (procStmtCtxChildren[idx] is ArgListContext)
4343
{
44-
var procStmtCtxChild = (SubstmtContext)procStmtCtxChildren[idx];
44+
var procStmtCtxChild = (ArgListContext)procStmtCtxChildren[idx];
4545
var arg = procStmtCtxChild.children;
4646
for (int idx2 = 0; idx2 < arg.Count; idx2++)
4747
{

RetailCoder.VBE/Inspections/Results/ProcedureCanBeWrittenAsFunctionInspectionResult.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ namespace Rubberduck.Inspections.Results
1616
public class ProcedureCanBeWrittenAsFunctionInspectionResult : InspectionResultBase
1717
{
1818
private IEnumerable<QuickFixBase> _quickFixes;
19-
private readonly QualifiedContext<VBAParser.SubstmtContext> _argListQualifiedContext;
19+
private readonly QualifiedContext<VBAParser.ArgListContext> _argListQualifiedContext;
2020
private readonly QualifiedContext<VBAParser.SubStmtContext> _subStmtQualifiedContext;
2121
private readonly RubberduckParserState _state;
2222

2323
public ProcedureCanBeWrittenAsFunctionInspectionResult(IInspection inspection, RubberduckParserState state,
24-
QualifiedContext<VBAParser.SubstmtContext> argListQualifiedContext, QualifiedContext<VBAParser.SubStmtContext> subStmtQualifiedContext)
24+
QualifiedContext<VBAParser.ArgListContext> argListQualifiedContext, QualifiedContext<VBAParser.SubStmtContext> subStmtQualifiedContext)
2525
: base(inspection, subStmtQualifiedContext.ModuleName, subStmtQualifiedContext.Context.subroutineName())
2626
{
2727
_target = state.AllUserDeclarations.Single(declaration => declaration.DeclarationType == DeclarationType.Procedure
@@ -57,14 +57,14 @@ public class ChangeProcedureToFunction : QuickFixBase
5757
public override bool CanFixInProject { get { return false; } }
5858

5959
private readonly RubberduckParserState _state;
60-
private readonly QualifiedContext<VBAParser.SubstmtContext> _argListQualifiedContext;
60+
private readonly QualifiedContext<VBAParser.ArgListContext> _argListQualifiedContext;
6161
private readonly QualifiedContext<VBAParser.SubStmtContext> _subStmtQualifiedContext;
6262
private readonly QualifiedContext<VBAParser.ArgContext> _argQualifiedContext;
6363

6464
private int _lineOffset;
6565

6666
public ChangeProcedureToFunction(RubberduckParserState state,
67-
QualifiedContext<VBAParser.SubstmtContext> argListQualifiedContext,
67+
QualifiedContext<VBAParser.ArgListContext> argListQualifiedContext,
6868
QualifiedContext<VBAParser.SubStmtContext> subStmtQualifiedContext,
6969
QualifiedSelection selection)
7070
: base(subStmtQualifiedContext.Context, selection, InspectionsUI.ProcedureShouldBeFunctionInspectionQuickFix)

RetailCoder.VBE/Navigation/CodeExplorer/CodeExplorerMemberViewModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ public override string NameWithSignature
117117
}
118118

119119
var context =
120-
_declaration.Context.children.FirstOrDefault(d => d is VBAParser.SubstmtContext) as VBAParser.SubstmtContext;
120+
_declaration.Context.children.FirstOrDefault(d => d is VBAParser.ArgListContext) as VBAParser.ArgListContext;
121121

122122
if (context == null)
123123
{

RetailCoder.VBE/Refactorings/IntroduceParameter/IntroduceParameterRefactoring.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ private void UpdateSignature(Declaration targetVariable)
142142
var functionDeclaration = _declarations.FindTarget(targetVariable.QualifiedSelection, ValidDeclarationTypes);
143143

144144
var proc = (dynamic)functionDeclaration.Context;
145-
var paramList = (VBAParser.SubstmtContext)proc.argList();
145+
var paramList = (VBAParser.ArgListContext)proc.argList();
146146
var module = functionDeclaration.QualifiedName.QualifiedModuleName.Component.CodeModule;
147147
{
148148
var interfaceImplementation = GetInterfaceImplementation(functionDeclaration);
@@ -182,14 +182,14 @@ private void UpdateSignature(Declaration targetVariable)
182182
private void UpdateSignature(Declaration targetMethod, Declaration targetVariable)
183183
{
184184
var proc = (dynamic)targetMethod.Context;
185-
var paramList = (VBAParser.SubstmtContext)proc.argList();
185+
var paramList = (VBAParser.ArgListContext)proc.argList();
186186
var module = targetMethod.QualifiedName.QualifiedModuleName.Component.CodeModule;
187187
{
188188
AddParameter(targetMethod, targetVariable, paramList, module);
189189
}
190190
}
191191

192-
private void AddParameter(Declaration targetMethod, Declaration targetVariable, VBAParser.SubstmtContext paramList, ICodeModule module)
192+
private void AddParameter(Declaration targetMethod, Declaration targetVariable, VBAParser.ArgListContext paramList, ICodeModule module)
193193
{
194194
var argList = paramList.arg();
195195
var lastParam = argList.LastOrDefault();

RetailCoder.VBE/Refactorings/RemoveParameters/RemoveParametersRefactoring.cs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ private string GetOldSignature(Declaration target)
279279
private void AdjustSignatures()
280280
{
281281
var proc = (dynamic)_model.TargetDeclaration.Context;
282-
var paramList = (VBAParser.SubstmtContext)proc.argList();
282+
var paramList = (VBAParser.ArgListContext)proc.argList();
283283
var module = _model.TargetDeclaration.QualifiedName.QualifiedModuleName.Component.CodeModule;
284284
{
285285
// if we are adjusting a property getter, check if we need to adjust the letter/setter too
@@ -336,23 +336,23 @@ private void AdjustSignatures(Declaration declaration)
336336
var proc = (dynamic)declaration.Context.Parent;
337337
var module = declaration.QualifiedName.QualifiedModuleName.Component.CodeModule;
338338
{
339-
VBAParser.SubstmtContext paramList;
339+
VBAParser.ArgListContext paramList;
340340

341341
if (declaration.DeclarationType == DeclarationType.PropertySet
342342
|| declaration.DeclarationType == DeclarationType.PropertyLet)
343343
{
344-
paramList = (VBAParser.SubstmtContext)proc.children[0].argList();
344+
paramList = (VBAParser.ArgListContext)proc.children[0].argList();
345345
}
346346
else
347347
{
348-
paramList = (VBAParser.SubstmtContext)proc.subStmt().argList();
348+
paramList = (VBAParser.ArgListContext)proc.subStmt().argList();
349349
}
350350

351351
RemoveSignatureParameters(declaration, paramList, module);
352352
}
353353
}
354354

355-
private void RemoveSignatureParameters(Declaration target, VBAParser.SubstmtContext paramList, ICodeModule module)
355+
private void RemoveSignatureParameters(Declaration target, VBAParser.ArgListContext paramList, ICodeModule module)
356356
{
357357
// property set/let have one more parameter than is listed in the getter parameters
358358
var nonRemovedParamNames = paramList.arg().Where((a, s) => s >= _model.Parameters.Count || !_model.Parameters[s].IsRemoved).Select(s => s.GetText());

RetailCoder.VBE/Refactorings/Rename/RenameRefactoring.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ private void RenameDeclaration(Declaration target, string newName)
335335

336336
if (target.DeclarationType == DeclarationType.Parameter)
337337
{
338-
var argList = (VBAParser.SubstmtContext)target.Context.Parent;
338+
var argList = (VBAParser.ArgListContext)target.Context.Parent;
339339
var lineNum = argList.GetSelection().LineCount;
340340

341341
// delete excess lines to prevent removing our own changes

RetailCoder.VBE/Refactorings/ReorderParameters/ReorderParametersModel.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ private void LoadParameters()
5050
Parameters.Clear();
5151

5252
var procedure = (dynamic)TargetDeclaration.Context;
53-
var argList = (VBAParser.SubstmtContext)procedure.argList();
53+
var argList = (VBAParser.ArgListContext)procedure.argList();
5454
var args = argList.arg();
5555

5656
var index = 0;

0 commit comments

Comments
 (0)