@@ -45,10 +45,15 @@ class Check {
4545 }
4646
4747 function isCheckSuppressed (f : Field ): Bool {
48- if (f == null || f .meta == null ) return false ;
48+ if (f == null ) return false ;
49+ return isPosSuppressed (f .pos );
50+ }
51+
52+ function hasSuppressWarningsMeta (m : Metadata ): Bool {
53+ if (m == null ) return false ;
4954
5055 var search = ' checkstyle: ${getModuleName ()}' ;
51- for (meta in f . meta ) {
56+ for (meta in m ) {
5257 if (meta .name != " SuppressWarnings" ) continue ;
5358 if (meta .params == null ) continue ;
5459 for (param in meta .params ) {
@@ -73,11 +78,44 @@ class Check {
7378 function isCharPosSuppressed (pos : Int ): Bool {
7479 for (td in _checker .ast .decls ) {
7580 switch (td .decl ){
81+ case EAbstract (d ):
82+ if ((pos <= td .pos .max ) && (pos >= td .pos .min )) {
83+ if (hasSuppressWarningsMeta (d .meta )) return true ;
84+ }
85+ for (field in d .data ) {
86+ if (pos > field .pos .max ) continue ;
87+ if (pos < field .pos .min ) continue ;
88+ return hasSuppressWarningsMeta (field .meta );
89+ }
7690 case EClass (d ):
91+ if ((pos <= td .pos .max ) && (pos >= td .pos .min )) {
92+ if (hasSuppressWarningsMeta (d .meta )) return true ;
93+ }
7794 for (field in d .data ) {
7895 if (pos > field .pos .max ) continue ;
7996 if (pos < field .pos .min ) continue ;
80- return isCheckSuppressed (field );
97+ return hasSuppressWarningsMeta (field .meta );
98+ }
99+ case EEnum (d ):
100+ if ((pos <= td .pos .max ) && (pos >= td .pos .min )) {
101+ if (hasSuppressWarningsMeta (d .meta )) return true ;
102+ }
103+ for (item in d .data ) {
104+ if (pos > item .pos .max ) continue ;
105+ if (pos < item .pos .min ) continue ;
106+ return hasSuppressWarningsMeta (item .meta );
107+ }
108+ case ETypedef (d ):
109+ switch (d .data ) {
110+ case TAnonymous (fields ):
111+ for (field in fields ) {
112+ if (pos > field .pos .max ) continue ;
113+ if (pos < field .pos .min ) continue ;
114+ if (hasSuppressWarningsMeta (field .meta )) return true ;
115+ // typedef pos does not include body
116+ return hasSuppressWarningsMeta (d .meta );
117+ }
118+ default :
81119 }
82120 default :
83121 }
0 commit comments