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

Rename doc param or its usage #811

Merged
merged 1 commit into from
Feb 26, 2025
Merged

Rename doc param or its usage #811

merged 1 commit into from
Feb 26, 2025

Conversation

aswamy
Copy link
Contributor

@aswamy aswamy commented Feb 24, 2025

What are you adding in this PR?

Closes #810

  • When you rename a variable usage or a param in doc tag, rename all instances

NOTE: if you have a assign (or equivalent) that collides with the param tag in doc, assume they are referring to the same variable and rename everything.

Tophat

  • Create a snippet with a doc param
  • Use the doc param in different liquid tags (pass in as a param for another snippet, use it in an echo tag, etc.)
  • Rename the variable from the doc param (place cursor on param name, and press F2)
  • Rename the variable usage in the snippet file (place cursor on variable usage, and press F2)

Before you deploy

  • I included a patch bump changeset

@aswamy aswamy requested a review from a team as a code owner February 24, 2025 20:29
@aswamy aswamy added the #gsd:44310 LiquidDoc label Feb 25, 2025
Comment on lines 104 to 108
(!!parentNode &&
parentNode.type === NodeTypes.LiquidDocParamNode &&
// We can only rename param tag's name; not its type or description
parentNode.paramName === node &&
node.type === NodeTypes.TextNode)
Copy link
Contributor

Choose a reason for hiding this comment

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

For clarity purposes, I feel like this should be in a variable or its own function. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've received this comment a couple times, but can you clarify what you mean by this?

It's already in a pretty concise function. Do you want me to separate this into another one?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's more of a personal preference, so I won't be hurt if you choose to go in a different direction!

I think separating this into another function or a variable such as const isLiquidDocParamNameNode would make it easier to reason about as someone not familiar with this code.

That would also allow us to only read from ancestors when needed.

Copy link
Contributor

@jamesmengo jamesmengo left a comment

Choose a reason for hiding this comment

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

Some non-blocking comments. Tophat and edge cases LGTM!
This one adds a really great feeling to the DX :)

@aswamy aswamy force-pushed the rename-liquid-doc-param-var branch from 5f63055 to fbf6b17 Compare February 26, 2025 15:53
@aswamy aswamy force-pushed the rename-liquid-doc-param-var branch from fbf6b17 to afebc66 Compare February 26, 2025 16:57
@aswamy aswamy merged commit 110bb00 into main Feb 26, 2025
6 checks passed
@aswamy aswamy deleted the rename-liquid-doc-param-var branch February 26, 2025 18:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
#gsd:44310 LiquidDoc
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Rename variable should also update liquid doc params
2 participants