Skip to content

Commit

Permalink
Disable symbol diagnostics in unary formula (#525)
Browse files Browse the repository at this point in the history
  • Loading branch information
lionel- authored Sep 17, 2024
1 parent 8bce66c commit 6f39983
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions crates/ark/src/lsp/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ use crate::lsp::traits::rope::RopeExt;
use crate::treesitter::BinaryOperatorType;
use crate::treesitter::NodeType;
use crate::treesitter::NodeTypeExt;
use crate::treesitter::UnaryOperatorType;
use crate::treesitter::UnmatchedDelimiterType;

#[derive(Clone, Debug, Eq, PartialEq)]
Expand Down Expand Up @@ -172,6 +173,10 @@ fn recurse(
},
NodeType::Subset | NodeType::Subset2 => recurse_subset(node, context, diagnostics),
NodeType::Call => recurse_call(node, context, diagnostics),
NodeType::UnaryOperator(op) => match op {
UnaryOperatorType::Tilde => recurse_formula(node, context, diagnostics),
_ => recurse_default(node, context, diagnostics),
},
NodeType::BinaryOperator(op) => match op {
BinaryOperatorType::Tilde => recurse_formula(node, context, diagnostics),
BinaryOperatorType::LeftAssignment => {
Expand Down Expand Up @@ -1148,4 +1153,19 @@ mod tests {
assert_eq!(diagnostic.range.start.line, 1)
})
}

#[test]
fn test_no_diagnostic_formula() {
r_test(|| {
let text = "
foo ~ bar
~foo
identity(foo ~ bar)
identity(~foo)
";
let document = Document::new(text, None);
let diagnostics = generate_diagnostics(document, DEFAULT_STATE.clone());
assert!(diagnostics.is_empty());
})
}
}

0 comments on commit 6f39983

Please sign in to comment.