Skip to content

Commit

Permalink
Disable "symbol in scope" within call arguments (#77)
Browse files Browse the repository at this point in the history
  • Loading branch information
DavisVaughan authored Aug 24, 2023
1 parent 2e3c99a commit 1710415
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions crates/ark/src/lsp/diagnostics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,9 @@ pub struct DiagnosticContext<'a> {

// Whether or not we're inside of a formula.
pub in_formula: bool,

// Whether or not we're inside of a call's arguments
pub in_call: bool,
}

impl<'a> DiagnosticContext<'a> {
Expand Down Expand Up @@ -128,6 +131,7 @@ async fn enqueue_diagnostics_impl(backend: Backend, uri: Url) {
workspace_symbols: HashSet::new(),
installed_packages: HashSet::new(),
in_formula: false,
in_call: false,
};

// Add a 'root' context for the document.
Expand Down Expand Up @@ -539,6 +543,13 @@ fn recurse_call_arguments_default(
context: &mut DiagnosticContext,
diagnostics: &mut Vec<Diagnostic>,
) -> Result<()> {
// TODO: Can we better handle NSE in things like `quote()` and
// `dplyr::mutate()` so we don't have to turn off certain diagnostics when
// we are inside a call's arguments?
let mut context = context.clone();
context.in_call = true;
let context = &mut context;

// Recurse into arguments.
if let Some(arguments) = node.child_by_field_name("arguments") {
let mut cursor = arguments.walk();
Expand Down Expand Up @@ -1007,6 +1018,11 @@ fn check_symbol_in_scope(
return false.ok();
}

// Skip if we're working on the arguments of a call
if context.in_call {
return false.ok();
}

// Skip if this isn't an identifier.
if node.kind() != "identifier" {
return false.ok();
Expand Down

0 comments on commit 1710415

Please sign in to comment.