-
-
Notifications
You must be signed in to change notification settings - Fork 12
fix(lsp): get language server on par with v2 #379
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
Conversation
|
Note Other AI code review bot(s) detectedCodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review. WalkthroughAdds multiple LSP providers, a code action, completion logic, formatter and comment/documentation/semantic tooling to the language package; adjusts exports and imports for ZModelCodeGenerator, updates dependencies and TS config, bumps the VSCode extension version, tweaks validators, and enriches server RPC error payloads. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
Claude finished @ymc9's task —— View job PR Review: Language Server ImprovementsI've completed my review of this pull request that brings the language server functionality up to par with v2. Here's my comprehensive feedback: ✅ Positive Aspects1. Code Quality & Architecture
2. Comprehensive Language Server Features
3. Integration Quality
|
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.
Pull Request Overview
This PR adds comprehensive Language Server Protocol (LSP) support to the ZModel language, enabling enhanced IDE features such as code completion, formatting, semantic highlighting, and quick fixes. The changes also refactor the code generator organization by moving ZModelCodeGenerator from the sdk package to the language package where it's more appropriately placed alongside other language infrastructure.
Key Changes:
- Addition of LSP providers for completion, formatting, semantic tokens, documentation, definitions, and code actions
- Migration of
ZModelCodeGeneratorfrom@zenstackhq/sdkto@zenstackhq/languagepackage - Addition of
vscode-languageserverdependency for LSP type definitions - Improved plugin document loading logic to avoid reloading already-loaded plugins
Reviewed Changes
Copilot reviewed 18 out of 19 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| pnpm-lock.yaml | Adds vscode-languageserver@9.0.1 dependency |
| packages/server/src/api/rpc/index.ts | Adds reason field to ORM error responses for better error handling |
| packages/sdk/src/prisma/prisma-schema-generator.ts | Updates import path for ZModelCodeGenerator after its move to language package |
| packages/sdk/src/index.ts | Removes re-export of ZModelCodeGenerator after migration |
| packages/language/tsconfig.json | Disables noUnusedLocals to accommodate decorator parameters and method overrides |
| packages/language/src/zmodle-comment-provider.ts | New file providing default comments for language elements (filename has typo) |
| packages/language/src/zmodel-semantic.ts | New provider for semantic token highlighting |
| packages/language/src/zmodel-formatter.ts | New provider for document formatting with custom ZModel rules |
| packages/language/src/zmodel-documentation-provider.ts | New provider supporting triple-slash and JSDoc comments |
| packages/language/src/zmodel-definition.ts | New provider for go-to-definition support including import resolution |
| packages/language/src/zmodel-completion-provider.ts | New comprehensive completion provider with context-aware suggestions |
| packages/language/src/zmodel-code-generator.ts | Updates imports after file relocation from sdk package |
| packages/language/src/zmodel-code-action.ts | New provider for quick fixes, including missing opposite relation fix |
| packages/language/src/validators/function-invocation-validator.ts | Removes obsolete @ts-expect-error comments |
| packages/language/src/validators/attribute-application-validator.ts | Removes obsolete @ts-expect-error comments |
| packages/language/src/module.ts | Registers new LSP providers and improves plugin document loading logic |
| packages/language/src/index.ts | Exports ZModelCodeGenerator for external use |
| packages/language/package.json | Adds vscode-languageserver dependency |
| packages/ide/vscode/package.json | Version bump to 3.0.12 |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Claude finished @ymc9's task —— View job 📋 PR Review: Language Server ImprovementsI've completed a comprehensive review of this pull request that brings the language server functionality up to par with v2. Here's my detailed analysis: ✅ Positive AspectsCode Quality & Architecture
Comprehensive Language Server Features
Integration Quality
|
|
fixes #313 |
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.
Actionable comments posted: 2
🧹 Nitpick comments (3)
packages/language/tsconfig.json (1)
4-6: Consider keeping strictnoUnusedLocalschecks with alternative approaches.Disabling
noUnusedLocalsmasks potential dead code or incomplete implementations. Rather than relaxing the check globally, prefer to:
- Use the
_prefix convention for intentionally unused variables (e.g.,_unused)- Remove actual unused code if it's not needed
- Clearly document if there's a temporary reason for the permissive setting
This is particularly important given the large surface area of new LSP features in this PR.
packages/server/src/api/rpc/index.ts (1)
192-194: Good addition - improves error response context.Adding the
reasonfield to the error payload allows API consumers to programmatically handle different error types without parsing error messages.Optional: Consider adding an explicit type for the error payload.
The
anytype for the error object reduces type safety. Consider defining an interface for the error response structure:interface ErrorResponse { message: string; reason: ORMErrorReason; model?: string; rejectedByValidation?: boolean; rejectedByPolicy?: boolean; rejectReason?: string; dbErrorCode?: string; }Then replace line 194:
-const error: any = { message: err.message, reason: err.reason }; +const error: ErrorResponse = { message: err.message, reason: err.reason };packages/language/src/zmodel-semantic.ts (1)
65-78: Use type tokens for referenced field typesWhen a field type resolves through
node.reference, it still represents a type (model/enum/typedef), but we classify it as a macro. That causes those identifiers to be colored differently from other type references. Please switch this branch to emitSemanticTokenTypes.typefor consistency with intrinsic types and data model declarations.Apply this diff:
- } else if (isDataFieldType(node)) { - if (node.type) { - acceptor({ - node, - property: 'type', - type: SemanticTokenTypes.type, - }); - } else { - acceptor({ - node, - property: 'reference', - type: SemanticTokenTypes.macro, - }); - } + } else if (isDataFieldType(node)) { + if (node.type) { + acceptor({ + node, + property: 'type', + type: SemanticTokenTypes.type, + }); + } else { + acceptor({ + node, + property: 'reference', + type: SemanticTokenTypes.type, + }); + }
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (1)
pnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (18)
packages/ide/vscode/package.json(1 hunks)packages/language/package.json(1 hunks)packages/language/src/index.ts(1 hunks)packages/language/src/module.ts(3 hunks)packages/language/src/validators/attribute-application-validator.ts(0 hunks)packages/language/src/validators/function-invocation-validator.ts(0 hunks)packages/language/src/zmodel-code-action.ts(1 hunks)packages/language/src/zmodel-code-generator.ts(1 hunks)packages/language/src/zmodel-completion-provider.ts(1 hunks)packages/language/src/zmodel-definition.ts(1 hunks)packages/language/src/zmodel-documentation-provider.ts(1 hunks)packages/language/src/zmodel-formatter.ts(1 hunks)packages/language/src/zmodel-semantic.ts(1 hunks)packages/language/src/zmodle-comment-provider.ts(1 hunks)packages/language/tsconfig.json(1 hunks)packages/sdk/src/index.ts(0 hunks)packages/sdk/src/prisma/prisma-schema-generator.ts(2 hunks)packages/server/src/api/rpc/index.ts(1 hunks)
💤 Files with no reviewable changes (3)
- packages/sdk/src/index.ts
- packages/language/src/validators/function-invocation-validator.ts
- packages/language/src/validators/attribute-application-validator.ts
🧰 Additional context used
🧬 Code graph analysis (6)
packages/language/src/zmodel-definition.ts (2)
packages/language/src/generated/ast.ts (1)
isModelImport(579-581)packages/language/src/utils.ts (1)
resolveImport(398-416)
packages/language/src/zmodle-comment-provider.ts (1)
packages/language/src/generated/ast.ts (5)
isDataModel(391-393)isTypeDef(737-739)isEnumField(446-448)isDataField(344-346)isFunctionDecl(475-477)
packages/language/src/zmodel-semantic.ts (1)
packages/language/src/generated/ast.ts (19)
isDataModel(391-393)isDataSource(417-419)isGeneratorDecl(516-518)isPlugin(628-630)isTypeDef(737-739)isDataField(344-346)isConfigField(303-305)isAttributeArg(221-223)isPluginField(641-643)isEnumField(446-448)isDataFieldType(373-375)isDataModelAttribute(404-406)isDataFieldAttribute(357-359)isInternalAttribute(529-531)isInvocationExpr(542-544)isFunctionDecl(475-477)isAttribute(208-210)isReferenceExpr(697-699)isMemberAccessExpr(555-557)
packages/language/src/module.ts (6)
packages/language/src/zmodel-formatter.ts (1)
ZModelFormatter(7-114)packages/language/src/zmodel-definition.ts (1)
ZModelDefinitionProvider(7-37)packages/language/src/zmodel-completion-provider.ts (1)
ZModelCompletionProvider(35-397)packages/language/src/zmodel-semantic.ts (1)
ZModelSemanticTokenProvider(27-111)packages/language/src/zmodle-comment-provider.ts (1)
ZModelCommentProvider(5-21)packages/language/src/zmodel-documentation-provider.ts (1)
ZModelDocumentationProvider(6-15)
packages/language/src/zmodel-code-action.ts (4)
packages/language/src/zmodel-formatter.ts (1)
ZModelFormatter(7-114)packages/language/src/validators/datamodel-validator.ts (1)
MissingOppositeRelationData(494-503)packages/language/src/generated/ast.ts (1)
isDataModel(391-393)packages/language/src/utils.ts (2)
getAllFields(511-536)getDocument(570-577)
packages/language/src/zmodel-completion-provider.ts (3)
packages/language/src/generated/ast.ts (11)
isDataModelAttribute(404-406)isDataFieldAttribute(357-359)isArrayExpr(193-195)isMemberAccessExpr(555-557)isEnumField(446-448)isInvocationExpr(542-544)isFunctionDecl(475-477)isDataField(344-346)isDataModel(391-393)isTypeDef(737-739)isAttribute(208-210)packages/language/src/utils.ts (1)
isEnumFieldReference(136-138)packages/language/src/zmodel-code-generator.ts (1)
ZModelCodeGenerator(72-389)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (4)
- GitHub Check: Agent
- GitHub Check: build-test (20.x, sqlite)
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: claude-review
🔇 Additional comments (1)
packages/ide/vscode/package.json (1)
4-4: Version bump is appropriate for LSP improvements.The patch version increment (3.0.11 → 3.0.12) correctly reflects the bug-fix nature of the LSP enhancements. Since the extension depends on
@zenstackhq/languageviaworkspace:*, it will automatically pick up the new language server providers (formatter, completion, definition, semantic tokens, etc.) from the language package.
|
Claude finished @ymc9's task —— View job 📋 PR Review: Language Server ImprovementsI've completed a comprehensive review of this pull request that brings the language server functionality up to par with v2. Here's my detailed analysis: Review Checklist:
✅ Positive AspectsCode Quality & Architecture
Comprehensive Language Server Features
Integration Quality
|
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.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
packages/language/src/zmodel-formatter.ts(1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
packages/language/src/zmodel-formatter.ts (1)
packages/language/src/module.ts (1)
ZModelLanguageMetaData(27-27)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: build-test (20.x, sqlite)
- GitHub Check: claude-review
- GitHub Check: build-test (20.x, postgresql)
Summary by CodeRabbit
New Features
Bug Fixes
Chores