Skip to content

Conversation

sailingKieler
Copy link
Contributor

@msujew here's my proposal on a refinement of DocumentBuilder.waitUntil(...) as discussed.

Is the way of reporting wrong pre-conditions via rejecting with ResponseErrors the way to go?
I enforced them with VS Code but didn't see any outputs in the log or did notice any UI pop-ups...

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Refines the waitUntil method in DocumentBuilder to support waiting for specific documents to reach required states, with improved error handling and immediate resolution when documents are already in the required state.

  • Separates document-specific waiting logic from general builder state waiting
  • Adds comprehensive error handling for missing documents and invalid state transitions
  • Includes a test case to verify the new behavior fires immediately when a document reaches the required state

Reviewed Changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
packages/langium/src/workspace/document-builder.ts Splits waitUntil into separate methods for document and builder state waiting, adds error handling with ResponseError
packages/langium/test/workspace/document-builder.test.ts Adds test case to verify immediate firing when document reaches required state
packages/langium/src/lsp/language-server.ts Ensures workspace manager is ready before waiting for document states

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

if (!document) {
return Promise.reject(
new ResponseError(
LSPErrorCodes.ServerCancelled,
Copy link
Preview

Copilot AI Sep 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using LSPErrorCodes.ServerCancelled for a missing document is semantically incorrect. This error code indicates the server cancelled the request, not that a document wasn't found. Consider using LSPErrorCodes.RequestFailed or LSPErrorCodes.InternalError instead.

Suggested change
LSPErrorCodes.ServerCancelled,
LSPErrorCodes.RequestFailed,

Copilot uses AI. Check for mistakes.

… document reaches required state

added corresponding test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant