feat(query): Add right to VariableDeclaration (#718)

This commit is contained in:
u9g 2023-08-11 01:40:35 -04:00 committed by GitHub
parent 9c05866cc1
commit 97c5cd379e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 0 deletions

View file

@ -1725,6 +1725,7 @@ pub(super) fn resolve_variable_declaration_edge<'a, 'b: 'a>(
match edge_name {
"span" => variable_declaration::span(contexts, resolve_info),
"left" => variable_declaration::left(contexts, resolve_info),
"right" => variable_declaration::right(contexts, resolve_info),
"ancestor" => ancestors(contexts, adapter),
"parent" => parents(contexts, adapter),
_ => {
@ -1775,4 +1776,23 @@ mod variable_declaration {
)));
})
}
pub(super) fn right<'a, 'b: 'a>(
contexts: ContextIterator<'a, Vertex<'b>>,
_resolve_info: &ResolveEdgeInfo,
) -> ContextOutcomeIterator<'a, Vertex<'b>, VertexIterator<'a, Vertex<'b>>> {
resolve_neighbors_with(contexts, |v| {
Box::new(
v.as_variable_declaration()
.unwrap_or_else(|| {
panic!("expected to have a typeannotation vertex, instead have: {v:#?}")
})
.variable_declaration
.init
.as_ref()
.into_iter()
.map(Vertex::from),
)
})
}
}

View file

@ -366,6 +366,7 @@ this will fire once per assignment.
"""
type VariableDeclarationAST implements VariableDeclaration & ASTNode & HasSpan {
left: AssignmentType!
right: Expression
# ASTNode
parent: ASTNode
ancestor: [ASTNode!]!