Skip to content

Commit d29d2d8

Browse files
committed
Refactor class access type decl matching
1 parent 9f12c92 commit d29d2d8

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

lkql_checker/share/lkql/identifier_prefixes.lkql

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,15 @@ fun get_derived(t, derived) = {
88
if not res then "" else res[res.length]
99
}
1010

11+
fun is_class_access(type_decl) =
12+
|" Given a TypeDecl node, return whether the declared type is an access
13+
|" to classwide values.
14+
type_decl.f_type_def is TypeAccessDef(
15+
f_subtype_indication: *(f_name: AttributeRef(
16+
f_attribute: Identifier(p_name_is("Class"): true)
17+
))
18+
)
19+
1120
@unit_check(help="prefixes in defining names", remediation="EASY",
1221
parametric_exemption=true,
1322
category="Style", subcategory="Readability")
@@ -254,12 +263,12 @@ fun identifier_prefixes(unit,
254263
concurrent_exclusive=false))
255264

256265
# 'Class access
257-
| (p@TypeDecl(f_type_def: TypeAccessDef(f_subtype_indication: *(f_name:
258-
AttributeRef(f_attribute: Identifier(p_name_is("Class"): true))))) |
259-
p@SubtypeDecl(p_canonical_type(): TypeDecl(f_type_def:
260-
TypeAccessDef(f_subtype_indication: *(f_name:
261-
AttributeRef(f_attribute: Identifier(p_name_is("Class"): true)))))))
262-
when class_access != "-"
266+
| (
267+
p@TypeDecl when is_class_access(p) |
268+
p@SubtypeDecl(
269+
p_canonical_type(): td@TypeDecl when is_class_access(td)
270+
)
271+
) when class_access != "-"
263272
=>
264273
p?.p_previous_part() is (null | IncompleteTypeDecl) and
265274
(if node.f_name.text.starts_with(class_access)

0 commit comments

Comments
 (0)