From e213b05cfb0fb2cded91b37ebc4f605b8357ce1b Mon Sep 17 00:00:00 2001 From: Davis Vaughan Date: Thu, 23 Jan 2025 15:16:21 -0500 Subject: [PATCH] Move `impl`s to bottom --- crates/ark/src/lsp/main_loop.rs | 51 +++++++++++++++++---------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/crates/ark/src/lsp/main_loop.rs b/crates/ark/src/lsp/main_loop.rs index 8fa8b5db9..ff0255417 100644 --- a/crates/ark/src/lsp/main_loop.rs +++ b/crates/ark/src/lsp/main_loop.rs @@ -72,35 +72,15 @@ pub(crate) enum KernelNotification { DidOpenVirtualDocument(DidOpenVirtualDocumentParams), } -#[derive(Debug)] -pub(crate) struct DidOpenVirtualDocumentParams { - pub(crate) uri: String, - pub(crate) contents: String, -} - -impl KernelNotification { - pub(crate) fn trace(&self) -> TraceKernelNotification { - TraceKernelNotification { inner: self } - } -} - +/// A thin wrapper struct with a custom `Debug` method more appropriate for trace logs pub(crate) struct TraceKernelNotification<'a> { inner: &'a KernelNotification, } -impl std::fmt::Debug for TraceKernelNotification<'_> { - fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { - match self.inner { - KernelNotification::DidChangeConsoleInputs(_) => f.write_str("DidChangeConsoleInputs"), - KernelNotification::DidOpenVirtualDocument(params) => f - .debug_struct("DidOpenVirtualDocument") - .field("uri", ¶ms.uri) - .field("contents", &"") - .finish(), - // NOTE: Uncomment if we have notifications we don't care to specially handle - //notification => std::fmt::Debug::fmt(notification, f), - } - } +#[derive(Debug)] +pub(crate) struct DidOpenVirtualDocumentParams { + pub(crate) uri: String, + pub(crate) contents: String, } #[derive(Debug)] @@ -610,3 +590,24 @@ pub(crate) fn publish_diagnostics(uri: Url, diagnostics: Vec, versio version, )); } + +impl KernelNotification { + pub(crate) fn trace(&self) -> TraceKernelNotification { + TraceKernelNotification { inner: self } + } +} + +impl std::fmt::Debug for TraceKernelNotification<'_> { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + match self.inner { + KernelNotification::DidChangeConsoleInputs(_) => f.write_str("DidChangeConsoleInputs"), + KernelNotification::DidOpenVirtualDocument(params) => f + .debug_struct("DidOpenVirtualDocument") + .field("uri", ¶ms.uri) + .field("contents", &"") + .finish(), + // NOTE: Uncomment if we have notifications we don't care to specially handle + //notification => std::fmt::Debug::fmt(notification, f), + } + } +}