8000 Improve alias parsing in the cst & ast by EvilGenius13 · Pull Request #845 · Shopify/theme-tools · GitHub
[go: up one dir, main page]

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

Improve alias parsing in the cst & ast #845

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

EvilGenius13
Copy link
Contributor

What are you adding in this PR?

Closes: https://github.com/Shopify/developer-tools-team/issues/607

  • Added proper position tracking for aliases by introducing a RenderAliasExpression node type.
  • Updated the parser to capture positional information for the as and with part of render tags
  • Modified any consumers of render markup to use the new structure

Before you deploy

  • I included a patch bump changeset

@EvilGenius13 EvilGenius13 force-pushed the improve-alias-parsing branch from 8988b17 to 67f029f Compare March 10, 2025 18:01
@EvilGenius13 EvilGenius13 force-pushed the improve-alias-parsing branch from 67f029f to 750a754 Compare March 10, 2025 18:06
@EvilGenius13 EvilGenius13 marked this pull request as ready for review March 10, 2025 18:07
@EvilGenius13 EvilGenius13 requested a review from a team as a code owner March 10, 2025 18:07
variable: ConcreteRenderVariableExpression | null;
aliasExpression: ConcreteRenderAliasExpression | null;
Copy link
Contributor

Choose a reason for hiding this comment

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

can we keep this as-is?

@@ -388,6 +389,11 @@ export interface ConcreteRenderVariableExpression
name: ConcreteLiquidExpression;
}

export interface ConcreteRenderAliasExpression
extends ConcreteBasicNode<ConcreteNodeTypes.RenderAliasExpression> {
alias: string;
Copy link
Contributor

Choose a reason for hiding this comment

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

If we keep alias in ConcreteLiquidTagRenderMarkup, we can make this .value

@@ -183,7 +183,7 @@ function printNamedLiquidBlockStart(
case NamedTags.render: {
const markup = node.markup;
const trailingWhitespace =
markup.args.length > 0 || (markup.variable && markup.alias) ? line : ' ';
markup.args.length > 0 || (markup.variable && markup.aliasExpression?.alias) ? line : ' ';
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this condition need to be updated?

When would markup.aliasExpression be truthy but markup.aliasExpression?.alias be falsy?

Copy link
Contributor

Choose a reason for hiding this comment

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

Based off the types in stage-1, I would expect aliasExpression to be null

Copy link
Contributor

This is going in the right direction! Left some questions / comments :)

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.

2 participants
0