-
Notifications
You must be signed in to change notification settings - Fork 915
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
[labs/analyzer] Add template utils to analyzer and use them in the compiler #4261
Conversation
🦋 Changeset detectedLatest commit: 6bf89aa The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📊 Tachometer Benchmark ResultsSummarynop-update
render
update
update-reflect
Resultsthis-change
render
update
update-reflect
this-change, tip-of-tree, previous-release
render
update
nop-update
this-change, tip-of-tree, previous-release
render
update
this-change, tip-of-tree, previous-release
render
update
update-reflect
|
The size of lit-html.js and lit-core.min.js are as expected. |
) { | ||
const name = node.expression.left.name.getText(); | ||
const name = statement.expression.left.name.getText(); |
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.
here and elsewhere: getText() is almost always a mistake to call outside of debug statements, because it exists on every node but doesn't have a reasonable value for a lot of them (and when called on artificial nodes that weren't in the original source code it may throw an error)
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.
This is already used in a bunch of places. I can file an issue to change them.
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.
Yeah, we should honestly add a lint rule to catch and prevent calls to getText(). We did that on the internal version of grimlock and it prevented a bunch of issues.
Andrew actually ran into an issue today where .getText() did the wrong thing (when called on a SourceFile it doesn't include all the content of the file (!), it misses leading comments. SourceFile has a .text property with the full text of the file)
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.
48032bd
to
b4c6ae2
Compare
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.
LGTM, but for reals, every .getText() is a bug waiting to happen
Builds on #4260 (for use in tests)
This moves the
isLitTaggedTemplateExpression
template utility from the compiler to the analyzer. The analyzer will need these same utilities to detect lit-html template expressions for template analysis.