Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Nov 23, 2024
1 parent 50dc49e commit ee530a3
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 25 deletions.
64 changes: 42 additions & 22 deletions crates/oxc_language_server/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,16 @@ use tokio::sync::{Mutex, OnceCell, RwLock, SetError};
use tower_lsp::{
jsonrpc::{Error, ErrorCode, Result},
lsp_types::{
CodeAction, CodeActionKind, CodeActionOptions, CodeActionOrCommand, CodeActionParams, CodeActionProviderCapability, CodeActionResponse, ConfigurationItem, Diagnostic, DiagnosticOptions, DiagnosticServerCapabilities, DidChangeConfigurationParams, DidChangeTextDocumentParams, DidChangeWatchedFilesParams, DidCloseTextDocumentParams, DidOpenTextDocumentParams, DidSaveTextDocumentParams, DocumentDiagnosticParams, DocumentDiagnosticReport, DocumentDiagnosticReportResult, FullDocumentDiagnosticReport, InitializeParams, InitializeResult, InitializedParams, OneOf, RelatedFullDocumentDiagnosticReport, ServerCapabilities, ServerInfo, TextDocumentSyncCapability, TextDocumentSyncKind, TextEdit, Url, WorkDoneProgressOptions, WorkspaceEdit, WorkspaceFoldersServerCapabilities, WorkspaceServerCapabilities
CodeAction, CodeActionKind, CodeActionOptions, CodeActionOrCommand, CodeActionParams,
CodeActionProviderCapability, CodeActionResponse, ConfigurationItem, Diagnostic,
DiagnosticOptions, DiagnosticServerCapabilities, DidChangeConfigurationParams,
DidChangeTextDocumentParams, DidChangeWatchedFilesParams, DidCloseTextDocumentParams,
DidOpenTextDocumentParams, DidSaveTextDocumentParams, DocumentDiagnosticParams,
DocumentDiagnosticReport, DocumentDiagnosticReportResult, FullDocumentDiagnosticReport,
InitializeParams, InitializeResult, InitializedParams, OneOf,
RelatedFullDocumentDiagnosticReport, ServerCapabilities, ServerInfo,
TextDocumentSyncCapability, TextDocumentSyncKind, TextEdit, Url, WorkDoneProgressOptions,
WorkspaceEdit, WorkspaceFoldersServerCapabilities, WorkspaceServerCapabilities,
},
Client, LanguageServer, LspService, Server,
};
Expand Down Expand Up @@ -108,12 +117,14 @@ impl LanguageServer for Backend {
}),
file_operations: None,
}),
diagnostic_provider: Some(DiagnosticServerCapabilities::Options(DiagnosticOptions {
identifier: Some("oxc".into()),
inter_file_dependencies: false,
workspace_diagnostics: false,
work_done_progress_options: WorkDoneProgressOptions::default(),
})),
diagnostic_provider: Some(DiagnosticServerCapabilities::Options(
DiagnosticOptions {
identifier: Some("oxc".into()),
inter_file_dependencies: false,
workspace_diagnostics: false,
work_done_progress_options: WorkDoneProgressOptions::default(),
},
)),
code_action_provider: Some(CodeActionProviderCapability::Options(
CodeActionOptions {
code_action_kinds: Some(vec![CodeActionKind::QUICKFIX]),
Expand Down Expand Up @@ -203,32 +214,41 @@ impl LanguageServer for Backend {
}
}

async fn diagnostic(&self, params: DocumentDiagnosticParams) -> Result<DocumentDiagnosticReportResult> {
let content = self.document_content_cache.get(&params.text_document.uri).map(|entry| entry.value().to_owned());
async fn diagnostic(
&self,
params: DocumentDiagnosticParams,
) -> Result<DocumentDiagnosticReportResult> {
let content = self
.document_content_cache
.get(&params.text_document.uri)
.map(|entry| entry.value().to_owned());

let Some(entry) = self.document_content_cache.get(&params.text_document.uri) else {
return Err(Error::new(ErrorCode::InvalidParams));
};

let Some(result) = self.lint_uri(entry.key(), content).await else {
return Ok(DocumentDiagnosticReportResult::Report(DocumentDiagnosticReport::Full(RelatedFullDocumentDiagnosticReport {
related_documents: None,
full_document_diagnostic_report: FullDocumentDiagnosticReport::default()
})))
return Ok(DocumentDiagnosticReportResult::Report(DocumentDiagnosticReport::Full(
RelatedFullDocumentDiagnosticReport {
related_documents: None,
full_document_diagnostic_report: FullDocumentDiagnosticReport::default(),
},
)));
};

self.diagnostics_report_map.insert(entry.key().to_string(), result.clone());

Ok(DocumentDiagnosticReportResult::Report(DocumentDiagnosticReport::Full(RelatedFullDocumentDiagnosticReport {
related_documents: None,
full_document_diagnostic_report: FullDocumentDiagnosticReport {
items: result.into_iter().map(|report| report.diagnostic).collect(),
..FullDocumentDiagnosticReport::default()
Ok(DocumentDiagnosticReportResult::Report(DocumentDiagnosticReport::Full(
RelatedFullDocumentDiagnosticReport {
related_documents: None,
full_document_diagnostic_report: FullDocumentDiagnosticReport {
items: result.into_iter().map(|report| report.diagnostic).collect(),
..FullDocumentDiagnosticReport::default()
},
},
})))
)))
}


async fn code_action(&self, params: CodeActionParams) -> Result<Option<CodeActionResponse>> {
let uri = params.text_document.uri;

Expand Down Expand Up @@ -376,7 +396,7 @@ impl Backend {
return None;
};

self.server_linter.read().await.run_single(&uri, content)
self.server_linter.read().await.run_single(&uri, content)
}
async fn handle_file_update(&self, uri: Url, content: Option<String>, version: Option<i32>) {
if let Some(diagnostics) = self.lint_uri(&uri, content).await {
Expand Down
6 changes: 3 additions & 3 deletions editors/vscode/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,9 @@ export async function activate(context: ExtensionContext) {
return true;
}

return !configService.config.enable
}
}
return !configService.config.enable;
},
},
};

// Create the language client and start the client.
Expand Down

0 comments on commit ee530a3

Please sign in to comment.