Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions shared/tree-sitter-extractor/src/extractor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,8 @@ impl<'a> Visitor<'a> {
if tp == single_type {
return true;
}
if let EntryKind::Union { members } = &self.schema.get(single_type).unwrap().kind
if let EntryKind::Union { members, .. } =
&self.schema.get(single_type).unwrap().kind
&& self.type_matches_set(tp, members)
{
return true;
Expand All @@ -926,7 +927,7 @@ impl<'a> Visitor<'a> {
return true;
}
for other in types.iter() {
if let EntryKind::Union { members } = &self.schema.get(other).unwrap().kind
if let EntryKind::Union { members, .. } = &self.schema.get(other).unwrap().kind
&& self.type_matches_set(tp, members)
{
return true;
Expand Down
4 changes: 3 additions & 1 deletion shared/tree-sitter-extractor/src/generator/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,9 @@ fn convert_nodes(
.collect();
for node in nodes.values() {
match &node.kind {
node_types::EntryKind::Union { members: n_members } => {
node_types::EntryKind::Union {
members: n_members, ..
} => {
// It's a tree-sitter supertype node, for which we create a union
// type.
let members: Set<&str> = n_members
Expand Down
326 changes: 233 additions & 93 deletions shared/tree-sitter-extractor/src/generator/ql_gen.rs

Large diffs are not rendered by default.

45 changes: 38 additions & 7 deletions shared/tree-sitter-extractor/src/node_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,17 @@ pub struct Entry {

#[derive(Debug)]
pub enum EntryKind {
Union { members: Set<TypeName> },
Table { name: String, fields: Vec<Field> },
Token { kind_id: usize },
Union {
members: Set<TypeName>,
fields: Vec<Field>,
},
Table {
name: String,
fields: Vec<Field>,
},
Token {
kind_id: usize,
},
}

#[derive(Clone, Debug, Ord, PartialOrd, Eq, PartialEq)]
Expand Down Expand Up @@ -135,16 +143,39 @@ pub fn convert_nodes(prefix: &str, nodes: &[NodeInfo]) -> NodeTypeMap {
if !subtypes.is_empty() {
// It's a tree-sitter supertype node, for which we create a union
// type.
let type_name = TypeName {
kind: node.kind.clone(),
named: node.named,
};
let mut fields = Vec::new();
for (field_name, field_info) in &node.fields {
add_field(
prefix,
&type_name,
Some(field_name.to_string()),
field_info,
&mut fields,
&token_kinds,
);
}
if let Some(children) = &node.children {
add_field(
prefix,
&type_name,
None,
children,
&mut fields,
&token_kinds,
);
}
entries.insert(
TypeName {
kind: node.kind.clone(),
named: node.named,
},
type_name,
Entry {
dbscheme_name,
ql_class_name,
kind: EntryKind::Union {
members: convert_types(subtypes),
fields,
},
},
);
Expand Down
Loading
Loading