/
IdentifierReferenceResolver.cs
824 lines (756 loc) · 31.1 KB
/
IdentifierReferenceResolver.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
using Antlr4.Runtime;
using NLog;
using Rubberduck.Parsing.Annotations;
using Rubberduck.Parsing.Binding;
using Rubberduck.Parsing.Grammar;
using Rubberduck.Parsing.Symbols.DeclarationLoaders;
using Rubberduck.VBEditor;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using Rubberduck.Parsing.VBA;
namespace Rubberduck.Parsing.Symbols
{
public sealed class IdentifierReferenceResolver
{
private readonly DeclarationFinder _declarationFinder;
private readonly QualifiedModuleName _qualifiedModuleName;
private readonly Stack<IBoundExpression> _withBlockExpressions;
private readonly Declaration _moduleDeclaration;
private Declaration _currentScope;
private Declaration _currentParent;
private readonly BindingService _bindingService;
private readonly BoundExpressionVisitor _boundExpressionVisitor;
private readonly AnnotationService _annotationService;
private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
public IdentifierReferenceResolver(QualifiedModuleName qualifiedModuleName, DeclarationFinder finder)
{
_declarationFinder = finder;
_qualifiedModuleName = qualifiedModuleName;
_withBlockExpressions = new Stack<IBoundExpression>();
_moduleDeclaration = finder.MatchName(_qualifiedModuleName.ComponentName)
.SingleOrDefault(item =>
(item.DeclarationType == DeclarationType.ClassModule ||
item.DeclarationType == DeclarationType.ProceduralModule)
&& item.QualifiedName.QualifiedModuleName.Equals(_qualifiedModuleName));
SetCurrentScope();
var typeBindingContext = new TypeBindingContext(_declarationFinder);
var procedurePointerBindingContext = new ProcedurePointerBindingContext(_declarationFinder);
_bindingService = new BindingService(
_declarationFinder,
new DefaultBindingContext(_declarationFinder, typeBindingContext, procedurePointerBindingContext),
typeBindingContext,
procedurePointerBindingContext);
_annotationService = new AnnotationService(_declarationFinder);
_boundExpressionVisitor = new BoundExpressionVisitor(_annotationService);
}
public void SetCurrentScope()
{
_currentScope = _moduleDeclaration;
_currentParent = _moduleDeclaration;
}
public void SetCurrentScope(string memberName, DeclarationType type)
{
Logger.Trace("Setting current scope: {0} ({1}) in thread {2}", memberName, type,
Thread.CurrentThread.ManagedThreadId);
_currentParent = _declarationFinder.MatchName(memberName).SingleOrDefault(item =>
item.QualifiedName.QualifiedModuleName == _qualifiedModuleName && item.DeclarationType == type);
_currentScope = _declarationFinder.MatchName(memberName).SingleOrDefault(item =>
item.QualifiedName.QualifiedModuleName == _qualifiedModuleName && item.DeclarationType == type) ??
_moduleDeclaration;
Logger.Trace("Current scope is now {0} in thread {1}",
_currentScope == null ? "null" : _currentScope.IdentifierName, Thread.CurrentThread.ManagedThreadId);
}
public void EnterWithBlock(VBAParser.WithStmtContext context)
{
var boundExpression = _bindingService.ResolveDefault(
_moduleDeclaration,
_currentParent,
context.expression(),
GetInnerMostWithExpression(),
StatementResolutionContext.Undefined);
_boundExpressionVisitor.AddIdentifierReferences(boundExpression, _qualifiedModuleName, _currentScope, _currentParent);
// note: pushes null if unresolved
_withBlockExpressions.Push(boundExpression);
}
private IBoundExpression GetInnerMostWithExpression()
{
if (_withBlockExpressions.Any())
{
return _withBlockExpressions.Peek();
}
return null;
}
public void ExitWithBlock()
{
_withBlockExpressions.Pop();
}
public void Resolve(VBAParser.ArgDefaultValueContext context)
{
var expression = context.expression();
if (expression == null)
{
return;
}
ResolveDefault(expression);
}
public void Resolve(VBAParser.ArrayDimContext context)
{
if (context.boundsList() == null)
{
return;
}
foreach (var dimSpec in context.boundsList().dimSpec())
{
if (dimSpec.lowerBound() != null)
{
ResolveDefault(dimSpec.lowerBound().constantExpression().expression());
}
ResolveDefault(dimSpec.upperBound().constantExpression().expression());
}
}
public void Resolve(VBAParser.OnErrorStmtContext context)
{
if (context.expression() == null)
{
return;
}
ResolveLabel(context.expression(), context.expression().GetText());
}
public void Resolve(VBAParser.ErrorStmtContext context)
{
ResolveDefault(context.expression());
}
private void ResolveLabel(ParserRuleContext context, string label)
{
var labelDeclaration = _bindingService.ResolveGoTo(_currentParent, label);
if (labelDeclaration != null)
{
var callSiteContext = context;
var identifier = context.GetText();
var callee = labelDeclaration;
labelDeclaration.AddReference(
_qualifiedModuleName,
_currentScope,
_currentParent,
callSiteContext,
identifier,
callee,
callSiteContext.GetSelection(),
_annotationService.FindAnnotations(_qualifiedModuleName, callSiteContext.GetSelection().StartLine));
}
}
private void ResolveDefault(
ParserRuleContext expression,
StatementResolutionContext statementContext = StatementResolutionContext.Undefined,
bool isAssignmentTarget = false,
bool hasExplicitLetStatement = false,
bool isSetAssignment = false)
{
var withExpression = GetInnerMostWithExpression();
var boundExpression = _bindingService.ResolveDefault(
_moduleDeclaration,
_currentParent,
expression,
withExpression,
statementContext);
if (boundExpression.Classification == ExpressionClassification.ResolutionFailed)
{
var lexpression = expression as VBAParser.LExpressionContext
?? expression.GetChild<VBAParser.LExpressionContext>(0)
?? (expression as VBAParser.LExprContext
?? expression.GetChild<VBAParser.LExprContext>(0))?.lExpression();
if (lexpression != null)
{
_declarationFinder.AddUnboundContext(_currentParent, lexpression, withExpression);
}
else
{
Logger.Warn(
$"Default Context: Failed to resolve {expression.GetText()}. Binding as much as we can.");
}
}
var hasDefaultMember = false;
if (boundExpression.ReferencedDeclaration != null
&& boundExpression.ReferencedDeclaration.DeclarationType != DeclarationType.Project
&& boundExpression.ReferencedDeclaration.AsTypeDeclaration != null)
{
var module = boundExpression.ReferencedDeclaration.AsTypeDeclaration;
var members = _declarationFinder.Members(module);
hasDefaultMember = members.Any(m => m.Attributes.Any(a => a.Name == $"{m.IdentifierName}.VB_UserMemId" && a.Values.SingleOrDefault() == "0"));
}
_boundExpressionVisitor.AddIdentifierReferences(boundExpression, _qualifiedModuleName, _currentScope, _currentParent, (!hasDefaultMember || isSetAssignment) && isAssignmentTarget, hasExplicitLetStatement);
}
private void ResolveType(ParserRuleContext expression)
{
var boundExpression = _bindingService.ResolveType(_moduleDeclaration, _currentParent, expression);
if (boundExpression.Classification == ExpressionClassification.ResolutionFailed)
{
Logger.Warn(
string.Format(
"Type Context: Failed to resolve {0}. Binding as much as we can.",
expression.GetText()));
}
_boundExpressionVisitor.AddIdentifierReferences(boundExpression, _qualifiedModuleName, _currentScope, _currentParent);
}
public void Resolve(VBAParser.GoToStmtContext context)
{
ResolveLabel(context.expression(), context.expression().GetText());
}
public void Resolve(VBAParser.OnGoToStmtContext context)
{
ResolveDefault(context.expression()[0]);
for (int labelIndex = 1; labelIndex < context.expression().Count; labelIndex++)
{
ResolveLabel(context.expression()[labelIndex], context.expression()[labelIndex].GetText());
}
}
public void Resolve(VBAParser.GoSubStmtContext context)
{
ResolveLabel(context.expression(), context.expression().GetText());
}
public void Resolve(VBAParser.OnGoSubStmtContext context)
{
ResolveDefault(context.expression()[0]);
for (int labelIndex = 1; labelIndex < context.expression().Count; labelIndex++)
{
ResolveLabel(context.expression()[labelIndex], context.expression()[labelIndex].GetText());
}
}
public void Resolve(VBAParser.RedimStmtContext context)
{
// TODO: Create local variable if no match for redim variable declaration.
foreach (var redimVariableDeclaration in context.redimDeclarationList().redimVariableDeclaration())
{
// We treat redim statements as index expressions to make it SLL.
var lExpr = ((VBAParser.LExprContext)redimVariableDeclaration.expression()).lExpression();
var indexExpr = (VBAParser.IndexExprContext)lExpr;
// The lexpression is the array that is being resized.
// We can't treat it as a normal index expression because the semantics are different.
// It's not actually a function call but a special statement.
ResolveDefault(indexExpr.lExpression());
var argumentList = indexExpr.argumentList();
if (argumentList.argument() != null)
{
foreach (var positionalArgument in argumentList.argument())
{
if (positionalArgument.positionalArgument() != null)
{
ResolveRedimArgument(positionalArgument.positionalArgument().argumentExpression());
}
}
}
}
}
private void ResolveRedimArgument(VBAParser.ArgumentExpressionContext argument)
{
// Redim statements can either have "normal" positional argument expressions or lower + upper bounds arguments.
if (argument.lowerBoundArgumentExpression() != null)
{
ResolveDefault(argument.lowerBoundArgumentExpression().expression());
ResolveDefault(argument.upperBoundArgumentExpression().expression());
}
else
{
ResolveDefault(argument.expression());
}
}
public void Resolve(VBAParser.WhileWendStmtContext context)
{
ResolveDefault(context.expression());
}
public void Resolve(VBAParser.DoLoopStmtContext context)
{
if (context.expression() == null)
{
return;
}
ResolveDefault(context.expression());
}
public void Resolve(VBAParser.IfStmtContext context)
{
ResolveDefault(context.booleanExpression());
if (context.elseIfBlock() != null)
{
foreach (var elseIfBlock in context.elseIfBlock())
{
ResolveDefault(elseIfBlock.booleanExpression());
}
}
}
public void Resolve(VBAParser.SingleLineIfStmtContext context)
{
// The listOrLabel rule could be resolved separately but since it's such a special case, only appearing in
// single-line-if-statements, we do it here for better understanding.
if (context.ifWithEmptyThen() != null)
{
ResolveDefault(context.ifWithEmptyThen().booleanExpression());
ResolveListOrLabel(context.ifWithEmptyThen().singleLineElseClause().listOrLabel());
}
else
{
ResolveDefault(context.ifWithNonEmptyThen().booleanExpression());
ResolveListOrLabel(context.ifWithNonEmptyThen().listOrLabel());
if (context.ifWithNonEmptyThen().singleLineElseClause() != null)
{
ResolveListOrLabel(context.ifWithNonEmptyThen().singleLineElseClause().listOrLabel());
}
}
}
private void ResolveListOrLabel(VBAParser.ListOrLabelContext listOrLabel)
{
if (listOrLabel?.lineNumberLabel() == null)
{
return;
}
ResolveLabel(listOrLabel.lineNumberLabel(), listOrLabel.lineNumberLabel().GetText());
}
public void Resolve(VBAParser.SelectCaseStmtContext context)
{
ResolveDefault(context.selectExpression().expression());
if (context.caseClause() == null)
{
return;
}
foreach (var caseClause in context.caseClause())
{
foreach (var rangeClause in caseClause.rangeClause())
{
if (rangeClause.expression() != null)
{
ResolveDefault(rangeClause.expression());
}
else
{
ResolveDefault(rangeClause.selectStartValue().expression());
ResolveDefault(rangeClause.selectEndValue().expression());
}
}
}
}
public void Resolve(VBAParser.LetStmtContext context)
{
var letStatement = context.LET();
ResolveDefault(
context.lExpression(),
StatementResolutionContext.LetStatement,
true,
letStatement != null,
false);
ResolveDefault(context.expression());
}
public void Resolve(VBAParser.SetStmtContext context)
{
ResolveDefault(
context.lExpression(),
StatementResolutionContext.SetStatement,
true,
false,
true);
ResolveDefault(context.expression());
}
public void Resolve(VBAParser.CallStmtContext context)
{
ResolveDefault(context);
}
public void Resolve(VBAParser.ConstStmtContext context)
{
foreach (var constStmt in context.constSubStmt())
{
ResolveDefault(constStmt.expression());
}
}
public void Resolve(VBAParser.EraseStmtContext context)
{
foreach (var expr in context.expression())
{
ResolveDefault(expr);
}
}
public void Resolve(VBAParser.NameStmtContext context)
{
foreach (var expr in context.expression())
{
ResolveDefault(expr);
}
}
private void ResolveFileNumber(VBAParser.FileNumberContext fileNumber)
{
if (fileNumber.markedFileNumber() != null)
{
ResolveDefault(fileNumber.markedFileNumber().expression());
}
else
{
ResolveDefault(fileNumber.unmarkedFileNumber().expression());
}
}
public void Resolve(VBAParser.OpenStmtContext context)
{
ResolveDefault(context.pathName().expression());
ResolveFileNumber(context.fileNumber());
if (context.lenClause() != null)
{
ResolveDefault(context.lenClause().recLength().expression());
}
}
public void Resolve(VBAParser.CloseStmtContext context)
{
if (context.fileNumberList() != null)
{
foreach (var fileNumber in context.fileNumberList().fileNumber())
{
ResolveFileNumber(fileNumber);
}
}
}
public void Resolve(VBAParser.SeekStmtContext context)
{
ResolveFileNumber(context.fileNumber());
ResolveDefault(context.position().expression());
}
public void Resolve(VBAParser.LockStmtContext context)
{
ResolveFileNumber(context.fileNumber());
if (context.recordRange() == null)
{
return;
}
ResolveRecordRange(context.recordRange());
}
public void Resolve(VBAParser.UnlockStmtContext context)
{
ResolveFileNumber(context.fileNumber());
ResolveRecordRange(context.recordRange());
}
private void ResolveRecordRange(VBAParser.RecordRangeContext recordRange)
{
if (recordRange == null)
{
return;
}
if (recordRange.startRecordNumber() != null)
{
ResolveDefault(recordRange.startRecordNumber().expression());
}
if (recordRange.endRecordNumber() != null)
{
ResolveDefault(recordRange.endRecordNumber().expression());
}
}
public void Resolve(VBAParser.LineInputStmtContext context)
{
ResolveDefault(context.markedFileNumber().expression());
ResolveDefault(context.variableName().expression(), isAssignmentTarget: true);
}
public void Resolve(VBAParser.WidthStmtContext context)
{
ResolveDefault(context.markedFileNumber().expression());
ResolveDefault(context.lineWidth().expression());
}
public void Resolve(VBAParser.PrintStmtContext context)
{
ResolveDefault(context.markedFileNumber().expression());
ResolveOutputList(context.outputList());
}
public void Resolve(VBAParser.WriteStmtContext context)
{
ResolveDefault(context.markedFileNumber().expression());
ResolveOutputList(context.outputList());
}
private void ResolveOutputList(VBAParser.OutputListContext outputList)
{
if (outputList == null)
{
return;
}
foreach (var outputItem in outputList.outputItem())
{
if (outputItem.outputClause() != null)
{
if (outputItem.outputClause().spcClause() != null)
{
ResolveDefault(outputItem.outputClause().spcClause().spcNumber().expression());
}
if (outputItem.outputClause().tabClause() != null && outputItem.outputClause().tabClause().tabNumberClause() != null)
{
ResolveDefault(outputItem.outputClause().tabClause().tabNumberClause().tabNumber().expression());
}
if (outputItem.outputClause().outputExpression() != null)
{
ResolveDefault(outputItem.outputClause().outputExpression().expression());
}
}
}
}
public void Resolve(VBAParser.InputStmtContext context)
{
ResolveDefault(context.markedFileNumber().expression());
foreach (var inputVariable in context.inputList().inputVariable())
{
ResolveDefault(inputVariable.expression(), isAssignmentTarget: true);
}
}
public void Resolve(VBAParser.PutStmtContext context)
{
ResolveFileNumber(context.fileNumber());
if (context.recordNumber() != null)
{
ResolveDefault(context.recordNumber().expression());
}
if (context.data() != null)
{
ResolveDefault(context.data().expression());
}
}
public void Resolve(VBAParser.GetStmtContext context)
{
ResolveFileNumber(context.fileNumber());
if (context.recordNumber() != null)
{
ResolveDefault(context.recordNumber().expression());
}
if (context.variable() != null)
{
ResolveDefault(context.variable().expression(), isAssignmentTarget: true);
}
}
public void Resolve(VBAParser.LsetStmtContext context)
{
foreach (var expr in context.expression())
{
ResolveDefault(expr);
}
}
public void Resolve(VBAParser.RsetStmtContext context)
{
foreach (var expr in context.expression())
{
ResolveDefault(expr);
}
}
public void Resolve(VBAParser.AsTypeClauseContext context)
{
// All "As Type" expressions are resolved here, statements don't have to resolve their "As Types" themselves.
var asType = context.type();
if (asType == null)
{
return;
}
var baseType = asType.baseType();
if (baseType != null)
{
// Fixed-Length strings can have a constant-name as length that is a simple-name-expression that also has to be resolved.
var length = context.fieldLength();
if (context.fieldLength() != null && context.fieldLength().identifierValue() != null)
{
ResolveDefault(context.fieldLength().identifierValue());
}
return;
}
ResolveType(asType.complexType());
}
public void Resolve(VBAParser.ForNextStmtContext context)
{
// In "For expr1 = expr2" the "expr1 = expr2" part is treated as a single expression.
var assignmentExpr = ((VBAParser.RelationalOpContext)context.expression()[0]);
var lExpr = assignmentExpr.expression()[0];
var firstExpression = _bindingService.ResolveDefault(
_moduleDeclaration,
_currentParent,
lExpr,
GetInnerMostWithExpression(),
StatementResolutionContext.Undefined);
//_boundExpressionVisitor.AddIdentifierReferences(
// firstExpression,
// _qualifiedModuleName,
// _currentScope,
// _currentParent);
if (firstExpression.Classification != ExpressionClassification.ResolutionFailed)
{
// each iteration counts as an assignment
_boundExpressionVisitor.AddIdentifierReferences(
firstExpression,
_qualifiedModuleName,
_currentScope,
_currentParent,
true);
}
var rExpr = assignmentExpr.expression()[1];
var secondExpression = _bindingService.ResolveDefault(
_moduleDeclaration,
_currentParent,
rExpr,
GetInnerMostWithExpression(),
StatementResolutionContext.Undefined);
_boundExpressionVisitor.AddIdentifierReferences(
secondExpression,
_qualifiedModuleName,
_currentScope,
_currentParent);
for (int exprIndex = 1; exprIndex < context.expression().Count; exprIndex++)
{
ResolveDefault(context.expression()[exprIndex]);
}
}
public void Resolve(VBAParser.ForEachStmtContext context)
{
var firstExpression = _bindingService.ResolveDefault(
_moduleDeclaration,
_currentParent,
context.expression()[0],
GetInnerMostWithExpression(),
StatementResolutionContext.Undefined);
if (firstExpression.Classification == ExpressionClassification.ResolutionFailed)
{
_boundExpressionVisitor.AddIdentifierReferences(
firstExpression,
_qualifiedModuleName,
_currentScope,
_currentParent);
}
else
{
// each iteration counts as an assignment
_boundExpressionVisitor.AddIdentifierReferences(
firstExpression,
_qualifiedModuleName,
_currentScope,
_currentParent,
true);
//_boundExpressionVisitor.AddIdentifierReferences(
// firstExpression,
// _qualifiedModuleName,
// _currentScope,
// _currentParent);
}
for (int exprIndex = 1; exprIndex < context.expression().Count; exprIndex++)
{
ResolveDefault(context.expression()[exprIndex]);
}
}
public void Resolve(VBAParser.ImplementsStmtContext context)
{
ResolveType(context.expression());
}
public void Resolve(VBAParser.RaiseEventStmtContext context)
{
var eventDeclaration = _bindingService.ResolveEvent(_moduleDeclaration, context.identifier().GetText());
if (eventDeclaration != null)
{
var callSiteContext = context.identifier();
var identifier = Identifier.GetName(context.identifier());
var callee = eventDeclaration;
callee.AddReference(
_qualifiedModuleName,
_currentScope,
_currentParent,
callSiteContext,
identifier,
callee,
callSiteContext.GetSelection(),
_annotationService.FindAnnotations(_qualifiedModuleName, callSiteContext.GetSelection().StartLine));
}
if (context.eventArgumentList() == null)
{
return;
}
foreach (var eventArgument in context.eventArgumentList().eventArgument())
{
ResolveDefault(eventArgument.expression());
}
}
public void Resolve(VBAParser.ResumeStmtContext context)
{
if (context.expression() == null)
{
return;
}
ResolveLabel(context.expression(), context.expression().GetText());
}
public void Resolve(VBAParser.LineSpecialFormContext context)
{
foreach (var expr in context.expression())
{
ResolveDefault(expr);
}
ResolveTuple(context.tuple(0));
ResolveTuple(context.tuple(1));
}
public void Resolve(VBAParser.CircleSpecialFormContext context)
{
foreach (var expr in context.expression())
{
ResolveDefault(expr);
}
ResolveTuple(context.tuple());
}
public void Resolve(VBAParser.ScaleSpecialFormContext context)
{
if (context.expression() != null)
{
ResolveDefault(context.expression());
}
foreach (var tuple in context.tuple())
{
ResolveTuple(tuple);
}
}
private void ResolveTuple(VBAParser.TupleContext tuple)
{
foreach (var expr in tuple.expression())
{
ResolveDefault(expr);
}
}
public void Resolve(VBAParser.EnumerationStmtContext context)
{
if (context.enumerationStmt_Constant() == null)
{
return;
}
foreach (var enumMember in context.enumerationStmt_Constant())
{
if (enumMember.expression() != null)
{
ResolveDefault(enumMember.expression());
}
}
}
public void Resolve(VBAParser.DebugPrintStmtContext context)
{
if (DebugDeclarations.DebugPrint == null)
{
Logger.Warn("Debug.Print (custom declaration) has not been loaded, skipping resolving Debug.Print call.");
return;
}
// Because Debug.Print has a special argument (an output list) instead
// of normal arguments we can't treat it as a function call.
var debugPrint = DebugDeclarations.DebugPrint;
var debugModule = debugPrint.ParentDeclaration;
debugModule.AddReference(
_qualifiedModuleName,
_currentScope,
_currentParent,
context.debugPrint().debugModule(),
context.debugPrint().debugModule().GetText(),
debugModule,
context.debugPrint().debugModule().GetSelection(),
_annotationService.FindAnnotations(_qualifiedModuleName, context.debugPrint().debugModule().GetSelection().StartLine));
debugPrint.AddReference(
_qualifiedModuleName,
_currentScope,
_currentParent,
context.debugPrint().debugPrintSub(),
context.debugPrint().debugPrintSub().GetText(),
debugPrint,
context.debugPrint().debugPrintSub().GetSelection(),
_annotationService.FindAnnotations(_qualifiedModuleName, context.debugPrint().debugPrintSub().GetSelection().StartLine));
var outputList = context.outputList();
if (outputList != null)
{
ResolveOutputList(outputList);
}
}
}
}