Repository navigation
Fix workspace folder URI resolution for SCM-backed projects - #448
Henrik Hartvig Jensen (HHartvig) wants to merge 8 commits into
Conversation
custom agents
There was a problem hiding this comment.
🟡 Changes recommended
One or more issues must be addressed before approval.
Get a fresh assessment by requesting another Copilot review.
Pull request overview
Fixes workspace folder URI resolution for SCM-backed and virtual projects.
Changes:
- Adds resource URI resolution with local, remote, and platform fallbacks.
- Uses the resolver when creating LSP workspace folders.
- Adds unit tests for resolution branches.
File summaries
| File | Description |
|---|---|
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/utils/WorkspaceUtils.java | Updated as part of this pull request. |
| com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/utils/FileUtils.java | Updated as part of this pull request. |
| com.microsoft.copilot.eclipse.core.test/src/com/microsoft/copilot/eclipse/core/utils/FileUtilsTests.java | Updated as part of this pull request. |
Review details
Suppressed comments (2)
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/utils/FileUtils.java:120
- This method duplicates the complete resolution sequence already implemented by
getResourceUri(IResource)above. Keeping two copies lets future URI fixes diverge; the fallback behavior is already different (toPortableString()here versustoString()there). Make one method delegate to the other and only convert to/from the string form at the boundary.
// Try standard file location first
if (resource.getLocation() != null) {
URI uri = LSPEclipseUtils.toUri(resource);
if (uri != null) {
return uri;
com.microsoft.copilot.eclipse.core/src/com/microsoft/copilot/eclipse/core/utils/WorkspaceUtils.java:95
- The changed workspace-folder path is not covered by a
WorkspaceUtilstest: the new tests exerciseFileUtils.getResourceAsUridirectly, but none verifies thatlistWorkspaceFolders()passes an SCM/virtual project's resolved URI into itsWorkspaceFolder. A regression in this integration point would therefore still pass the test suite; add a focused test for this method.
URI uri = FileUtils.getResourceAsUri(project);
if (uri != null) {
WorkspaceFolder folder = new WorkspaceFolder();
folder.setUri(uri.toASCIIString());
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
|
@microsoft-github-policy-service agree company="Danske Bank" |
|
Hi Henrik Hartvig Jensen (@HHartvig), Please check the CI failure, thank you. |
|
For some reason a merge was not merged correctly, that has been updated now. Should build now. |
Problem
WorkspaceUtils.listWorkspaceFolders()usedproject.getLocationURI()directly tobuild LSP
WorkspaceFolderentries. For projects backed by a source-control provider(e.g.
semanticfs://,sourcecontrol://), this could return a URI that didn't matchwhat the rest of the codebase expects, since it bypassed the same file-URI resolution
used elsewhere (
LSPEclipseUtils.toUri()+ platform-resource fallback).This made add custom agents fail, making it impossible to add custom agents on non git repos.
Solution
FileUtils.getResourceAsUri(IResource), a resource-agnostic version of theexisting URI resolution logic: prefers
LSPEclipseUtils.toUri()when the resourcehas a local
getLocation(), falls back togetLocationURI()for remote/virtualresources, and finally falls back to a
platform:/resource...URI built from theresource's portable full path.
WorkspaceUtils.listWorkspaceFolders()to useFileUtils.getResourceAsUri()instead of calling
project.getLocationURI()directly, so workspace folders areresolved consistently with the rest of the codebase regardless of the project's
backing storage/SCM provider.
Testing
Added unit tests in
FileUtilsTestscovering all resolution branches ofgetResourceAsUri:getLocation()→ returns theLSPEclipseUtils-resolved URIgetLocation()resolves to afile://URI derived from the absolutepath, even when
getLocationURI()reports a different SCM scheme (locally-backedresource takes priority)
getLocation()but withgetLocationURI()→ returns that URI directlyplatform:/resource...URIRan
.\mvnw test— all tests pass.