Skip to content

Commit

Permalink
change to tracing::debug_span
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshuaBatty committed Jul 8, 2024
1 parent fb41dba commit 8544b08
Show file tree
Hide file tree
Showing 10 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion sway-lsp/src/capabilities/code_lens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use lsp_types::{CodeLens, Url};
use crate::core::session::Session;

pub fn code_lens(session: &Arc<Session>, url: &Url) -> Vec<CodeLens> {
let _p = tracing::trace_span!("code_lens").entered();
let _p = tracing::debug_span!("code_lens").entered();
let url_path = PathBuf::from(url.path());

// Construct code lenses for runnable functions
Expand Down
2 changes: 1 addition & 1 deletion sway-lsp/src/capabilities/formatting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use std::sync::Arc;
use swayfmt::Formatter;

pub fn format_text(documents: &Documents, url: &Url) -> Result<Vec<TextEdit>, LanguageServerError> {
let _p = tracing::trace_span!("format_text").entered();
let _p = tracing::debug_span!("format_text").entered();
let document = documents.try_get(url.path()).try_unwrap().ok_or_else(|| {
DocumentError::DocumentNotFound {
path: url.path().to_string(),
Expand Down
2 changes: 1 addition & 1 deletion sway-lsp/src/capabilities/highlight.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pub fn get_highlights(
url: &Url,
position: Position,
) -> Option<Vec<DocumentHighlight>> {
let _p = tracing::trace_span!("get_highlights").entered();
let _p = tracing::debug_span!("get_highlights").entered();
session.token_ranges(url, position).map(|ranges| {
ranges
.into_iter()
Expand Down
2 changes: 1 addition & 1 deletion sway-lsp/src/capabilities/inlay_hints.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub fn inlay_hints(
range: &Range,
config: &InlayHintsConfig,
) -> Option<Vec<lsp_types::InlayHint>> {
let _p = tracing::trace_span!("inlay_hints").entered();
let _p = tracing::debug_span!("inlay_hints").entered();
// 1. Loop through all our tokens and filter out all tokens that aren't TypedVariableDeclaration tokens
// 2. Also filter out all tokens that have a span that fall outside of the provided range
// 3. Filter out all variable tokens that have a type_ascription
Expand Down
2 changes: 1 addition & 1 deletion sway-lsp/src/capabilities/rename.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub fn rename(
url: &Url,
position: Position,
) -> Result<WorkspaceEdit, LanguageServerError> {
let _p = tracing::trace_span!("rename").entered();
let _p = tracing::debug_span!("rename").entered();
// Make sure the new name is not a keyword or a literal int type
if sway_parse::RESERVED_KEYWORDS.contains(&new_name)
|| sway_parse::parse_int_suffix(&new_name).is_some()
Expand Down
2 changes: 1 addition & 1 deletion sway-lsp/src/capabilities/semantic_tokens.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pub fn semantic_tokens_range(
url: &Url,
range: &Range,
) -> Option<SemanticTokensRangeResult> {
let _p = tracing::trace_span!("semantic_tokens_range").entered();
let _p = tracing::debug_span!("semantic_tokens_range").entered();
let tokens: Vec<_> = session
.token_map()
.tokens_for_file(url)
Expand Down
20 changes: 10 additions & 10 deletions sway-lsp/src/core/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ impl Session {

/// Clean up memory in the [TypeEngine] and [DeclEngine] for the user's workspace.
pub fn garbage_collect(&self, engines: &mut Engines) -> Result<(), LanguageServerError> {
let _p = tracing::trace_span!("garbage_collect").entered();
let _p = tracing::debug_span!("garbage_collect").entered();
let path = self.sync.temp_dir()?;
let program_id = { engines.se().get_program_id(&path) };
if let Some(program_id) = program_id {
Expand All @@ -132,7 +132,7 @@ impl Session {
}

pub fn token_ranges(&self, url: &Url, position: Position) -> Option<Vec<Range>> {
let _p = tracing::trace_span!("token_ranges").entered();
let _p = tracing::debug_span!("token_ranges").entered();
let mut token_ranges: Vec<_> = self
.token_map
.tokens_for_file(url)
Expand All @@ -152,7 +152,7 @@ impl Session {
uri: &Url,
position: Position,
) -> Option<GotoDefinitionResponse> {
let _p = tracing::trace_span!("token_definition_response").entered();
let _p = tracing::debug_span!("token_definition_response").entered();
self.token_map
.token_at_position(uri, position)
.and_then(|item| item.value().declared_token_ident(&self.engines.read()))
Expand All @@ -174,7 +174,7 @@ impl Session {
position: Position,
trigger_char: &str,
) -> Option<Vec<CompletionItem>> {
let _p = tracing::trace_span!("completion_items").entered();
let _p = tracing::debug_span!("completion_items").entered();
let shifted_position = Position {
line: position.line,
character: position.character - trigger_char.len() as u32 - 1,
Expand Down Expand Up @@ -209,7 +209,7 @@ impl Session {
}

pub fn symbol_information(&self, url: &Url) -> Option<Vec<SymbolInformation>> {
let _p = tracing::trace_span!("symbol_information").entered();
let _p = tracing::debug_span!("symbol_information").entered();
let tokens = self.token_map.tokens_for_file(url);
self.sync
.to_workspace_url(url.clone())
Expand All @@ -229,7 +229,7 @@ impl Session {

/// Create a [BuildPlan] from the given [Url] appropriate for the language server.
pub(crate) fn build_plan(uri: &Url) -> Result<BuildPlan, LanguageServerError> {
let _p = tracing::trace_span!("build_plan").entered();
let _p = tracing::debug_span!("build_plan").entered();
let manifest_dir = PathBuf::from(uri.path());
let manifest =
ManifestFile::from_dir(manifest_dir).map_err(|_| DocumentError::ManifestFileNotFound {
Expand Down Expand Up @@ -260,7 +260,7 @@ pub fn compile(
lsp_mode: Option<LspConfig>,
experimental: sway_core::ExperimentalFlags,
) -> Result<Vec<(Option<Programs>, Handler)>, LanguageServerError> {
let _p = tracing::trace_span!("compile").entered();
let _p = tracing::debug_span!("compile").entered();
let build_plan = build_plan(uri)?;
let tests_enabled = true;
pkg::check(
Expand All @@ -283,7 +283,7 @@ pub fn traverse(
engines_clone: &Engines,
session: Arc<Session>,
) -> Result<Option<CompileResults>, LanguageServerError> {
let _p = tracing::trace_span!("traverse").entered();
let _p = tracing::debug_span!("traverse").entered();
session.token_map.clear();
session.metrics.clear();
let mut diagnostics: CompileResults = (Vec::default(), Vec::default());
Expand Down Expand Up @@ -381,7 +381,7 @@ pub fn parse_project(
session: Arc<Session>,
experimental: sway_core::ExperimentalFlags,
) -> Result<(), LanguageServerError> {
let _p = tracing::trace_span!("parse_project").entered();
let _p = tracing::debug_span!("parse_project").entered();
let results = compile(
uri,
engines,
Expand Down Expand Up @@ -457,7 +457,7 @@ fn create_runnables(
decl_engine: &DeclEngine,
source_engine: &SourceEngine,
) {
let _p = tracing::trace_span!("create_runnables").entered();
let _p = tracing::debug_span!("create_runnables").entered();
// Insert runnable test functions.
for (decl, _) in typed_program.test_fns(decl_engine) {
// Get the span of the first attribute if it exists, otherwise use the span of the function name.
Expand Down
3 changes: 2 additions & 1 deletion sway-lsp/src/handlers/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
use crate::{
capabilities, core::session::build_plan, lsp_ext, server_state::ServerState, utils::debug,
};
use forc_tracing::{init_tracing_subscriber, TracingSubscriberOptions, TracingWriterMode};
use forc_tracing::{init_tracing_subscriber, TracingSubscriberOptions, TracingWriterMode, FmtSpan};
use lsp_types::{
CodeLens, CompletionResponse, DocumentFormattingParams, DocumentSymbolResponse,
InitializeResult, InlayHint, InlayHintParams, PrepareRenameResponse, RenameParams,
Expand Down Expand Up @@ -43,6 +43,7 @@ pub fn handle_initialize(
let tracing_options = TracingSubscriberOptions {
log_level: Some(config.logging.level),
writer_mode: Some(TracingWriterMode::Stderr),
format_span: Some(FmtSpan::CLOSE),
..Default::default()
};
init_tracing_subscriber(tracing_options);
Expand Down
1 change: 1 addition & 0 deletions sway-lsp/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ impl LanguageServer for ServerState {
}

async fn initialized(&self, _: InitializedParams) {
let _p = tracing::debug_span!("parse_text").entered();
tracing::info!("Sway Language Server Initialized");
}

Expand Down
2 changes: 1 addition & 1 deletion sway-lsp/src/server_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ impl ServerState {
}

pub fn shutdown_server(&self) -> jsonrpc::Result<()> {
let _p = tracing::trace_span!("shutdown_server").entered();
let _p = tracing::debug_span!("shutdown_server").entered();
tracing::info!("Shutting Down the Sway Language Server");

// Drain pending compilation requests
Expand Down

0 comments on commit 8544b08

Please # to comment.