-
Notifications
You must be signed in to change notification settings - Fork 96
Support string enums in LiquidDoc parameter types #1310
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鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
clauderic
wants to merge
4
commits into
main
Choose a base branch
from
liquiddoc-string-literal-unions
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
11fa47f
Fix quoted delimiters in LiquidDoc parameter types
clauderic 295bed8
Accept string enums in LiquidDoc parameter types
clauderic 7c8b9d4
Validate arguments against LiquidDoc string enums
clauderic 78895cd
Support LiquidDoc string enums in the language server
clauderic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@shopify/theme-language-server-common': minor | ||
| --- | ||
|
|
||
| Support LiquidDoc string enums in hovers and completions | ||
|
|
||
| Allowed values are kept through assignments and `default`, and `render`, `content_for` and `block` parameter completions insert the first one. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| '@shopify/theme-check-common': minor | ||
| --- | ||
|
|
||
| Support string enums in LiquidDoc parameter types | ||
|
|
||
| `@param` accepts unions of string literals, such as `{'heading' | 'small'}`, and literal arguments to `render`, `content_for` and `block` are checked against them. |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| --- | ||
| '@shopify/liquid-html-parser': patch | ||
| --- | ||
|
|
||
| Preserve quoted braces in LiquidDoc parameter types and recover incomplete string annotations without consuming subsequent parameters. |
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
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
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
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
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -245,6 +245,16 @@ describe('ValidBlockArgumentTypes', () => { | |
| expect(offenses).toEqual([]); | ||
| }); | ||
|
|
||
| it('keeps the schema type of a setting that LiquidDoc declares as a string enum', async () => { | ||
| const block = blockSource( | ||
| [{ id: 'variant', type: 'text' }], | ||
| ["@param {'heading' | 'small'} [variant] - Variant"], | ||
| ); | ||
|
|
||
| expect(await definitions(block)).toEqual([]); | ||
| expect(await run("{% block 'card', variant: 'body' %}{% endblock %}", block)).toEqual([]); | ||
| }); | ||
|
Comment on lines
+248
to
+256
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We鈥檙e missing a failure case? |
||
|
|
||
| it('does not speculate about omitted LiquidDoc or unmapped schema types', async () => { | ||
| const offenses = await definitions( | ||
| blockSource([{ id: 'item', type: 'metaobject' }], ['@param [item] - Item']), | ||
|
|
||
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
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yuk. Can we not tokenize and consume tokens here instead? Why are we going ch by ch? This feels fast but also gross.
I feel like a stack based parser here would make this a bit easier to follow. I don鈥檛 like the lookback.