Skip to content

Conversation

@ematipico
Copy link
Member

Summary

This PR optimises the LSP scanner by computing the ScanKind variant when we create a project. The business logic we used in the CLI has been moved inside the Workspace. When we create a project, the Workspace also tells us how to scan it. This is very useful and functional. This is very convenient because it will allow us to tweak the LSP scanner by taking LSP settings into account.

To implement this functionality, the method open_project now accepts the skip and only parameters because they need to be factored into account when deciding how to scan a project. Of course, the LSP doesn't have any of those yet.

Additionally, the CLI adds some further checks, which are the same as before. That's why the method comput_scan_kind now returns an Option, so we can unwrap_or and use one computed from the workspace.

The rest of the changes are mostly code moved around, and unit tests updated.

Test Plan

CI should stay green, snapshots shouldn't change.

@github-actions github-actions bot added A-CLI Area: CLI A-Core Area: core labels May 20, 2025
Comment on lines +15 to +18
let execution = Execution::new_format(VcsTargeted {
staged: false,
changed: false,
});
Copy link
Member Author

Choose a reason for hiding this comment

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

I really like this change, because it felt weird that project_key needed to be part of Execution.

@github-actions github-actions bot added A-Project Area: project A-Parser Area: parser A-Formatter Area: formatter A-LSP Area: language server protocol L-CSS Language: CSS A-Diagnostic Area: diagnostocis L-HTML Language: HTML and super languages labels May 20, 2025
pub fn parse_html_with_cache(source: &str, cache: &mut NodeCache) -> HtmlParse {
tracing::debug_span!("Parsing phase").in_scope(move || {
let mut parser = HtmlParser::new(source);
let mut parser = HtmlParser::new(source);
Copy link
Member Author

Choose a reason for hiding this comment

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

All these logs have been removed because they cause a lot of noise

"biome_did_change_workspace_settings",
"workspace/didChangeWatchedFiles",
if let Some(base_path) = self.session.base_path() {
if let Some(folders) = self.session.get_workspace_folders() {
Copy link
Member Author

Choose a reason for hiding this comment

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

I noticed that we weren't considering workspace folders when the configuration changed. This should fix some bugs.

@ematipico ematipico requested review from a team May 20, 2025 14:10
Copy link
Contributor

@arendjr arendjr left a comment

Choose a reason for hiding this comment

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

Nice!

watch: true,
force: false,
scan_kind: ScanKind::Project,
scan_kind,
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, if I understand correctly this is the main reason for this PR, right? The LSP no longer always needs to use ScanKind::Project, but it can use an actual scan_kind determined by the workspace.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes! If you open a project that doesn't use project rules, the memory used by the biome process (daemon) will still be low because we don't crawl and save all files.

@ematipico ematipico force-pushed the chore/smarter-lsp-scanner branch from 9d7468a to 2dcd162 Compare May 20, 2025 15:28
@codspeed-hq
Copy link

codspeed-hq bot commented May 20, 2025

CodSpeed Performance Report

Merging #6099 will not alter performance

Comparing chore/smarter-lsp-scanner (2cfa644) with main (97ac0d0)

Summary

✅ 95 untouched benchmarks

@ematipico ematipico force-pushed the chore/smarter-lsp-scanner branch from 51f69bd to fc449d5 Compare May 21, 2025 13:32
@ematipico ematipico merged commit c440d2d into main May 21, 2025
12 of 13 checks passed
@ematipico ematipico deleted the chore/smarter-lsp-scanner branch May 21, 2025 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-CLI Area: CLI A-Core Area: core A-Diagnostic Area: diagnostocis A-Formatter Area: formatter A-LSP Area: language server protocol A-Parser Area: parser A-Project Area: project L-CSS Language: CSS L-HTML Language: HTML and super languages

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants