fix(dart): omit rootUri/rootPath (#2045) (#2051)

The Dart analysis server treats rootUri as an additional analysis root on top of
workspaceFolders, with no de-duplication, so on a monorepo root the whole tree is
analysed and the server burns CPU at idle. Always omit rootUri/rootPath and rely on
workspaceFolders alone.
This commit is contained in:
Max authored and GitHub committed 2026-09-21 21:57:33 +02:00
1 parent 24068f7b31
commit 9f19a79a04
5 files changed
+102 -3

No files matched your search

@@ -0,0 +1,39 @@
# SPDX-License-Identifier: MIT
import tempfile
from pathlib import Path
from solidlsp.initialize_params import DefaultInitializeParamsBuilder
class _FakeLS:
# Windows: as_uri() rejects drive-less paths like "/tmp/..."
repository_root_path = str(Path(tempfile.mkdtemp(prefix="fake-project-")) / "root")
class config:
@staticmethod
def get_absolute_workspace_folders(root):
return [root]
@staticmethod
def get_absolute_additional_workspace_folders(root):
return []
custom_settings: dict = {}
def test_default_builder_sets_root_uri():
builder = DefaultInitializeParamsBuilder(_FakeLS())
params = builder.build()
assert "rootUri" in params
assert "rootPath" in params
def test_builder_sends_null_root_uri_when_disabled():
builder = DefaultInitializeParamsBuilder(_FakeLS(), set_root_uri=False)
params = builder.build()
# keys must be present (some servers reject an undefined rootUri); values are null
assert params["rootUri"] is None
assert params["rootPath"] is None
assert params["processId"] is not None
assert params["clientInfo"] == {"name": "Serena"}