-
Couldn't load subscription status.
- Fork 11
feat: vscode extension #23
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
WalkthroughThis update introduces a new VSCode extension for the ZenStack ZModel language, including its extension and language server implementations, configuration, and packaging. The build and workspace setups are expanded to support the new IDE package. Enhancements to the language package improve module system compatibility and workspace management, notably with a custom workspace manager for loading standard libraries. Changes
Sequence Diagram(s)sequenceDiagram
participant VSCode
participant Extension (main.ts)
participant LanguageClient
participant LanguageServer (main.ts)
participant Services
VSCode->>Extension (main.ts): Activate extension
Extension (main.ts)->>LanguageClient: Initialize with server module path
LanguageClient->>LanguageServer (main.ts): Start language server process
LanguageServer (main.ts)->>Services: Create language services (includes custom workspace manager)
LanguageClient-->>VSCode: Provide language features (completion, diagnostics, etc.)
VSCode->>Extension (main.ts): Deactivate extension
Extension (main.ts)->>LanguageClient: Stop language client
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration 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.
Actionable comments posted: 5
🔭 Outside diff range comments (1)
packages/ide/vscode/LICENSE (1)
1-2:⚠️ Potential issueLicense file should include actual text instead of a relative path
Referencing../../../LICENSEwon’t resolve in the published extension package. Please embed or copy the full MIT license text here so it’s properly included.
🧹 Nitpick comments (9)
packages/ide/vscode/syntaxes (1)
1-1: Ensure this is a valid symlink or packaged correctly
This appears to be a pointer to the shared syntax definitions, but VSCode expects concrete grammar files under asyntaxesdirectory. Confirm that this is committed as a filesystem symlink (not a plain text file) and that your build/publish process resolves the link so that the extension includes the actual JSON grammars. Otherwise, consider adding a copy step in your build to place thelanguage/syntaxesfiles into the extension'ssyntaxesfolder.packages/ide/vscode/src/language-server/main.ts (1)
1-7: Nit: import fromvscode-languageserver/nodeinstead ofnode.jsThe file extension can be omitted;
vscode-languageserver/nodeis the documented entry and avoids potential bundler resolution quirks.-import { - createConnection, - ProposedFeatures, -} from 'vscode-languageserver/node.js'; +import { createConnection, ProposedFeatures } from 'vscode-languageserver/node';packages/ide/vscode/language-configuration.json (1)
15-22: Block‐comment pair is not auto-closed
autoClosingPairscontains a special entry for/** … */but omits the ordinary/* … */block comment that users will type far more often. Align this list with the language’s comment syntax to avoid a jarring authoring experience.["(", ")"], ["\"", "\""], ["'", "'"], + ["/*", "*/"], { "open": "/**", "close": " */", "notIn": ["string"] }packages/language/src/index.ts (1)
48-56: Avoid recomputing_dirnameon everyloadDocumentinvocation
_dirnameis a module-level constant; putting the calculation inside the function means it is recomputed every time the helper is called. Moving it to the top scope shaves unnecessary work (and clarifies intent).- // isomorphic __dirname - const _dirname = - typeof __dirname !== 'undefined' - ? __dirname - : path.dirname(fileURLToPath(import.meta.url)); +// isomorphic __dirname +const _dirname = + typeof __dirname !== 'undefined' + ? __dirname + : path.dirname(fileURLToPath(import.meta.url)); + +… + + // load standard library.vscode/launch.json (1)
48-70: Globs inoutFileslack a wildcard and may break source-map lookup
"${workspaceFolder}/packages/ide/vscode/node_modules/langium"points to a folder, not to compiled.jsfiles.
VS Code’s debugger expects a glob such as**/*.js; without it, breakpoints inside Langium sources won’t bind.- "${workspaceFolder}/packages/ide/vscode/node_modules/langium" + "${workspaceFolder}/packages/ide/vscode/node_modules/langium/**/*.js"packages/language/src/module.ts (1)
55-64: Redundant type alias can be dropped
export type ZModelSharedServices = LangiumSharedServices;is a straight alias with no added semantic meaning and risks bit-rot if the upstream type changes. Unless it’s required by external consumers, consider removing the alias and usingLangiumSharedServicesdirectly.packages/language/src/zmodel-workspace-manager.ts (3)
55-58: Avoidconsole.login library codeLanguage-server output should be routed through the LSP connection’s logger or
services.loggerso that messages appear in the client’s output channel and respect user log-level preferences.- console.log( - `Found installed zenstack package stdlib at: ${installedStdlibPath}` - ); + this.services.shared.logger.debug( + () => `Found installed zenstack package stdlib at: ${installedStdlibPath}` + );
60-63: RedundantcontinuestatementThe
continueat the end of thecatchblock is unnecessary; control flow proceeds to the next iteration anyway.- } catch (error) { - // Package not found or other error, continue to next folder - continue; - } + } catch { + // Package not found, try next folder + }🧰 Tools
🪛 Biome (1.9.4)
[error] 62-62: Unnecessary continue statement
Unsafe fix: Delete the unnecessary continue statement
(lint/correctness/noUnnecessaryContinue)
80-82: Potential duplicate loading of stdlib document
loadAdditionalDocumentsis invoked for every workspace refresh. Without a guard, the samestdlibdocument can be collected repeatedly, wasting memory and analysis time. Consider caching the URI or checkingdocuments.has(uri)before collecting.
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
⛔ Files ignored due to path filters (4)
packages/ide/vscode/asset/logo-256-bg.pngis excluded by!**/*.pngpackages/ide/vscode/asset/logo-dark-256.pngis excluded by!**/*.pngpackages/ide/vscode/asset/logo-light-256.pngis excluded by!**/*.pngpnpm-lock.yamlis excluded by!**/pnpm-lock.yaml
📒 Files selected for processing (18)
.vscode/launch.json(1 hunks)package.json(1 hunks)packages/ide/vscode/.gitignore(1 hunks)packages/ide/vscode/LICENSE(1 hunks)packages/ide/vscode/language-configuration.json(1 hunks)packages/ide/vscode/package.json(1 hunks)packages/ide/vscode/res(1 hunks)packages/ide/vscode/src/extension/main.ts(1 hunks)packages/ide/vscode/src/language-server/main.ts(1 hunks)packages/ide/vscode/syntaxes(1 hunks)packages/ide/vscode/tsconfig.json(1 hunks)packages/ide/vscode/tsup.config.ts(1 hunks)packages/language/package.json(2 hunks)packages/language/src/index.ts(1 hunks)packages/language/src/module.ts(4 hunks)packages/language/src/zmodel-workspace-manager.ts(1 hunks)packages/language/tsup.config.ts(1 hunks)pnpm-workspace.yaml(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (4)
packages/language/src/index.ts (1)
packages/language/src/constants.ts (1)
STD_LIB_MODULE_NAME(30-30)
packages/language/src/module.ts (2)
packages/language/src/zmodel-workspace-manager.ts (1)
ZModelWorkspaceManager(15-83)packages/language/src/generated/module.ts (1)
ZModelGeneratedSharedModule(17-19)
packages/language/src/zmodel-workspace-manager.ts (1)
packages/language/src/constants.ts (1)
STD_LIB_MODULE_NAME(30-30)
packages/ide/vscode/src/language-server/main.ts (1)
packages/language/src/module.ts (1)
createZModelLanguageServices(81-105)
🪛 Biome (1.9.4)
packages/language/src/zmodel-workspace-manager.ts
[error] 62-62: Unnecessary continue statement
Unsafe fix: Delete the unnecessary continue statement
(lint/correctness/noUnnecessaryContinue)
⏰ Context from checks skipped due to timeout of 90000ms (2)
- GitHub Check: build-test (20.x)
- GitHub Check: Analyze (javascript-typescript)
🔇 Additional comments (9)
pnpm-workspace.yaml (1)
7-7: Approve inclusion of IDE packages
Addingpackages/ide/**ensures the newly introduced VSCode extension and any future IDE tools are recognized by pnpm workspace.packages/language/package.json (2)
8-10: Include resource directory for packaging
Adding"res"to thefilesarray guarantees the standard library assets are bundled alongsidedist.
23-42: Verify dual module export mappings
Ensure that both ESM (.js/.d.ts) and CJS (.cjs/.d.cts) files exist post-build for the.and./astexports. Mismatches will cause runtime resolution failures.package.json (1)
16-16: Update project license to MIT
Changing the root license field from ISC to MIT aligns with the repository’s license and downstream packages.packages/ide/vscode/res (1)
1-1: Verify resource link and packaging configuration.Ensure the relative path (
../../language/res) resolves correctly in the published VSCode extension across all platforms. Confirm that both this file and the targetlanguage/resdirectory are included via yourpackage.jsonfilesfield and bundler settings.packages/ide/vscode/.gitignore (1)
1-1: Verify.gitignoreexclusion does not drop grammar files from the VSIX
vsceuses.gitignoreas a basis for packaging filters.
If thesyntaxes/directory (or a symlink pointing to the grammar) is ignored here, the compiled VSIX may miss thezmodel.tmLanguage.json, breaking syntax highlighting for users.Confirm that the grammar is still included in the published extension (or move the rule to
.vscodeignore, which is safer for VSIX packaging).packages/ide/vscode/tsconfig.json (1)
1-7: Looks good – baseline TS config is minimal but sufficientThe file cleanly extends the repo-level
tsconfig.jsonand only overridesoutDir, keeping the IDE package simple.
No issues spotted.packages/language/tsup.config.ts (1)
13-13: Double-check package.jsonexportsafter adding CommonJS build
format: ['esm', 'cjs']will emit two artifact sets. Ensurepackages/language/package.jsonnow exposes arequirepath (e.g."./dist/index.cjs"or"./dist/index.js"under"default"/"require"fields) so downstream Node consumers resolve the intended file instead of the ESM build by accident.packages/ide/vscode/package.json (1)
18-19: Bundlevscelocally or call it viapnpm dlxThe publish / package scripts assume that
vsceis globally installed. CI/CD or new contributors may not have it, causing the task to fail.Either:
- "vscode:publish": "pnpm build && vsce publish --no-dependencies --pre-release --follow-symlinks", - "vscode:package": "pnpm build && vsce package --no-dependencies" + "vscode:publish": "pnpm build && pnpm dlx vsce publish --no-dependencies --pre-release --follow-symlinks", + "vscode:package": "pnpm build && pnpm dlx vsce package --no-dependencies"or add
"vsce": "^3.23.0"todevDependencies.
Summary by CodeRabbit