Skip to content

Commit a1a6f89

Browse files
wfrasertjdevries
andauthored
[rust bindings] parse macro symbols (#145)
* rust: parse macro symbols Macros end in an exclamation point. Currently parsing one results in a MissingDescriptor error, for example: `scip::symbol::parse_symbol("rust-analyzer cargo std https://github.com/rust-lang/rust/library/std macros/print!")` * fixup: add test for macro --------- Co-authored-by: TJ DeVries <devries.timothyj@gmail.com>
1 parent 8573468 commit a1a6f89

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

bindings/rust/src/symbol.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,7 @@ impl SymbolParser {
342342
'.' => Ok(new_descriptor(name, descriptor::Suffix::Term)),
343343
'#' => Ok(new_descriptor(name, descriptor::Suffix::Type)),
344344
':' => Ok(new_descriptor(name, descriptor::Suffix::Meta)),
345+
'!' => Ok(new_descriptor(name, descriptor::Suffix::Macro)),
345346
_ => Err(SymbolError::MissingDescriptor),
346347
}
347348
}
@@ -524,4 +525,27 @@ mod test {
524525
})
525526
);
526527
}
528+
529+
#[test]
530+
fn parses_rust_method_with_macro() {
531+
let input_symbol = "rust-analyzer cargo test_rust_dependency 0.1.0 println!";
532+
533+
assert_eq!(
534+
parse_symbol(input_symbol).expect("rust symbol"),
535+
Symbol {
536+
scheme: "rust-analyzer".to_string(),
537+
package: Package::new_with_values("cargo", "test_rust_dependency", "0.1.0"),
538+
descriptors: vec![new_descriptor(
539+
"println".to_string(),
540+
descriptor::Suffix::Macro
541+
),],
542+
special_fields: SpecialFields::default(),
543+
}
544+
);
545+
546+
assert_eq!(
547+
input_symbol,
548+
format_symbol(parse_symbol(input_symbol).expect("rust symbol"))
549+
)
550+
}
527551
}

0 commit comments

Comments
 (0)