From 44f78cf0c0bdf151ec5f1e68b6e3b5583866bc67 Mon Sep 17 00:00:00 2001 From: Kai Schmidt Date: Thu, 27 Jun 2024 23:40:11 -0700 Subject: [PATCH] actually use local module spans in lsp --- src/lsp.rs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/lsp.rs b/src/lsp.rs index 065c3dc3..9781ceda 100644 --- a/src/lsp.rs +++ b/src/lsp.rs @@ -9,7 +9,7 @@ use std::{ use crate::{ algorithm::invert::{invert_instrs, under_instrs}, - ast::{Item, Modifier, PlaceholderOp, Ref, RefComponent, Word}, + ast::{Item, Modifier, ModuleKind, PlaceholderOp, Ref, RefComponent, Word}, ident_modifier_args, instrs_are_pure, lex::{CodeSpan, Sp}, parse::parse, @@ -173,7 +173,16 @@ impl Spanner { let mut spans = Vec::new(); for item in items { match item { - Item::Module(m) => spans.extend(self.items_spans(&m.value.items)), + Item::Module(m) => { + match &m.value.kind { + ModuleKind::Named(name) => { + let binding_docs = self.binding_docs(&name.span); + spans.push(name.span.clone().sp(SpanKind::Ident(binding_docs))); + } + ModuleKind::Test => {} + } + spans.extend(self.items_spans(&m.value.items)); + } Item::Words(lines) => { for line in lines { spans.extend(self.words_spans(line)) @@ -265,9 +274,10 @@ impl Spanner { if comment.is_none() { match &binfo.kind { BindingKind::Const(None) => comment = Some("constant".into()), - BindingKind::Import(_) => comment = Some("module".into()), + BindingKind::Import(_) | BindingKind::Module(_) => comment = Some("module".into()), BindingKind::Macro => comment = Some("macro".into()), - _ => {} + BindingKind::Func(_) => {} + BindingKind::Const(_) => {} } } let kind = match &binfo.kind {