feat(query): impl Typename for VariableDeclaration (#638)

This commit is contained in:
u9g 2023-07-26 21:46:49 -04:00 committed by GitHub
parent 318d55806f
commit 997eb26d3e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 2 deletions

View file

@ -103,6 +103,7 @@ query {
span_asmt_type_end: u64,
entire_span_start: u64,
entire_span_end: u64,
__typename: String,
}
let mut results: Vec<Output> = execute_query(
@ -120,6 +121,8 @@ query {
}
}
__typename @output
entire_span_: entire_span {
start @output
end @output
@ -142,7 +145,8 @@ query {
span_asmt_type_start: 6,
span_asmt_type_end: 11,
entire_span_start: 6,
entire_span_end: 15
entire_span_end: 15,
__typename: "VariableDeclarationAST".to_owned()
}],
results
);

View file

@ -176,7 +176,7 @@ impl Typename for Vertex<'_> {
Vertex::TypeAnnotation(tn) => tn.typename(),
Vertex::Type(_) => "Type",
Vertex::Url(_) => "URL",
Vertex::VariableDeclaration(_) => "VariableDeclaration",
Vertex::VariableDeclaration(vd) => vd.typename(),
Vertex::ReturnStatementAST(_) => "ReturnStatementAST",
}
}
@ -346,3 +346,9 @@ pub struct VariableDeclarationVertex<'a> {
ast_node: Option<AstNode<'a>>,
pub variable_declaration: &'a VariableDeclarator<'a>,
}
impl<'a> Typename for VariableDeclarationVertex<'a> {
fn typename(&self) -> &'static str {
if self.ast_node.is_some() { "VariableDeclarationAST" } else { "VariableDeclaration" }
}
}