Skip to content

Commit

Permalink
fix: string in macros
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarrus1 committed Mar 8, 2024
1 parent 8124090 commit a12ee08
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion crates/preprocessor/src/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -280,7 +280,7 @@ where
queued_symbol.symbol.range.start.character + text.len() as u32,
),
),
queued_symbol.symbol.delta,
symbol.delta,
));
context_stack.push(current_context);
}
Expand Down
4 changes: 2 additions & 2 deletions crates/preprocessor/tests/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ fn macro_expansion_6() {
this.GetValue("m_" ... #%2, i); \
return i;}
public void GetFoo(){ void i; this.GetValue("m_" ... "Foo", i); return i;}"#;
public void GetFoo(){ void i; this.GetValue( "m_" ... "Foo", i); return i;}"#;

assert_preproc_eq!(input, output);
}
Expand Down Expand Up @@ -877,7 +877,7 @@ void foo(){
if(this.GetValue("m_" ... #%1, m_h%1)){ \
delete m_h%1;}
void foo(){
Handle m_hFoo; if(this.GetValue("m_" ... "Foo", m_hFoo)){ delete m_hFoo;}
Handle m_hFoo; if(this.GetValue( "m_" ... "Foo", m_hFoo)){ delete m_hFoo;}
}"#;
assert_preproc_eq!(input, output);
}
13 changes: 13 additions & 0 deletions crates/sourcepawn_lsp/tests/text_document/hover/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,16 @@ Bar bar = BAR;
"#,
));
}

#[test]
fn macro_10() {
assert_json_snapshot!(hover(
r#"
%! main.sp
#define FOO "foo"
char foo[10] = FOO;
|
^
"#,
));
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
source: crates/sourcepawn_lsp/tests/text_document/hover/macros.rs
assertion_line: 136
expression: "hover(r#\"\n%! main.sp\n#define FOO \"foo\"\nchar foo[10] = FOO;\n |\n ^\n\"#)"
---
{
"contents": {
"kind": "markdown",
"value": "```sourcepawn\n#define FOO \"foo\"\n```\nExpands to:\n```sourcepawn\n\"foo\"\n```"
},
"range": {
"start": {
"line": 1,
"character": 15
},
"end": {
"line": 1,
"character": 18
}
}
}

0 comments on commit a12ee08

Please sign in to comment.