Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proposal for nesting query predicate operator #1

Conversation

pokey
Copy link

@pokey pokey commented Feb 2, 2024

The idea here is to define @foo.input / @foo.output pairs. For any @foo capture, we look to see if there are any @foo.input captures whose range is identical to @foo. If so, we change the range of @foo to be the range of @foo.output. We repeat this process until it doesn't match any @foo.input capture. This way we can expand up an ancestor tree, traverse across a tree, etc

I haven't implemented the operator itself, but I don't think it should be too bad; just do an initial traversal where construct a map of all @foo.input captures and then use that for doing a lookup when we handle the final captures

cc/ @AndreasArvidsson @wenkokke @josharian

Checklist

Comment on lines +258 to +263
(
(apply_expression
function: (_) @functionCallee
) @functionCallee.domain @functionCall
(#not-type? @functionCallee apply_expression)
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This matches the innermost function call, which is why we use the not-type here

Comment on lines 265 to +267
(apply_expression
[
(select_expression
expression: (variable_expression
name: (identifier)
)
) @functionCallee
(apply_expression
[
(select_expression
expression: (variable_expression
name: (identifier)
)
) @functionCallee
(apply_expression
[
(select_expression
expression: (variable_expression
name: (identifier)
)
) @functionCallee
(apply_expression
(select_expression
expression: (variable_expression
name: (identifier)
)
) @functionCallee
)
]
)
]
)
]
) @functionCall @_.domain
function: (apply_expression) @functionCallee.domain.input @functionCall.input
) @functionCallee.domain.output @functionCall.output
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

then each step goes from an apply_expression to its immediate apply_expression parent

Comment on lines +283 to 286
(
(apply_expression) @argumentOrParameter.iteration
(#not-parent-type? @argumentOrParameter.iteration apply_expression)
)
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fidgetingbits this isn't entirely related, but note that we can simply define iteration scope for arg like this, and then "first arg" etc should just work

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
1 participant