mirror of
https://github.com/denoland/deno.git
synced 2025-03-06 02:52:05 -05:00
wire up in the lsp
This commit is contained in:
parent
f6efc9f357
commit
f55dd0d0bb
5 changed files with 53 additions and 9 deletions
|
@ -1628,19 +1628,34 @@ impl ConfigData {
|
|||
sloppy_imports_resolver.clone(),
|
||||
Some(resolver.clone()),
|
||||
);
|
||||
|
||||
let lint_options = LintOptions::resolve(
|
||||
member_dir.dir_path(),
|
||||
(*lint_config).clone(),
|
||||
&LintFlags::default(),
|
||||
);
|
||||
let mut plugin_runner = None;
|
||||
let maybe_plugin_specifiers_result = lint_options.resolve_lint_plugins();
|
||||
if let Ok(maybe_plugin_specifiers) = maybe_plugin_specifiers_result {
|
||||
if let Some(plugin_specifiers) = maybe_plugin_specifiers {
|
||||
let plugin_load_result =
|
||||
crate::tools::lint::create_runner_and_load_plugins(plugin_specifiers)
|
||||
.await;
|
||||
// eprintln!("plugin load result {:#?}", plugin_load_result);
|
||||
if let Some(runner) = plugin_load_result.ok() {
|
||||
plugin_runner = Some(Arc::new(Mutex::new(runner)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let linter = Arc::new(CliLinter::new(CliLinterOptions {
|
||||
configured_rules: lint_rule_provider.resolve_lint_rules(
|
||||
LintOptions::resolve(
|
||||
member_dir.dir_path(),
|
||||
(*lint_config).clone(),
|
||||
&LintFlags::default(),
|
||||
)
|
||||
.rules,
|
||||
lint_options.rules,
|
||||
member_dir.maybe_deno_json().map(|c| c.as_ref()),
|
||||
),
|
||||
fix: false,
|
||||
deno_lint_config,
|
||||
maybe_plugin_runner: None,
|
||||
maybe_plugin_runner: plugin_runner,
|
||||
}));
|
||||
|
||||
ConfigData {
|
||||
|
|
|
@ -80,6 +80,7 @@ impl CliLinter {
|
|||
parsed_source: ParsedSource,
|
||||
file_path: PathBuf,
|
||||
) -> Result<Vec<LintDiagnostic>, AnyError> {
|
||||
eprintln!("has plugin runner? {}", self.maybe_plugin_runner.is_some());
|
||||
let Some(plugin_runner) = self.maybe_plugin_runner.clone() else {
|
||||
return Ok(vec![]);
|
||||
};
|
||||
|
@ -107,9 +108,22 @@ impl CliLinter {
|
|||
&self,
|
||||
parsed_source: &ParsedSource,
|
||||
) -> Vec<LintDiagnostic> {
|
||||
self
|
||||
let mut diagnostics = self
|
||||
.linter
|
||||
.lint_with_ast(parsed_source, self.deno_lint_config.clone())
|
||||
.lint_with_ast(parsed_source, self.deno_lint_config.clone());
|
||||
eprintln!("lint with ast");
|
||||
let file_path = parsed_source.specifier().to_file_path().unwrap();
|
||||
// TODO(bartlomieju): surface error is running plugin fails
|
||||
let run_plugin_result = self.run_plugins(parsed_source.clone(), file_path);
|
||||
// if let Err(err) = run_plugin_result.as_ref() {
|
||||
// eprintln!("run plugin result {:#?}", err);
|
||||
// }
|
||||
let maybe_plugin_diagnostics = run_plugin_result.ok();
|
||||
if let Some(plugin_diagnostics) = maybe_plugin_diagnostics {
|
||||
diagnostics.extend_from_slice(&plugin_diagnostics);
|
||||
}
|
||||
|
||||
diagnostics
|
||||
}
|
||||
|
||||
pub fn lint_file(
|
||||
|
|
|
@ -61,6 +61,7 @@ mod rules;
|
|||
pub use ast_buffer::serialize_ast_to_buffer;
|
||||
pub use linter::CliLinter;
|
||||
pub use linter::CliLinterOptions;
|
||||
pub use plugins::create_runner_and_load_plugins;
|
||||
pub use rules::collect_no_slow_type_diagnostics;
|
||||
pub use rules::ConfiguredRules;
|
||||
pub use rules::LintRuleProvider;
|
||||
|
|
3
test_lint_plugins/.vscode/settings.json
vendored
Normal file
3
test_lint_plugins/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"deno.path": "/Users/ib/dev/deno/target/debug/deno"
|
||||
}
|
11
test_lint_plugins/deno.lock
generated
Normal file
11
test_lint_plugins/deno.lock
generated
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"version": "4",
|
||||
"specifiers": {
|
||||
"jsr:@bartlomieju/test-lint-plugin@0.2.0": "0.2.0"
|
||||
},
|
||||
"jsr": {
|
||||
"@bartlomieju/test-lint-plugin@0.2.0": {
|
||||
"integrity": "b6ef2d11164cccf97c049a487295c81843f8aa7ef42c03dff546adadf9fef443"
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue