Skip to content

Fixed Shared Files in VS-Code + Some Documentation Updates#2454

Merged
davydkov merged 2 commits intomainfrom
kieron/shared-files-fix
Dec 10, 2025
Merged

Fixed Shared Files in VS-Code + Some Documentation Updates#2454
davydkov merged 2 commits intomainfrom
kieron/shared-files-fix

Conversation

@kieronlanning
Copy link
Copy Markdown
Collaborator

@kieronlanning kieronlanning commented Dec 9, 2025

Checklist

  • I've thoroughly read the latest contribution guidelines.
  • I've rebased my branch onto main before creating this PR.
  • My commit messages follow conventional spec
  • I've added tests to cover my changes (if applicable).
  • I've verified that all new and existing tests have passed locally for mobile, tablet, and desktop screen sizes.
  • My change requires documentation updates.
  • I've updated the documentation accordingly.

Summary by CodeRabbit

  • Documentation

    • Updated Include configuration documentation with clearer guidance on path configuration and new configurable scanning options (maxDepth and fileThreshold).
  • Improvements

    • Enhanced multi-project support to properly manage shared files across projects using include paths, with improved document association and accessibility.

✏️ Tip: You can customize this high-level summary in your review settings.

Copilot AI review requested due to automatic review settings December 9, 2025 14:58
Copy link
Copy Markdown
Contributor

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

This PR fixes shared file handling in VS Code for multi-project workspaces and updates documentation to reflect the correct configuration format. The fix ensures that when multiple projects include the same directory path, both projects can access documents from that shared location, resolving a critical functionality issue in the VS Code extension.

Key changes:

  • Implemented proper shared include path support in LangiumDocuments.projectDocuments() and IndexManager.projectElements()
  • Added comprehensive test coverage for the shared include path scenario
  • Updated documentation to show the correct include: { paths: [...] } config structure instead of the incorrect include: [...] format

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
packages/language-server/src/workspace/LangiumDocuments.ts Modified projectDocuments() to filter documents by project folder and include paths using URI string comparison
packages/language-server/src/workspace/IndexManager.ts Modified projectElements() to include documents from both the project's own folder and configured include paths
packages/language-server/src/workspace/ProjectsManager.spec.ts Added test case verifying that multiple projects can share the same include path and access shared documents
apps/docs/src/content/docs/dsl/Config/multi-projects.mdx Updated documentation example to show correct include: { paths: [...] } structure
apps/docs/src/content/docs/dsl/Config/index.mdx Updated documentation to show correct include configuration structure and added details about maxDepth and fileThreshold options

return true
}

// Check for addtional documents when the config has the `include:paths` property set.
Copy link

Copilot AI Dec 9, 2025

Choose a reason for hiding this comment

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

Spelling error: "addtional" should be "additional".

Suggested change
// Check for addtional documents when the config has the `include:paths` property set.
// Check for additional documents when the config has the `include:paths` property set.

Copilot uses AI. Check for mistakes.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Dec 9, 2025

📝 Walkthrough

Walkthrough

The PR updates documentation for the Include configuration structure and implements project-aware document inclusion logic in the language server workspace manager. Document filtering shifts from ID-based matching to path-based scope that respects both project folders and configured include paths.

Changes

Cohort / File(s) Summary
Documentation updates
apps/docs/src/content/docs/dsl/Config/index.mdx, apps/docs/src/content/docs/dsl/Config/multi-projects.mdx
Updated include configuration examples and descriptions from simple array format to structured object with paths property; added documentation for configurable scanning behavior including maxDepth and fileThreshold options
Workspace document filtering
packages/language-server/src/workspace/IndexManager.ts, packages/language-server/src/workspace/LangiumDocuments.ts
Implemented project-aware document inclusion: refactored filtering logic to use path-based scope matching that includes documents from project folders and configured include paths, replacing ID-only equality checks
Test coverage
packages/language-server/src/workspace/ProjectsManager.spec.ts
Added test case verifying that multiple projects can share the same include path and correctly associate shared documents to their respective projects

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • LangiumDocuments.ts requires careful review of the path-based filtering logic and inclusion scope determination
  • IndexManager.ts changes to URI filtering and include path normalization need verification for edge cases (trailing slashes, path resolution)
  • ProjectsManager.spec.ts includes a duplicated test block that should be verified as intentional or removed
  • Path matching logic across both workspace files should be validated for consistency and correctness with relative path handling

