Skip to content

Commit 4345463

Browse files
authored
Merge pull request #22693 from asgerf/unified/supertype-fields-clean
Unified: Declare exposed fields on supertypes (v2)
2 parents e785768 + c42892a commit 4345463

8 files changed

Lines changed: 790 additions & 413 deletions

File tree

‎shared/tree-sitter-extractor/src/extractor/mod.rs‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,8 @@ impl<'a> Visitor<'a> {
908908
if tp == single_type {
909909
return true;
910910
}
911-
if let EntryKind::Union { members } = &self.schema.get(single_type).unwrap().kind
911+
if let EntryKind::Union { members, .. } =
912+
&self.schema.get(single_type).unwrap().kind
912913
&& self.type_matches_set(tp, members)
913914
{
914915
return true;
@@ -930,7 +931,7 @@ impl<'a> Visitor<'a> {
930931
return true;
931932
}
932933
for other in types.iter() {
933-
if let EntryKind::Union { members } = &self.schema.get(other).unwrap().kind
934+
if let EntryKind::Union { members, .. } = &self.schema.get(other).unwrap().kind
934935
&& self.type_matches_set(tp, members)
935936
{
936937
return true;

‎shared/tree-sitter-extractor/src/generator/mod.rs‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -399,7 +399,9 @@ fn convert_nodes(
399399
.collect();
400400
for node in nodes.values() {
401401
match &node.kind {
402-
node_types::EntryKind::Union { members: n_members } => {
402+
node_types::EntryKind::Union {
403+
members: n_members, ..
404+
} => {
403405
// It's a tree-sitter supertype node, for which we create a union
404406
// type.
405407
let members: Set<&str> = n_members

‎shared/tree-sitter-extractor/src/generator/ql.rs‎

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ impl fmt::Display for Class<'_> {
109109
is_final: false,
110110
return_type: None,
111111
formal_parameters: vec![],
112-
body: Some(charpred.clone()),
112+
body: charpred.clone(),
113113
overlay: None,
114114
}
115115
)?;
@@ -307,9 +307,7 @@ pub struct Predicate<'a> {
307307
pub is_final: bool,
308308
pub return_type: Option<Type<'a>>,
309309
pub formal_parameters: Vec<FormalParameter<'a>>,
310-
/// The body of the predicate, or `None` if this is an `abstract`
311-
/// predicate declaration with no body.
312-
pub body: Option<Expression<'a>>,
310+
pub body: Expression<'a>,
313311
pub overlay: Option<OverlayAnnotation>,
314312
}
315313

@@ -332,9 +330,6 @@ impl fmt::Display for Predicate<'_> {
332330
if self.is_final {
333331
write!(f, "final ")?;
334332
}
335-
if self.body.is_none() {
336-
write!(f, "abstract ")?;
337-
}
338333
if self.overridden {
339334
write!(f, "override ")?;
340335
}
@@ -349,10 +344,7 @@ impl fmt::Display for Predicate<'_> {
349344
}
350345
write!(f, "{param}")?;
351346
}
352-
match &self.body {
353-
Some(body) => write!(f, ") {{ {body} }}")?,
354-
None => write!(f, ");")?,
355-
}
347+
write!(f, ") {{ {} }}", self.body)?;
356348

357349
Ok(())
358350
}

0 commit comments

Comments
 (0)