0
0
Fork 0
mirror of https://github.com/denoland/deno.git synced 2025-03-06 11:18:57 -05:00
This commit is contained in:
Bartek Iwańczuk 2024-12-26 11:26:04 +01:00
parent f8e8f251a4
commit 1a0a61d059
No known key found for this signature in database
GPG key ID: 0C6BCDDC3B3AD750
5 changed files with 10 additions and 18 deletions

View file

@ -113,7 +113,6 @@ export class Context {
op_lint_report( op_lint_report(
this.id, this.id,
this.fileName,
data.message, data.message,
start, start,
end, end,

View file

@ -5,7 +5,6 @@ use super::diagnostics::DiagnosticSource;
use super::documents::Document; use super::documents::Document;
use super::documents::Documents; use super::documents::Documents;
use super::language_server; use super::language_server;
use super::logging::lsp_log;
use super::resolver::LspResolver; use super::resolver::LspResolver;
use super::tsc; use super::tsc;
use super::urls::url_to_uri; use super::urls::url_to_uri;

View file

@ -3090,7 +3090,6 @@ impl tower_lsp::LanguageServer for LanguageServer {
self.init_flag.raise(); self.init_flag.raise();
for registration in registrations { for registration in registrations {
lsp_log!("{}", format!("registration {:#?}", registration));
if let Err(err) = self if let Err(err) = self
.client .client
.when_outside_lsp_lock() .when_outside_lsp_lock()
@ -3099,7 +3098,6 @@ impl tower_lsp::LanguageServer for LanguageServer {
{ {
lsp_warn!("Client errored on capabilities.\n{:#}", err); lsp_warn!("Client errored on capabilities.\n{:#}", err);
} }
lsp_log!("registration finished");
} }
if upgrade_check_enabled() { if upgrade_check_enabled() {

View file

@ -28,6 +28,8 @@ deno_core::extension!(
options = { options = {
logger: PluginLogger, logger: PluginLogger,
}, },
// TODO(bartlomieju): this should only be done,
// if not in the "test worker".
middleware = |op| match op.name { middleware = |op| match op.name {
"op_print" => op_print(), "op_print" => op_print(),
_ => op, _ => op,
@ -42,19 +44,14 @@ deno_core::extension!(
pub struct LintPluginContainer { pub struct LintPluginContainer {
pub diagnostics: Vec<LintDiagnostic>, pub diagnostics: Vec<LintDiagnostic>,
pub source_text_info: Option<SourceTextInfo>, pub source_text_info: Option<SourceTextInfo>,
token: CancellationToken, pub specifier: Option<ModuleSpecifier>,
pub token: CancellationToken,
} }
impl LintPluginContainer { impl LintPluginContainer {
fn report( fn report(&mut self, id: String, message: String, start: usize, end: usize) {
&mut self,
id: String,
specifier: String,
message: String,
start: usize,
end: usize,
) {
let source_text_info = self.source_text_info.as_ref().unwrap(); let source_text_info = self.source_text_info.as_ref().unwrap();
let specifier = self.specifier.clone().unwrap();
let start_pos = source_text_info.start_pos(); let start_pos = source_text_info.start_pos();
let source_range = SourceRange::new(start_pos + start, start_pos + end); let source_range = SourceRange::new(start_pos + start, start_pos + end);
let range = LintDiagnosticRange { let range = LintDiagnosticRange {
@ -63,9 +60,7 @@ impl LintPluginContainer {
text_info: source_text_info.clone(), text_info: source_text_info.clone(),
}; };
let lint_diagnostic = LintDiagnostic { let lint_diagnostic = LintDiagnostic {
// TODO: fix specifier,
specifier: ModuleSpecifier::parse(&format!("file:///{}", specifier))
.unwrap(),
range: Some(range), range: Some(range),
details: LintDiagnosticDetails { details: LintDiagnosticDetails {
message, message,
@ -124,13 +119,12 @@ fn op_lint_create_serialized_ast(
fn op_lint_report( fn op_lint_report(
state: &mut OpState, state: &mut OpState,
#[string] id: String, #[string] id: String,
#[string] specifier: String,
#[string] message: String, #[string] message: String,
#[smi] start: usize, #[smi] start: usize,
#[smi] end: usize, #[smi] end: usize,
) { ) {
let container = state.borrow_mut::<LintPluginContainer>(); let container = state.borrow_mut::<LintPluginContainer>();
container.report(id, specifier, message, start, end); container.report(id, message, start, end);
} }
#[op2] #[op2]

View file

@ -271,6 +271,8 @@ impl PluginRunner {
let mut state = state.borrow_mut(); let mut state = state.borrow_mut();
let container = state.borrow_mut::<LintPluginContainer>(); let container = state.borrow_mut::<LintPluginContainer>();
container.source_text_info = Some(source_text_info); container.source_text_info = Some(source_text_info);
container.specifier =
Some(ModuleSpecifier::from_file_path(specifier).unwrap());
} }
let (file_name_v8, ast_uint8arr_v8) = { let (file_name_v8, ast_uint8arr_v8) = {