Skip to content

Commit 00d064b

Browse files
committed
IAnnotatedContext.Annotate sets the annotated context, now need to fix AttributeListener.ExitAnnotation.
1 parent e4b6570 commit 00d064b

File tree

5 files changed

+16
-6
lines changed

5 files changed

+16
-6
lines changed

Rubberduck.Inspections/Concrete/MissingAttributeInspection.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,8 @@
22
using System.Collections.Generic;
33
using System.Diagnostics;
44
using System.Linq;
5-
using Antlr4.Runtime;
65
using Rubberduck.Inspections.Abstract;
76
using Rubberduck.Inspections.Results;
8-
using Rubberduck.Parsing;
97
using Rubberduck.Parsing.Annotations;
108
using Rubberduck.Parsing.Grammar;
119
using Rubberduck.Parsing.Inspections;

Rubberduck.Inspections/QuickFixes/SynchronizeAttributesQuickFix.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ private void FixMember(IInspectionResult result, ParserRuleContext context)
8282
var annotationContext = context as VBAParser.AnnotationContext;
8383
if (annotationContext != null)
8484
{
85-
Fix(memberName, annotationContext);
85+
InsertAttributeStatement(memberName, annotationContext);
8686
return;
8787
}
8888
}
@@ -210,7 +210,7 @@ private static void FixExposedAttribute(RubberduckParserState state, QualifiedMo
210210
/// </summary>
211211
/// <param name="memberName"></param>
212212
/// <param name="context"></param>
213-
private void Fix(QualifiedMemberName memberName, VBAParser.AnnotationContext context)
213+
private void InsertAttributeStatement(QualifiedMemberName memberName, VBAParser.AnnotationContext context)
214214
{
215215
Debug.Assert(context.AnnotationType.HasFlag(AnnotationType.MemberAnnotation));
216216

Rubberduck.Parsing/Annotations/AnnotationListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public AnnotationListener(IAnnotationFactory factory, QualifiedModuleName qualif
2323
public override void ExitAnnotation([NotNull] VBAParser.AnnotationContext context)
2424
{
2525
var newAnnotation = _factory.Create(context, new QualifiedSelection(_qualifiedName, context.GetSelection()));
26-
// It might be an annotation we don't support or a typo.
26+
// it might be an annotation we don't support, or a typo.
2727
if (newAnnotation != null)
2828
{
2929
_annotations.Add(newAnnotation);

Rubberduck.Parsing/Grammar/PartialExtensions/VBAParserPartialExtensions.cs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ public Interval IdentifierTokens
6767

6868
public void Annotate(AnnotationContext annotation)
6969
{
70+
annotation.AnnotatedContext = this;
7071
_annotations.Add(annotation);
7172
}
7273

@@ -105,6 +106,7 @@ public Interval IdentifierTokens
105106

106107
public void Annotate(AnnotationContext annotation)
107108
{
109+
annotation.AnnotatedContext = this;
108110
_annotations.Add(annotation);
109111
}
110112

@@ -143,6 +145,7 @@ public Interval IdentifierTokens
143145

144146
public void Annotate(AnnotationContext annotation)
145147
{
148+
annotation.AnnotatedContext = this;
146149
_annotations.Add(annotation);
147150
}
148151

@@ -195,6 +198,7 @@ public Interval IdentifierTokens
195198

196199
public void Annotate(AnnotationContext annotation)
197200
{
201+
annotation.AnnotatedContext = this;
198202
_annotations.Add(annotation);
199203
}
200204

@@ -231,6 +235,7 @@ public Interval IdentifierTokens
231235

232236
public void Annotate(AnnotationContext annotation)
233237
{
238+
annotation.AnnotatedContext = this;
234239
_annotations.Add(annotation);
235240
}
236241

@@ -267,6 +272,7 @@ public Interval IdentifierTokens
267272

268273
public void Annotate(AnnotationContext annotation)
269274
{
275+
annotation.AnnotatedContext = this;
270276
_annotations.Add(annotation);
271277
}
272278

@@ -303,6 +309,7 @@ public Interval IdentifierTokens
303309

304310
public void Annotate(AnnotationContext annotation)
305311
{
312+
annotation.AnnotatedContext = this;
306313
_annotations.Add(annotation);
307314
}
308315

@@ -339,6 +346,7 @@ public Interval IdentifierTokens
339346

340347
public void Annotate(AnnotationContext annotation)
341348
{
349+
annotation.AnnotatedContext = this;
342350
_annotations.Add(annotation);
343351
}
344352

@@ -375,6 +383,7 @@ public Interval IdentifierTokens
375383

376384
public void Annotate(AnnotationContext annotation)
377385
{
386+
annotation.AnnotatedContext = this;
378387
_annotations.Add(annotation);
379388
}
380389

@@ -411,6 +420,7 @@ public Interval IdentifierTokens
411420

412421
public void Annotate(AnnotationContext annotation)
413422
{
423+
annotation.AnnotatedContext = this;
414424
_annotations.Add(annotation);
415425
}
416426

@@ -447,6 +457,7 @@ public Interval IdentifierTokens
447457

448458
public void Annotate(AnnotationContext annotation)
449459
{
460+
annotation.AnnotatedContext = this;
450461
_annotations.Add(annotation);
451462
}
452463

@@ -483,6 +494,7 @@ public Interval IdentifierTokens
483494

484495
public void Annotate(AnnotationContext annotation)
485496
{
497+
annotation.AnnotatedContext = this;
486498
_annotations.Add(annotation);
487499
}
488500

Rubberduck.Parsing/VBA/AttributeListener.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ public AttributeListener(Tuple<string, DeclarationType> scope)
2727

2828
public override void ExitAnnotation(VBAParser.AnnotationContext context)
2929
{
30+
// note: SynchronizeAttributesQuickFix needs the AnnotatedContext to be from the AttributesPass parse tree.
3031
_currentAnnotatedContext?.Annotate(context);
31-
context.AnnotatedContext = _currentAnnotatedContext as ParserRuleContext;
3232
}
3333

3434
public override void ExitModuleAttributes(VBAParser.ModuleAttributesContext context)

0 commit comments

Comments
 (0)