From 858d59e00e10a85a6d1fac6e3c79afec4224443f Mon Sep 17 00:00:00 2001 From: Simon Marlow Date: Mon, 16 Dec 2024 07:50:09 -0800 Subject: [PATCH] Convert hack.ModuleParent Reviewed By: donsbot Differential Revision: D66014022 fbshipit-source-id: a28b40b75641b2279009303a38872c80fe18e558 --- glean/schema/source/hack.angle | 50 ++++++++++++++++++++++------------ 1 file changed, 32 insertions(+), 18 deletions(-) diff --git a/glean/schema/source/hack.angle b/glean/schema/source/hack.angle index 946f726de..66388cd14 100644 --- a/glean/schema/source/hack.angle +++ b/glean/schema/source/hack.angle @@ -734,23 +734,38 @@ predicate ModuleParent: decl: hack.Declaration, module: hack.ModuleDeclaration } - { Decl, Module } where - ( { function_ = FunDecl } = Decl; - hack.FunctionDefinition { declaration = FunDecl, module_ = M } ) | - ( { typedef_ = TyDecl } = Decl; - hack.TypedefDefinition { declaration = TyDecl, module_ = M } + { Decl, M.just?.declaration } where + ( + hack.FunctionDefinition D; + Decl.function_? = D.declaration; + M = D.module_; + ) | ( + hack.TypedefDefinition D; + Decl.typedef_? = D.declaration; + M = D.module_; ) | ( - { container = Container } = Decl; - ( { class_ = CDecl } = Container; - hack.ClassDefinition { declaration = CDecl, module_ = M } ) | - ( { enum_ = CDecl } = Container; - hack.EnumDefinition { declaration = CDecl, module_ = M } ) | - ( { interface_ = CDecl } = Container; - hack.InterfaceDefinition { declaration = CDecl, module_ = M } ) | - ( { trait = CDecl } = Container; - hack.TraitDefinition { declaration = CDecl, module_ = M } ) - ); - { just = { Module, _ } } = M + Decl.container? = Container; + ( Container.class_? = CDecl; + hack.ClassDefinition D; + D.declaration = CDecl; + D.module_ = M; + ) | ( + Container.enum_? = CDecl; + hack.EnumDefinition D; + D.declaration = CDecl; + D.module_ = M; + ) | ( + Container.interface_? = CDecl; + hack.InterfaceDefinition I; + I.declaration = CDecl; + I.module_ = M; + ) | ( + Container.trait? = CDecl; + hack.TraitDefinition T; + T.declaration = CDecl; + T.module_ = M; + ) + ) # derive children decls that are members of a parent module predicate ModuleChild: @@ -796,8 +811,7 @@ predicate AttributeToDeclaration : } stored { Attr, Decl, File } where - { name = Name } = Attr; - { container = { class_ = { name = { name = Name } } } } = Decl; + Attr.name = Decl.container?.class_?.name.name; DeclarationLocation { declaration = Decl, file = File }; # TODO qname for attributes aren't filled by the indexer yet