-
Notifications
You must be signed in to change notification settings - Fork 492
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added discovery of struct members inside constructors
- Loading branch information
1 parent
5e02697
commit 64a30c3
Showing
4 changed files
with
174 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
crates/cairo-lang-language-server/tests/test_data/hover/structs.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
//! > Hover | ||
|
||
//! > test_runner_name | ||
test_hover | ||
|
||
//! > cairo_project.toml | ||
[crate_roots] | ||
hello = "src" | ||
|
||
[config.global] | ||
edition = "2023_11" | ||
|
||
//! > cairo_code | ||
/// Docstring of Struct. | ||
struct Struct { | ||
/// Docstring of member1. | ||
member<caret>1: felt252, | ||
member2: u256 | ||
} | ||
|
||
mod happy_cases { | ||
use super::Struct; | ||
|
||
fn constructor() { | ||
let _s = Struct { member1<caret>: 0, member2: 0 }; | ||
let _s = Struct { member1: 0, mem<caret>ber2: 0 }; | ||
} | ||
|
||
fn member_access() { | ||
let s = Struct { member1: 0, member2: 0 }; | ||
let _ = s.member1<caret>; | ||
} | ||
} | ||
|
||
mod unhappy_cases { | ||
fn non_existent_struct { | ||
let _ = NonExistentStruct { mem<caret>ber: 0 }; | ||
} | ||
} | ||
|
||
//! > hover #0 | ||
// = source context | ||
member<caret>1: felt252, | ||
// = highlight | ||
<sel>member1</sel>: felt252, | ||
// = popover | ||
```cairo | ||
hello | ||
``` | ||
```cairo | ||
struct Struct { | ||
member1: felt252, | ||
member2: u256, | ||
} | ||
``` | ||
--- | ||
Docstring of Struct. | ||
|
||
//! > hover #1 | ||
// = source context | ||
let _s = Struct { member1<caret>: 0, member2: 0 }; | ||
// = highlight | ||
let _s = Struct { <sel>member1</sel>: 0, member2: 0 }; | ||
// = popover | ||
```cairo | ||
hello | ||
``` | ||
```cairo | ||
struct Struct { | ||
member1: felt252, | ||
member2: u256, | ||
} | ||
``` | ||
--- | ||
Docstring of member1. | ||
|
||
//! > hover #2 | ||
// = source context | ||
let _s = Struct { member1: 0, mem<caret>ber2: 0 }; | ||
// = highlight | ||
let _s = Struct { member1: 0, <sel>member2</sel>: 0 }; | ||
// = popover | ||
```cairo | ||
hello | ||
``` | ||
```cairo | ||
struct Struct { | ||
member1: felt252, | ||
member2: u256, | ||
} | ||
``` | ||
|
||
//! > hover #3 | ||
// = source context | ||
let _ = s.member1<caret>; | ||
// = highlight | ||
let _ = s.<sel>member1</sel>; | ||
// = popover | ||
```cairo | ||
hello | ||
``` | ||
```cairo | ||
struct Struct { | ||
member1: felt252, | ||
member2: u256, | ||
} | ||
``` | ||
--- | ||
Docstring of member1. | ||
|
||
//! > hover #4 | ||
// = source context | ||
let _ = NonExistentStruct { mem<caret>ber: 0 }; | ||
// = highlight | ||
No highlight information. | ||
// = popover | ||
```cairo | ||
<missing> | ||
``` |