Possibly related PRs

Suggested reviewers

  • davydkov

Poem

🐰 Include paths now guide the way,
No more IDs to hold the day,
Projects share their common ground,
Documents dance and files are found,
Workspace hops with newfound grace!

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: fixing shared file handling in VS-Code with accompanying documentation updates, matching the changeset contents.
Description check ✅ Passed The PR description completes all required checklist items indicating the contributor followed guidelines, rebased, used conventional commits, added tests, verified test passage, and updated documentation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch kieron/shared-files-fix

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (2)
packages/language-server/src/workspace/IndexManager.ts (1)

29-34: Simplify the empty array check.

The includePathStrings.length > 0 guard is redundant since Array.prototype.some() already returns false for empty arrays.

Apply this diff to simplify:

       .filter(uri => {
         const belongsToProject = projects.belongsTo(uri) === projectId
-        const inIncludePath = includePathStrings.length > 0 &&
-          includePathStrings.some(includePath => uri.startsWith(includePath))
+        const inIncludePath = includePathStrings.some(includePath => uri.startsWith(includePath))
         return (belongsToProject || inIncludePath) && (!uris || uris.has(uri))
       })
packages/language-server/src/workspace/LangiumDocuments.ts (1)

95-97: Consider removing redundant empty array check for consistency.

Similar to the pattern in IndexManager.ts, the includePathStrings.length > 0 check is redundant since Array.prototype.some() returns false for empty arrays.

-      if (includePathStrings.length > 0) {
-        return includePathStrings.some(includePath => docUri.startsWith(includePath))
-      }
-
-      return false
+      return includePathStrings.some(includePath => docUri.startsWith(includePath))
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 2768240 and 860fa2f.

📒 Files selected for processing (5)
  • apps/docs/src/content/docs/dsl/Config/index.mdx (2 hunks)
  • apps/docs/src/content/docs/dsl/Config/multi-projects.mdx (1 hunks)
  • packages/language-server/src/workspace/IndexManager.ts (1 hunks)
  • packages/language-server/src/workspace/LangiumDocuments.ts (1 hunks)
  • packages/language-server/src/workspace/ProjectsManager.spec.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (4)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use pnpm ci:typecheck for TypeScript type checking across all packages except documentation

Files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
  • packages/language-server/src/workspace/IndexManager.ts
  • packages/language-server/src/workspace/LangiumDocuments.ts
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use oxlint with type-aware rules for linting instead of eslint, and run pnpm ci:lint to validate all packages except documentation

Files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
  • packages/language-server/src/workspace/IndexManager.ts
  • packages/language-server/src/workspace/LangiumDocuments.ts
**/*.{ts,tsx,js,jsx,json,md}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use pnpm fmt to format code with dprint instead of Prettier or eslint for formatting

Files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
  • packages/language-server/src/workspace/IndexManager.ts
  • packages/language-server/src/workspace/LangiumDocuments.ts
packages/*/**/!(node_modules)/**/*.spec.ts

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Unit tests must be located in packages/*/src/**/*.spec.ts or packages/*/src/**/__test__/*.spec.ts files

Files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
🧠 Learnings (1)
📚 Learning: 2025-12-05T15:36:11.968Z
Learnt from: CR
Repo: likec4/likec4 PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-12-05T15:36:11.968Z
Learning: Applies to packages/*/**/!(node_modules)/**/*.spec.ts : Unit tests must be located in `packages/*/src/**/*.spec.ts` or `packages/*/src/**/__test__/*.spec.ts` files

Applied to files:

  • packages/language-server/src/workspace/ProjectsManager.spec.ts
