-
Notifications
You must be signed in to change notification settings - Fork 190
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
add block param nodes #1552
add block param nodes #1552
Conversation
let [Foo] = ast.body; | ||
if (assertNodeType(Foo, 'BlockStatement')) { | ||
let [ab, cd, efg] = guardArray({ blockParamNodes: Foo.program.blockParamNodes }, { min: 3 }); | ||
locEqual(ab, 1, 11, 1, 13); |
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.
can the value / name be asserted as well?
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.
i think this should be done separately. i will add it in parser-node-test
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.
revert bin/run-tests.mjs <3
1ed5c46
to
a88263f
Compare
@@ -293,6 +295,16 @@ export interface HashPair extends BaseNode { | |||
value: Expression; | |||
} | |||
|
|||
/** | |||
* a param inside the pipes of elements or mustache blocks, |
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.
🙌 perfect! thank you!
let [Foo] = ast.body; | ||
if (assertNodeType(Foo, 'ElementNode')) { | ||
let [ab, cd, efg] = guardArray({ blockParamNodes: Foo.blockParamNodes }, { min: 3 }); | ||
locEqual(ab, 1, 8, 1, 12); |
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.
since the signature for locEqual
is
function locEqual(
node: AST.Node | null | undefined,
startLine: number,
startColumn: number,
endLine: number,
endColumn: number,
message = JSON.stringify(node)
) {
should endColumn
be 2 characters more than startColumn
? right now it sees like.. 4?
locEqual(ab, 1, 8, 1, 12); // 12 - 8 = 4, but the node is 'ab', 2
locEqual(cd, 1, 12, 1, 15); // 15 - 12 = 3, but the node is 'cd', 2
locEqual(efg, 1, 15, 1, 19); // 19 - 15 = 4, but the node is 'efg', 3
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.
oh! thanks for noticing. since those are initially parsed as attributes by hbs parser the location contains the pipe as well... need to fix it. not sure why it also contains the whitespace, might be a bug in hbs parser
't=<Foo as |ab cd efg|></Foo>'
t.slice(8,12)
'|ab '
t.slice(12,15)
'cd '
t.slice(15,19)
'efg|'
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.
ranges look good, thank you!
The original commit has a few issues: - Type safety - Added a new AST node, which is unnecessary since we already have `VarHead`, but is also a breaking change and is kind of breakage we have been careful to avoid in this area thus far - The parsing is robust against a few classes of edge cases This rework the same feature (on the `Block`/`BlockStatement` side) and adds more test coverage for the feature. Also reanmed the field to `block.params`.
The original commit has a few issues: - Type safety - Added a new AST node, which is unnecessary since we already have `VarHead`, but is also a breaking change and is kind of breakage we have been careful to avoid in this area thus far - The parsing is robust against a few classes of edge cases This rework the same feature (on the `Block`/`BlockStatement` side) and adds more test coverage for the feature. Also reanmed the field to `block.params`.
The original commit has a few issues: - Type safety - Added a new AST node, which is unnecessary since we already have `VarHead`, but is also a breaking change and is kind of breakage we have been careful to avoid in this area thus far - The parsing is robust against a few classes of edge cases This rework the same feature (on the `Block`/`BlockStatement` side) and adds more test coverage for the feature. Also reanmed the field to `block.params`.
The original commit has a few issues: - Type safety - Added a new AST node, which is unnecessary since we already have `VarHead`, but is also a breaking change and is kind of breakage we have been careful to avoid in this area thus far - The parsing is robust against a few classes of edge cases This rework the same feature (on the `Block`/`BlockStatement` side) and adds more test coverage for the feature. Also reanmed the field to `block.params`.
The original commit has a few issues: - Type safety - Added a new AST node, which is unnecessary since we already have `VarHead`, but is also a breaking change and is kind of breakage we have been careful to avoid in this area thus far - The parsing is robust against a few classes of edge cases This rework the same feature (on the `Block`/`BlockStatement` side) and adds more test coverage for the feature. Also renamed the field to `block.params`.
The previous/existing "parsing" code tries to piggy back on letting the HTML tokenizer/parse parse out the block params syntax into attribute nodes and tries to recover the information after the fact This is fundamentally broken and suffers from some wild edge cases like: ``` <div as="" |foo="bar|>...</div> // => <div as |foo|>...</div> ``` This is especially problematic in light of wanting to retain the source spans of the block params nodes. This commit rework the block params parsing and integrate it into the normal parsing pass in the appropiate time.
The previous/existing "parsing" code tries to piggy back on letting the HTML tokenizer/parser parse out the block params syntax into attribute nodes and tries to recover the information after the fact This is fundamentally broken and suffers from some wild edge cases like: ``` <div as="" |foo="bar|>...</div> // => <div as |foo|>...</div> ``` This is especially problematic in light of wanting to retain the source spans of the block params nodes. This commit rework the block params parsing and integrate it into the normal parsing pass in the appropiate time.
part of #1490
made it backwards compatible