Skip to content

Commit 8f5e3d8

Browse files
committed
fix some comment formatting and lsp spans
1 parent 8ccfd42 commit 8f5e3d8

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

parser/src/ast.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//! Uiua's abstract syntax tree
22
3-
use std::{collections::HashMap, fmt, mem::discriminant};
3+
use std::{collections::BTreeMap, fmt, mem::discriminant};
44

55
use ecow::EcoString;
66
use serde::*;
@@ -311,7 +311,7 @@ pub struct Comments {
311311
/// The normal comment lines
312312
pub lines: Vec<Sp<EcoString>>,
313313
/// The semantic comments
314-
pub semantic: HashMap<SemanticComment, CodeSpan>,
314+
pub semantic: BTreeMap<SemanticComment, CodeSpan>,
315315
}
316316

317317
/// An inline macro

parser/src/lex.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -829,10 +829,10 @@ impl From<SemanticComment> for Token {
829829
pub enum SemanticComment {
830830
/// Allow experimental features
831831
Experimental,
832-
/// Prevent the containing function from being inlined
833-
NoInline,
834832
/// Prevent stack traces from going deeper
835833
TrackCaller,
834+
/// Prevent the containing function from being inlined
835+
NoInline,
836836
/// Mark that a function should be bound externally
837837
External,
838838
/// Mark a function as deprecated

parser/src/parse.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//! The Uiua parser
22
33
use std::{
4-
collections::HashMap,
4+
collections::BTreeMap,
55
error::Error,
66
f64::consts::{PI, TAU},
77
fmt,
@@ -1746,14 +1746,13 @@ impl Parser<'_> {
17461746
}
17471747
fn comments(&mut self) -> Option<Comments> {
17481748
let mut lines = Vec::new();
1749-
let mut semantic = HashMap::new();
1749+
let mut semantic = BTreeMap::new();
17501750
loop {
17511751
self.ignore_whitespace();
17521752
if let Some(span) = self.exact(Comment) {
17531753
let s = span.as_str(self.inputs, |s| s.trim_start_matches("#").trim().into());
17541754
lines.push(span.sp(s));
17551755
} else if let Some(sem) = self.next_token_map(Token::as_semantic_comment) {
1756-
lines.push(sem.span.clone().sp(sem.value.to_string().into()));
17571756
semantic.insert(sem.value, sem.span);
17581757
} else {
17591758
break;

src/lsp.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,9 @@ impl Spanner {
381381
for line in &comments.lines {
382382
spans.push(line.span.clone().sp(SpanKind::Comment));
383383
}
384+
for span in comments.semantic.values() {
385+
spans.push(span.clone().sp(SpanKind::Comment));
386+
}
384387
}
385388
spans.push(field.name.span.clone().sp(SpanKind::Ident {
386389
docs: self.binding_docs(&field.name.span),

0 commit comments

Comments
 (0)