🧬 Code graph analysis (2)
packages/language-server/src/workspace/ProjectsManager.spec.ts (7)
packages/language-server/src/test/testServices.ts (1)
  • createMultiProjectTestServices (190-256)
packages/likec4/src/LikeC4.ts (1)
  • projectsManager (166-168)
packages/language-server/src/workspace/LangiumDocuments.ts (1)
  • addDocument (28-39)
packages/language-server/src/model/fqn-index.ts (1)
  • documents (59-64)
packages/language-server/src/model/model-parser.ts (1)
  • documents (97-101)
packages/language-server/src/model/model-builder.ts (1)
  • documents (300-302)
packages/language-server/src/model/model-locator.ts (1)
  • documents (47-49)
packages/language-server/src/workspace/IndexManager.ts (1)
packages/language-server/src/LikeC4LanguageServices.ts (2)
  • project (154-175)
  • projects (105-152)
🪛 GitHub Check: SonarCloud Code Analysis
packages/language-server/src/workspace/IndexManager.ts

[warning] 31-31: The non-empty check is useless as Array#some() returns false for an empty array.

See more on https://sonarcloud.io/project/issues?id=likec4_likec4&issues=AZsDn7HSeL1l2F4_Mi8r&open=AZsDn7HSeL1l2F4_Mi8r&pullRequest=2454

⏰ 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). (7)
  • GitHub Check: checks / 🔬 e2e types
  • GitHub Check: checks / 📖 docs
  • GitHub Check: checks / 🔬 e2e tests
  • GitHub Check: Agent
  • GitHub Check: CodeQL analysis (javascript-typescript)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: checks / ⊞ windows build
🔇 Additional comments (6)
packages/language-server/src/workspace/IndexManager.ts (1)

18-36: LGTM!

The project-aware inclusion logic correctly extends URI filtering to include documents from both the project folder and configured include paths. The trailing slash normalization ensures consistent path matching.

apps/docs/src/content/docs/dsl/Config/multi-projects.mdx (1)

68-150: LGTM!

The documentation clearly explains the updated include configuration structure with the paths array, and the new scanning options (maxDepth, fileThreshold) are well-documented with sensible defaults and usage tips.

apps/docs/src/content/docs/dsl/Config/index.mdx (1)

59-113: LGTM!

The documentation updates consistently reflect the new object-based include configuration structure and provide clear examples for both basic and advanced scanning behavior options.

packages/language-server/src/workspace/ProjectsManager.spec.ts (1)

502-543: LGTM!

The test thoroughly validates the shared include path scenario:

  1. Verifies project-specific document ownership
  2. Correctly allows the shared document to belong to either project or default
  3. Confirms both projects can access the shared document via projectDocuments

This aligns well with the implementation changes in IndexManager.ts and LangiumDocuments.ts.

packages/language-server/src/workspace/LangiumDocuments.ts (2)

76-101: LGTM!

The projectDocuments method correctly implements path-based inclusion logic that aligns with the IndexManager.ts changes. Documents from the project folder are always included, and documents from configured include paths are included when specified.


80-84: The conditional check on line 80 is necessary and should not be removed. While folderUri for registered projects is normalized via ProjectFolder() to include a trailing slash, the default project's folderUri is obtained directly from WorkspaceManager.workspaceUri (or URI.file('/') as fallback) without going through the ProjectFolder() normalization. The defensive check handles both cases correctly.

Likely an incorrect or invalid review comment.

return true
}

// Check for addtional documents when the config has the `include:paths` property set.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix typo in comment.

"addtional" should be "additional".

-      // Check for addtional documents when the config has the `include:paths` property set.
+      // Check for additional documents when the config has the `include:paths` property set.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// Check for addtional documents when the config has the `include:paths` property set.
// Check for additional documents when the config has the `include:paths` property set.
🤖 Prompt for AI Agents
In packages/language-server/src/workspace/LangiumDocuments.ts around line 94,
the inline comment has a typo: "addtional" should be corrected to "additional";
update the comment text to read "Check for additional documents when the config
has the `include:paths` property set." to fix spelling while preserving intent
and formatting.

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.

3 participants