-
Notifications
You must be signed in to change notification settings - Fork 231
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
WIP(schema-wasm): support schema split into multiple files #4787
Merged
Commits on Mar 21, 2024
-
Implement multi-file schema handling in PSL
This commit implements multi-file schema handling in the Prisma Schema Language. At a high level, instead of accepting a single string, `psl::validate_multi_file()` is an alternative to `psl::validate()` that accepts something morally equivalent to: ```json { "./prisma/schema/a.prisma": "datasource db { ... }", "./prisma/schema/nested/b.prisma": "model Test { ... }" } ``` There are tests for PSL validation with multiple schema files, but most of the rest of engines still consumes the single file version of `psl::validate()`. The implementation and the return type are shared between `psl::validate_multi_file()` and `psl::validate()`, so the change is completely transparent, other than the expectation of passing in a list of (file_name, file_contents) instead of a single string. The `psl::validate()` entry point should behave exactly the same as `psl::multi_schema()` with a single file named `schema.prisma`. In particular, it has the exact same return type. Implementation ============== This is achieved by extending `Span` to contain, in addition to a start and end offset, a `FileId`. The `FileId` is a unique identifier for a file and its parsed `SchemaAst` inside `ParserDatabase`. The identifier types for AST items in `ParserDatabase` are also extended to contain the `FileId`, so that they can be uniquely referred to in the context of the (multi-file) schema. After the analysis phase (the `parser_database` crate), consumers of the analyzed schema become multi-file aware completely transparently, no change is necessary in the other engines. The only changes that will be required at scattered points across the codebase are the `psl::validate()` call sites that will need to receive a `Vec<Box<Path>, SourceFile>` instead of a single `SourceFile`. This PR does _not_ deal with that, but it makes where these call sites are obvious by what entry points they use: `psl::validate()`, `psl::parse_schema()` and the various `*_assert_single()` methods on `ParserDatabase`. The PR contains tests confirming that schema analysis, validation and displaying diagnostics across multiple files works as expected. Status of this PR ================= This is going to be directly mergeable after review, and it will not affect the current schema handling behaviour when dealing with a single schema file. Next steps ========== - Replace all calls to `psl::validate()` with calls to `psl::validate_multi_file()`. - The `*_assert_single()` calls should be progressively replaced with their multi-file counterparts across engines. - The language server should start sending multiple files to prisma-schema-wasm in all calls. This is not in the spirit of the language server spec, but that is the most immediate solution. We'll have to make `range_to_span()` in `prisma-fmt` multi-schema aware by taking a FileId param. Links ===== Relevant issue: prisma/prisma#2377 Also see the [internal design doc](https://www.notion.so/prismaio/Multi-file-Schema-24d68fe8664048ad86252fe446caac24?d=68ef128f25974e619671a9855f65f44d#2889a038e68c4fe1ac9afe3cd34978bd).
Configuration menu - View commit details
-
Copy full SHA for 1e42d35 - Browse repository at this point
Copy the full SHA 1e42d35View commit details
Commits on Mar 22, 2024
-
Configuration menu - View commit details
-
Copy full SHA for aad9355 - Browse repository at this point
Copy the full SHA aad9355View commit details
Commits on Mar 26, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 0128219 - Browse repository at this point
Copy the full SHA 0128219View commit details
Commits on Apr 2, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 4ff6406 - Browse repository at this point
Copy the full SHA 4ff6406View commit details -
Configuration menu - View commit details
-
Copy full SHA for ad12e21 - Browse repository at this point
Copy the full SHA ad12e21View commit details
Commits on Apr 4, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 11925e2 - Browse repository at this point
Copy the full SHA 11925e2View commit details -
Configuration menu - View commit details
-
Copy full SHA for ea3adb0 - Browse repository at this point
Copy the full SHA ea3adb0View commit details
Commits on Apr 5, 2024
-
Configuration menu - View commit details
-
Copy full SHA for 49e66e0 - Browse repository at this point
Copy the full SHA 49e66e0View commit details -
Configuration menu - View commit details
-
Copy full SHA for 408a77a - Browse repository at this point
Copy the full SHA 408a77aView commit details -
Co-authored-by: Serhii Tatarintsev <tatarintsev@prisma.io>
Configuration menu - View commit details
-
Copy full SHA for d804fd3 - Browse repository at this point
Copy the full SHA d804fd3View commit details -
Configuration menu - View commit details
-
Copy full SHA for c34d7b5 - Browse repository at this point
Copy the full SHA c34d7b5View commit details -
Configuration menu - View commit details
-
Copy full SHA for 39a2742 - Browse repository at this point
Copy the full SHA 39a2742View commit details
Commits on Apr 8, 2024
-
Configuration menu - View commit details
-
Copy full SHA for b3409f4 - Browse repository at this point
Copy the full SHA b3409f4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 751b1c8 - Browse repository at this point
Copy the full SHA 751b1c8View commit details -
Configuration menu - View commit details
-
Copy full SHA for e32d0dd - Browse repository at this point
Copy the full SHA e32d0ddView commit details
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.