@@ -20,18 +20,11 @@ public IllegalAnnotationInspection(RubberduckParserState state)
20
20
21
21
protected override IEnumerable < IInspectionResult > DoGetInspectionResults ( )
22
22
{
23
- var illegalAnnotations = new List < IAnnotation > ( ) ;
24
-
25
23
var userDeclarations = State . DeclarationFinder . AllUserDeclarations . ToList ( ) ;
26
24
var identifierReferences = State . DeclarationFinder . AllIdentifierReferences ( ) . ToList ( ) ;
27
25
var annotations = State . AllAnnotations ;
28
26
29
- illegalAnnotations . AddRange ( UnboundAnnotations ( annotations , userDeclarations , identifierReferences ) ) ;
30
- illegalAnnotations . AddRange ( NonIdentifierAnnotationsOnIdentifiers ( identifierReferences ) ) ;
31
- illegalAnnotations . AddRange ( NonModuleAnnotationsOnModules ( userDeclarations ) ) ;
32
- illegalAnnotations . AddRange ( NonMemberAnnotationsOnMembers ( userDeclarations ) ) ;
33
- illegalAnnotations . AddRange ( NonVariableAnnotationsOnVariables ( userDeclarations ) ) ;
34
- illegalAnnotations . AddRange ( NonGeneralAnnotationsWhereOnlyGeneralAnnotationsBelong ( userDeclarations ) ) ;
27
+ var illegalAnnotations = UnboundAnnotations ( annotations , userDeclarations , identifierReferences ) ;
35
28
36
29
return illegalAnnotations . Select ( annotation =>
37
30
new QualifiedContextInspectionResult (
@@ -50,64 +43,5 @@ private static ICollection<IAnnotation> UnboundAnnotations(IEnumerable<IAnnotati
50
43
51
44
return annotations . Where ( annotation => ! boundAnnotationsSelections . Contains ( annotation . QualifiedSelection ) ) . ToList ( ) ;
52
45
}
53
-
54
- private static ICollection < IAnnotation > NonIdentifierAnnotationsOnIdentifiers ( IEnumerable < IdentifierReference > identifierReferences )
55
- {
56
- return identifierReferences
57
- . SelectMany ( reference => reference . Annotations )
58
- . Where ( annotation => ! annotation . AnnotationType . HasFlag ( AnnotationType . IdentifierAnnotation ) )
59
- . ToList ( ) ;
60
- }
61
-
62
- private static ICollection < IAnnotation > NonModuleAnnotationsOnModules ( IEnumerable < Declaration > userDeclarations )
63
- {
64
- return userDeclarations
65
- . Where ( declaration => declaration . DeclarationType . HasFlag ( DeclarationType . Module ) )
66
- . SelectMany ( moduleDeclaration => moduleDeclaration . Annotations )
67
- . Where ( annotation => ! annotation . AnnotationType . HasFlag ( AnnotationType . ModuleAnnotation ) )
68
- . ToList ( ) ;
69
- }
70
-
71
- private static ICollection < IAnnotation > NonMemberAnnotationsOnMembers ( IEnumerable < Declaration > userDeclarations )
72
- {
73
- return userDeclarations
74
- . Where ( declaration => declaration . DeclarationType . HasFlag ( DeclarationType . Member ) )
75
- . SelectMany ( member => member . Annotations )
76
- . Where ( annotation => ! annotation . AnnotationType . HasFlag ( AnnotationType . MemberAnnotation ) )
77
- . ToList ( ) ;
78
- }
79
-
80
- private static ICollection < IAnnotation > NonVariableAnnotationsOnVariables ( IEnumerable < Declaration > userDeclarations )
81
- {
82
- return userDeclarations
83
- . Where ( declaration => VariableAnnotationDeclarationTypes . Contains ( declaration . DeclarationType ) )
84
- . SelectMany ( declaration => declaration . Annotations )
85
- . Where ( annotation => ! annotation . AnnotationType . HasFlag ( AnnotationType . VariableAnnotation ) )
86
- . ToList ( ) ;
87
- }
88
-
89
- private static readonly HashSet < DeclarationType > VariableAnnotationDeclarationTypes = new HashSet < DeclarationType > ( )
90
- {
91
- DeclarationType . Variable ,
92
- DeclarationType . Control ,
93
- DeclarationType . Constant ,
94
- DeclarationType . Enumeration ,
95
- DeclarationType . EnumerationMember ,
96
- DeclarationType . UserDefinedType ,
97
- DeclarationType . UserDefinedType ,
98
- DeclarationType . UserDefinedTypeMember
99
- } ;
100
-
101
- private static ICollection < IAnnotation > NonGeneralAnnotationsWhereOnlyGeneralAnnotationsBelong ( IEnumerable < Declaration > userDeclarations )
102
- {
103
- return userDeclarations
104
- . Where ( declaration => ! declaration . DeclarationType . HasFlag ( DeclarationType . Module )
105
- && ! declaration . DeclarationType . HasFlag ( DeclarationType . Member )
106
- && ! VariableAnnotationDeclarationTypes . Contains ( declaration . DeclarationType )
107
- && declaration . DeclarationType != DeclarationType . Project )
108
- . SelectMany ( member => member . Annotations )
109
- . Where ( annotation => ! annotation . AnnotationType . HasFlag ( AnnotationType . GeneralAnnotation ) )
110
- . ToList ( ) ;
111
- }
112
46
}
113
47
}
0 commit comments