Skip to content

✨feat(lang): support attribute access after selector call (.h(1).level)#1651

Merged
harehare merged 2 commits into
mainfrom
feat/support-attribute-access-after-selector-call
Apr 27, 2026
Merged

✨feat(lang): support attribute access after selector call (.h(1).level)#1651
harehare merged 2 commits into
mainfrom
feat/support-attribute-access-after-selector-call

Conversation

@harehare

Copy link
Copy Markdown
Owner
  • Add AST/CST parser logic to allow attribute selectors after selector calls (e.g., .h(1).level)
  • Add integration and parser tests for selector call attribute access
  • Enables queries like .h(2).depth and .code("rust").lang

- Add AST/CST parser logic to allow attribute selectors after selector calls (e.g., .h(1).level)
- Add integration and parser tests for selector call attribute access
- Enables queries like .h(2).depth and .code("rust").lang

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Adds language support for attribute access immediately after selector calls (e.g., .h(1).level), extending existing attribute-suffix behavior that previously worked for plain selectors (e.g., .code.lang).

Changes:

  • Extend CST parsing to accept an attribute selector immediately following a selector call.
  • Extend AST parsing to lower .selectorCall(...).attr into an attr(selectorCall(...), "attr") builtin call.
  • Add parser unit tests and an integration test covering the new selector-call attribute access syntax.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
crates/mq-lang/tests/integration_tests.rs Adds an end-to-end evaluation case for .h(2).depth after a selector call.
crates/mq-lang/src/cst/parser.rs Updates CST selector parsing to allow an attribute selector token immediately after selector-call args.
crates/mq-lang/src/ast/parser.rs Refactors attribute lowering and adds handling/tests for attribute suffixes on Expr::SelectorCall.

Comment thread crates/mq-lang/tests/integration_tests.rs
Comment thread crates/mq-lang/src/cst/parser.rs Outdated
Comment thread crates/mq-lang/src/cst/parser.rs
@codspeed-hq

codspeed-hq Bot commented Apr 27, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 29 untouched benchmarks


Comparing feat/support-attribute-access-after-selector-call (ade99f2) with main (d4f15fd)

Open in CodSpeed

- Add integration test for .code("rust").lang to validate full pipeline
- Fix CST error propagation to use map_err(ParseError::UnknownSelector) instead of unwrap_or(false)
- Add CST parser unit test for selector_call_with_attribute (.h(1).depth layout)

Agent-Logs-Url: https://github.com/harehare/mq/sessions/f74c277e-9380-4d9d-a488-0246892fecf6

Co-authored-by: harehare <533078+harehare@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends mq-lang’s parsing pipeline to support attribute access immediately after selector calls (e.g. .h(1).level), enabling more ergonomic selector-call chaining that desugars into the existing attr(...) / set_attr(...) machinery.

Changes:

  • Extend CST parsing to recognize an attribute-selector token following a SelectorCall node and attach it to the call node.
  • Extend AST parsing to convert .selector_call(...).attr into an attr(selector_call(...), "attr") call (and support |= via set_attr), mirroring existing .selector.attr behavior.
  • Add AST/CST unit tests and integration tests covering .h(2).depth and .code("rust").lang end-to-end evaluation.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
crates/mq-lang/tests/integration_tests.rs Adds end-to-end integration coverage for attribute access after selector calls.
crates/mq-lang/src/cst/parser.rs Parses attribute selectors that directly follow selector-call argument lists and models them in the CST.
crates/mq-lang/src/ast/parser.rs Desugars selector-call attribute access into attr(...) / set_attr(...) calls; adds parser unit tests.

@harehare harehare merged commit 93fc394 into main Apr 27, 2026
10 checks passed
@harehare harehare deleted the feat/support-attribute-access-after-selector-call branch April 27, 2026 23:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants