Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(lsp): include all diagnosable documents on initialize #17979

Merged
merged 37 commits into from
Mar 30, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
6125671
fix(lsp): add all documents to the lsp on initialize
dsherret Feb 28, 2023
f08a5bf
Fix
dsherret Feb 28, 2023
ef6475c
Take into account enabled_paths
dsherret Mar 1, 2023
17b1f0b
Another one.
dsherret Mar 1, 2023
67439dd
More work.
dsherret Mar 4, 2023
abedfff
Merge branch 'main' into fix_lsp_open_docs_root
dsherret Mar 15, 2023
459ce44
Fix inverted logic.
dsherret Mar 15, 2023
72bfa94
Compile
dsherret Mar 15, 2023
cdc4af0
Ignore minified files
dsherret Mar 15, 2023
0129cf9
Merge branch 'main' into fix_lsp_open_docs_root
dsherret Mar 29, 2023
8688718
Handle files in enabled paths
dsherret Mar 29, 2023
8b0ab70
Consolidate code
dsherret Mar 29, 2023
4c9e102
refactor(lsp): remove boolean parameters on `documents.documents(...)`
dsherret Mar 29, 2023
d9c5e91
Remove word "And"
dsherret Mar 29, 2023
fc4d027
Merge branch 'refactor_lsp_documents_bool_param' into fix_lsp_open_do…
dsherret Mar 29, 2023
08ef6af
Working.
dsherret Mar 29, 2023
2dc17b0
Failing test because our textDocument/references implementation is br…
dsherret Mar 29, 2023
bab99d7
fix(lsp): `textDocument/references` should respect `includeDeclaration`
dsherret Mar 29, 2023
b7dee99
Small refactor.
dsherret Mar 29, 2023
a8cb329
Fix codelens test
dsherret Mar 29, 2023
5894f85
Merge branch 'main' into fix_lsp_find_references_respect_include_decl…
dsherret Mar 29, 2023
c5cfb24
Merge branch 'main' into fix_lsp_find_references_respect_include_decl…
dsherret Mar 30, 2023
b7d7541
Add test and improve code
dsherret Mar 30, 2023
41b3004
Merge branch 'main' into fix_lsp_find_references_respect_include_decl…
dsherret Mar 30, 2023
8dec2d3
Oops... Fix test
dsherret Mar 30, 2023
5a55a7e
Reduce flakiness of package_json_uncached_no_error
dsherret Mar 30, 2023
74fb03f
Merge branch 'main' into fix_lsp_open_docs_root
dsherret Mar 30, 2023
818811e
Merge branch 'fix_lsp_find_references_respect_include_declaration' in…
dsherret Mar 30, 2023
7b96f00
Add enabled_root_urls tests
dsherret Mar 30, 2023
bc3c42e
Merge branch 'main' into fix_lsp_open_docs_root
dsherret Mar 30, 2023
697ace6
Refactor document finder to be more easily unit testable
dsherret Mar 30, 2023
2216402
Another test.
dsherret Mar 30, 2023
8fe2597
Merge branch 'main' into fix_lsp_open_docs_root
dsherret Mar 30, 2023
4d8a9b0
Fix tests
dsherret Mar 30, 2023
b416267
Merge branch 'main' into fix_lsp_open_docs_root
dsherret Mar 30, 2023
055f94d
Fix two failing tests.
dsherret Mar 30, 2023
6cc5a97
Update lsp tests to use a temp cwd
dsherret Mar 30, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Prev Previous commit
Next Next commit
More work.
  • Loading branch information
dsherret committed Mar 4, 2023
commit 67439dd8340d35fe37681de06e580884f65071d2
61 changes: 24 additions & 37 deletions cli/lsp/config.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.

use super::client::Client;
use super::logging::lsp_log;
use crate::util::path::ensure_directory_specifier;
use crate::util::path::specifier_to_file_path;
Expand Down Expand Up @@ -227,7 +226,7 @@ impl Default for ImportCompletionSettings {

/// Deno language server specific settings that can be applied uniquely to a
/// specifier.
#[derive(Debug, Default, Clone, Deserialize)]
#[derive(Debug, Default, Clone, Deserialize, PartialEq, Eq)]
#[serde(rename_all = "camelCase")]
pub struct SpecifierSettings {
/// A flag that indicates if Deno is enabled for this specifier or not.
Expand Down Expand Up @@ -406,26 +405,17 @@ impl ConfigSnapshot {
}
}
}
if let Some((_, SpecifierSettings { enable, .. })) =
self.settings.specifiers.get(specifier)
{
*enable
if let Some(settings) = self.settings.specifiers.get(specifier) {
settings.enable
} else {
self.settings.workspace.enable
}
}
}

#[derive(Debug, Clone)]
pub struct SpecifierWithClientUri {
pub specifier: ModuleSpecifier,
pub client_uri: ModuleSpecifier,
}

#[derive(Debug, Default, Clone)]
pub struct Settings {
pub specifiers:
BTreeMap<ModuleSpecifier, (ModuleSpecifier, SpecifierSettings)>,
pub specifiers: BTreeMap<ModuleSpecifier, SpecifierSettings>,
pub workspace: WorkspaceSettings,
}

Expand Down Expand Up @@ -492,7 +482,7 @@ impl Config {
.settings
.specifiers
.get(specifier)
.map(|(_, s)| s.enable)
.map(|settings| settings.enable)
.unwrap_or_else(|| self.settings.workspace.enable)
}

Expand All @@ -519,7 +509,7 @@ impl Config {
.settings
.specifiers
.get(specifier)
.map(|(_, s)| s.code_lens.test)
.map(|settings| settings.code_lens.test)
.unwrap_or_else(|| self.settings.workspace.code_lens.test);
value
}
Expand Down Expand Up @@ -573,13 +563,15 @@ impl Config {

/// Given the configured workspaces or root URI and the their settings,
/// update and resolve any paths that should be enabled
pub async fn update_enabled_paths(&mut self, client: Client) -> bool {
pub fn update_enabled_paths(&mut self) -> bool {
if let Some(workspace_folders) = self.workspace_folders.clone() {
let mut touched = false;
for (workspace, folder) in workspace_folders {
if let Ok(settings) = client.specifier_configuration(&folder.uri).await
{
if self.update_enabled_paths_entry(workspace, settings.enable_paths) {
for (workspace, _) in workspace_folders {
if let Some(settings) = self.settings.specifiers.get(&workspace) {
if self.update_enabled_paths_entry(
workspace,
settings.enable_paths.clone(),
) {
touched = true;
}
}
Expand Down Expand Up @@ -629,28 +621,23 @@ impl Config {
touched
}

pub fn get_specifiers_with_client_uris(&self) -> Vec<SpecifierWithClientUri> {
self
.settings
.specifiers
.iter()
.map(|(s, (u, _))| SpecifierWithClientUri {
specifier: s.clone(),
client_uri: u.clone(),
})
.collect()
pub fn get_specifiers(&self) -> Vec<ModuleSpecifier> {
self.settings.specifiers.keys().cloned().collect()
}

pub fn set_specifier_settings(
&mut self,
specifier: ModuleSpecifier,
client_uri: ModuleSpecifier,
settings: SpecifierSettings,
) {
self
.settings
.specifiers
.insert(specifier, (client_uri, settings));
) -> bool {
if let Some(existing) = self.settings.specifiers.get(&specifier) {
if *existing == settings {
return false;
}
}

self.settings.specifiers.insert(specifier, settings);
true
}
}

Expand Down
13 changes: 5 additions & 8 deletions cli/lsp/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1179,14 +1179,11 @@ let c: number = "a";
let mut disabled_config = mock_config();
disabled_config.settings.specifiers.insert(
specifier.clone(),
(
specifier.clone(),
SpecifierSettings {
enable: false,
enable_paths: Vec::new(),
code_lens: Default::default(),
},
),
SpecifierSettings {
enable: false,
enable_paths: Vec::new(),
code_lens: Default::default(),
},
);

let diagnostics = generate_lint_diagnostics(
Expand Down