Add advanced CSS-like selector syntax to Foresta.js AST query engine#8
Draft
Add advanced CSS-like selector syntax to Foresta.js AST query engine#8
Conversation
…pseudo-class support Co-authored-by: joelmartinez <90380+joelmartinez@users.noreply.github.com>
…s passing Co-authored-by: joelmartinez <90380+joelmartinez@users.noreply.github.com>
…new selector features Co-authored-by: joelmartinez <90380+joelmartinez@users.noreply.github.com>
…, extract common regex pattern Co-authored-by: joelmartinez <90380+joelmartinez@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add advanced selector types and options for Foresta.js AST engine
Add advanced CSS-like selector syntax to Foresta.js AST query engine
Dec 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extends Foresta.js with CSS-inspired selector syntax for querying JavaScript ASTs, enabling attribute filtering, pseudo-classes, combinators, and logical operators while maintaining backward compatibility.
Implementation
Attribute Selectors
Literal[value=42][name^="is"](starts),[name$="Value"](ends),[name*="test"](contains)[name~/^get[A-Z]/]CallExpression[callee.name=fetch]Pseudo-Classes
:not([value=42]):first-child,:last-child,:nth-child(n):empty,:has(ReturnStatement)Combinators
BlockStatement > VariableDeclarationProperty + PropertyProperty ~ PropertyLogical Operators
VariableDeclaration, FunctionDeclarationAdditional AST Support
Added visitor methods for FunctionDeclaration, IfStatement, ReturnStatement, SwitchStatement, Export nodes, ArrowFunctionExpression, AwaitExpression, ArrayExpression.
Example Usage
Notes
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.