Skip to content

Commit d5ea6a9

Browse files
committed
Retrieve string from TS child
1 parent 1209357 commit d5ea6a9

File tree

2 files changed

+5
-4
lines changed

2 files changed

+5
-4
lines changed

crates/ark/src/lsp/diagnostics.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1642,7 +1642,7 @@ foo
16421642

16431643
// Test that non-exported symbols still generate diagnostics
16441644
let code = "
1645-
library(mockpkg)
1645+
library('mockpkg')
16461646
undefined()
16471647
also_undefined
16481648
";

crates/ark/src/treesitter.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,10 @@ impl NodeTypeExt for Node<'_> {
330330
match self.node_type() {
331331
NodeType::Identifier => return Ok(contents.node_slice(self)?.to_string()),
332332
NodeType::String => {
333-
// Remove quotes from string literal
334-
let string = contents.node_slice(self)?.to_string();
335-
Ok(string.trim_matches('"').trim_matches('\'').to_string())
333+
let string_content = self
334+
.child_by_field_name("content")
335+
.ok_or_else(|| anyhow::anyhow!("Can't extract string's `content` field"))?;
336+
Ok(contents.node_slice(&string_content)?.to_string())
336337
},
337338
_ => {
338339
return Err(anyhow::anyhow!("Not an identifier or string"));

0 commit comments

Comments
 (0)