Skip to content

Commit 14547be

Browse files
authored
Merge pull request #4599 from MDoerner/FixGeneralAnnotations
Always deem annotations with GeneralAnnotation flag legal
2 parents a6d6d18 + 33eb1f5 commit 14547be

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Rubberduck.CodeAnalysis/Inspections/Concrete/IllegalAnnotationInspection.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ protected override IEnumerable<IInspectionResult> DoGetInspectionResults()
2424
var identifierReferences = State.DeclarationFinder.AllIdentifierReferences().ToList();
2525
var annotations = State.AllAnnotations;
2626

27-
var illegalAnnotations = UnboundAnnotations(annotations, userDeclarations, identifierReferences);
27+
var illegalAnnotations = UnboundAnnotations(annotations, userDeclarations, identifierReferences)
28+
.Where(annotation => !annotation.AnnotationType.HasFlag(AnnotationType.GeneralAnnotation));
2829

2930
return illegalAnnotations.Select(annotation =>
3031
new QualifiedContextInspectionResult(

RubberduckTests/Inspections/IllegalAnnotationsInspectionTests.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -782,6 +782,31 @@ End Sub
782782
}
783783
}
784784

785+
[Test]
786+
[Category("Inspections")]
787+
public void GeneralAnnotationOnNonDeclarationNonIdentifier_NoResult()
788+
{
789+
const string inputCode = @"
790+
Option Explicit
791+
'@Ignore OptionBase
792+
Option Base 1
793+
794+
Public foo As Long
795+
796+
Public Sub Test2()
797+
End Sub
798+
";
799+
var vbe = MockVbeBuilder.BuildFromSingleStandardModule(inputCode, out _);
800+
using (var state = MockParser.CreateAndParse(vbe.Object))
801+
{
802+
var inspection = new IllegalAnnotationInspection(state);
803+
var inspector = InspectionsHelper.GetInspector(inspection);
804+
var inspectionResults = inspector.FindIssuesAsync(state, CancellationToken.None).Result;
805+
806+
Assert.IsFalse(inspectionResults.Any());
807+
}
808+
}
809+
785810
[Test]
786811
[Category("Inspections")]
787812
[Ignore("We cannot really test this because we currently do not have a pure IdentifierReferenceAnnotation.")]

0 commit comments

Comments
 (0)