-
-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
feat: loose parser mode #14691
feat: loose parser mode #14691
Conversation
🦋 Changeset detectedLatest commit: e079744 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
preview: https://svelte-dev-git-preview-svelte-14691-svelte.vercel.app/ this is an automated message |
|
Should we just always parse in loose mode, and push errors to an array as we go? Then, if |
For language tools I'm not interested in where the first error happened. Logic-wise, it's a few if blocks here and there now, and trading those for not throwing directly in certain cases would not give us much (i.e. we trade less code in one place for almost the same additional code in another). So I vote for keeping it as it's now. |
Wouldn't you want to show red squigglies for all the errors? And surely if you don't capture the errors during loose parse you need to do a separate strict parse to show just the first error, so we're not even saving any work? |
Bottom line, in the future it might make sense to have an error property which returns the very first error in case of loose parsing, but that's about it. |
…#2631) This adds support for the Svelte parser with its new loose mode (sveltejs/svelte#14691) and adjusts code paths to make use of it properly. As a result, intellisense should be a lot more useful in situations where code is in the middle of being typed and the Svelte file is in a broken state.
This implements a new option for the parser,
loose
, which means the parser is forgiving with the syntax and tries to continue parsing even if it encounters broken code. It does not parse no matter what, but handles the most common "in the middle of typing" scenarios gracefully.closes #4818
Our language tools can then make use of this to provide better intellisense in more situations.
Before submitting the PR, please make sure you do the following
feat:
,fix:
,chore:
, ordocs:
.packages/svelte/src
, add a changeset (npx changeset
).Tests and linting
pnpm test
and lint the project withpnpm lint