From 617284ef72ed7fa5923f9d550dcbe2a19e1bcf68 Mon Sep 17 00:00:00 2001 From: Matthew Espino <65783406+mcecode@users.noreply.github.com> Date: Sat, 26 Oct 2024 03:30:46 +0800 Subject: [PATCH] build-debug --- .github/workflows/build-debug-harper-ls.yml | 28 ++++++++++++++ harper-ls/src/backend.rs | 41 +++++++++++++++++++++ 2 files changed, 69 insertions(+) create mode 100644 .github/workflows/build-debug-harper-ls.yml diff --git a/.github/workflows/build-debug-harper-ls.yml b/.github/workflows/build-debug-harper-ls.yml new file mode 100644 index 00000000..e0362782 --- /dev/null +++ b/.github/workflows/build-debug-harper-ls.yml @@ -0,0 +1,28 @@ +name: Build Debug + +on: + push: + branches: ["build-debug-harper-ls"] + +jobs: + build: + name: Build + runs-on: ubuntu-20.04 + steps: + - uses: actions/checkout@v4 + - uses: dtolnay/rust-toolchain@master + with: + toolchain: stable + targets: x86_64-unknown-linux-gnu + - name: Build + run: cargo +stable build --locked --profile dev --bin harper-ls --target x86_64-unknown-linux-gnu + - name: Archive + run: | + cd target/x86_64-unknown-linux-gnu/debug + tar -czf ../../../harper-ls.tar.gz harper-ls + cd - + - name: Upload + uses: actions/upload-artifact@v4 + with: + name: debug-build + path: harper-ls.tar.gz diff --git a/harper-ls/src/backend.rs b/harper-ls/src/backend.rs index 1cb4c670..156068d0 100644 --- a/harper-ls/src/backend.rs +++ b/harper-ls/src/backend.rs @@ -23,6 +23,8 @@ use tower_lsp::lsp_types::{ InitializeResult, InitializedParams, MessageType, PublishDiagnosticsParams, Range, ServerCapabilities, TextDocumentSyncCapability, TextDocumentSyncKind, TextDocumentSyncOptions, TextDocumentSyncSaveOptions, Url, + DocumentDiagnosticParams, DocumentDiagnosticReportResult, DocumentDiagnosticReport, + RelatedFullDocumentDiagnosticReport, FullDocumentDiagnosticReport, }; use tower_lsp::{Client, LanguageServer}; use tracing::{error, info}; @@ -175,6 +177,8 @@ impl Backend { doc_state.linter = LintGroup::new(config_lock.lint_config, dict.clone()); } + doc_state.linter = LintGroup::new(config_lock.lint_config, dict.clone()); + let Some(language_id) = &doc_state.language_id else { doc_lock.remove(url); return Ok(()); @@ -477,6 +481,43 @@ impl LanguageServer for Backend { async fn did_change_configuration(&self, params: DidChangeConfigurationParams) { self.update_config_from_obj(params.settings).await; + + let urls: Vec = { + let doc_lock = self.doc_state.lock().await; + doc_lock.keys().cloned().collect() + }; + + self.client.log_message(MessageType::INFO, urls).await; + + for url in urls { + self.client.log_message(MessageType::INFO, url).await; + let _ = self.update_document_from_file(&url, None).await; + self.publish_diagnostics(&url).await; + self.client.log_message(MessageType::INFO, "end").await; + } + } + + async fn diagnostic( + &self, + params: DocumentDiagnosticParams, + ) -> Result { + let _ = self + .update_document_from_file(¶ms.text_document.uri, None) + .await; + let diagnostics = self.generate_diagnostics(¶ms.text_document.uri).await; + + Ok(DocumentDiagnosticReportResult::Report( + DocumentDiagnosticReport::Full( + RelatedFullDocumentDiagnosticReport { + full_document_diagnostic_report: FullDocumentDiagnosticReport { + items: diagnostics, + ..Default::default() + }, + ..Default::default() + } + ) + ) + ) } async fn code_action(&self, params: CodeActionParams) -> Result> {