-
Notifications
You must be signed in to change notification settings - Fork 11.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move][ide] Change parsing / expansion to report IDE suggestions for …
…missing types (#18744) ## Description This modifies the parser to build `UnresolvedError` for types that don't parse, and then uses those during expansion to provide IDE alias information at those locations. ## Test plan New IDE tests, plus everything else still works as expected. --- ## Release notes Check each box that your changes affect. If none of the boxes relate to your changes, release notes aren't required. For each box you select, include information after the relevant heading that describes the impact of your changes that a user might notice and any actions they must take to implement updates. - [ ] Protocol: - [ ] Nodes (Validators and Full nodes): - [ ] Indexer: - [ ] JSON-RPC: - [ ] GraphQL: - [ ] CLI: - [ ] Rust SDK: - [ ] REST API:
- Loading branch information
Showing
11 changed files
with
483 additions
and
18 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
68 changes: 68 additions & 0 deletions
68
...al-crates/move/crates/move-compiler/tests/move_2024/ide_mode/missing_type_suggestions.exp
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,68 @@ | ||
warning[W09001]: unused alias | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:7:16 | ||
│ | ||
7 │ use a::m::{Self, S, A}; | ||
│ ^^^^ Unused 'use' of alias 'm'. Consider removing it | ||
│ | ||
= This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') | ||
|
||
warning[W09001]: unused alias | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:7:22 | ||
│ | ||
7 │ use a::m::{Self, S, A}; | ||
│ ^ Unused 'use' of alias 'S'. Consider removing it | ||
│ | ||
= This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') | ||
|
||
warning[W09001]: unused alias | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:7:25 | ||
│ | ||
7 │ use a::m::{Self, S, A}; | ||
│ ^ Unused 'use' of alias 'A'. Consider removing it | ||
│ | ||
= This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') | ||
|
||
warning[W09002]: unused variable | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:9:18 | ||
│ | ||
9 │ public fun p(a: | ||
│ ^ Unused parameter 'a'. Consider removing or prefixing with an underscore: '_a' | ||
│ | ||
= This warning can be suppressed with '#[allow(unused_variable)]' applied to the 'module' or module member ('const', 'fun', or 'struct') | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:11:5 | ||
│ | ||
9 │ public fun p(a: | ||
│ - To match this '(' | ||
10 │ | ||
11 │ public fun q(): | ||
│ ^ Expected ')' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:11:5 | ||
│ | ||
11 │ public fun q(): | ||
│ ^^^^^^ | ||
│ │ | ||
│ Unexpected 'public' | ||
│ Expected a type name | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:12:1 | ||
│ | ||
12 │ } | ||
│ ^ | ||
│ │ | ||
│ Unexpected '}' | ||
│ Expected a type name | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:14:1 | ||
│ | ||
14 │ | ||
│ ^ | ||
│ | ||
│ Unexpected end-of-file | ||
│ Expected '{' | ||
|
Empty file.
142 changes: 142 additions & 0 deletions
142
...rates/move/crates/move-compiler/tests/move_2024/ide_mode/missing_type_suggestions.ide.exp
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,142 @@ | ||
note[I15006]: IDE path autocomplete | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:1:1 | ||
│ | ||
1 │ ╭ module a::m { | ||
2 │ │ public struct S<T> { x: T } | ||
3 │ │ public struct A {} | ||
4 │ │ } | ||
│ ╰─^ Possible in-scope names | ||
│ | ||
= members: 'A -> a::m::A', 'Option -> std::option::Option', or 'S -> a::m::S' | ||
= modules: 'Self -> a::m', 'option -> std::option', or 'vector -> std::vector' | ||
= addresses: 'B -> 0x42', 'K -> 0x19', 'M -> 0x40', 'a -> 0x44', 'b -> 0x45', 'k -> 0x19', 'std -> 0x1', or 'sui -> 0x2' | ||
= type params: | ||
|
||
warning[W09009]: unused struct field | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:2:26 | ||
│ | ||
2 │ public struct S<T> { x: T } | ||
│ ^ The 'x' field of the 'S' type is unused | ||
│ | ||
= This warning can be suppressed with '#[allow(unused_field)]' applied to the 'module' or module member ('const', 'fun', or 'struct') | ||
|
||
note[I15006]: IDE path autocomplete | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:2:29 | ||
│ | ||
2 │ public struct S<T> { x: T } | ||
│ ^ Possible in-scope names | ||
│ | ||
= members: 'A -> a::m::A', 'Option -> std::option::Option', or 'S -> a::m::S' | ||
= modules: 'Self -> a::m', 'option -> std::option', or 'vector -> std::vector' | ||
= addresses: 'B -> 0x42', 'K -> 0x19', 'M -> 0x40', 'a -> 0x44', 'b -> 0x45', 'k -> 0x19', 'std -> 0x1', or 'sui -> 0x2' | ||
= type params: 'T' | ||
|
||
note[I15006]: IDE path autocomplete | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:6:1 | ||
│ | ||
6 │ ╭ module a::test { | ||
7 │ │ use a::m::{Self, S, A}; | ||
8 │ │ | ||
9 │ │ public fun p(a: | ||
10 │ │ | ||
11 │ │ public fun q(): | ||
12 │ │ } | ||
│ ╰─^ Possible in-scope names | ||
│ | ||
= members: 'A -> a::m::A', 'Option -> std::option::Option', 'S -> a::m::S', 'p -> a::test::p', or 'q -> a::test::q' | ||
= modules: 'Self -> a::test', 'm -> a::m', 'option -> std::option', or 'vector -> std::vector' | ||
= addresses: 'B -> 0x42', 'K -> 0x19', 'M -> 0x40', 'a -> 0x44', 'b -> 0x45', 'k -> 0x19', 'std -> 0x1', or 'sui -> 0x2' | ||
= type params: | ||
|
||
warning[W09001]: unused alias | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:7:16 | ||
│ | ||
7 │ use a::m::{Self, S, A}; | ||
│ ^^^^ Unused 'use' of alias 'm'. Consider removing it | ||
│ | ||
= This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') | ||
|
||
warning[W09001]: unused alias | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:7:22 | ||
│ | ||
7 │ use a::m::{Self, S, A}; | ||
│ ^ Unused 'use' of alias 'S'. Consider removing it | ||
│ | ||
= This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') | ||
|
||
warning[W09001]: unused alias | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:7:25 | ||
│ | ||
7 │ use a::m::{Self, S, A}; | ||
│ ^ Unused 'use' of alias 'A'. Consider removing it | ||
│ | ||
= This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') | ||
|
||
warning[W09002]: unused variable | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:9:18 | ||
│ | ||
9 │ public fun p(a: | ||
│ ^ Unused parameter 'a'. Consider removing or prefixing with an underscore: '_a' | ||
│ | ||
= This warning can be suppressed with '#[allow(unused_variable)]' applied to the 'module' or module member ('const', 'fun', or 'struct') | ||
|
||
note[I15006]: IDE path autocomplete | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:11:5 | ||
│ | ||
9 │ │ public fun p(a: | ||
│ ╰───────────────────^ Possible in-scope names | ||
10 │ | ||
11 │ ╭ public fun q(): | ||
│ | ||
= members: 'A -> a::m::A', 'Option -> std::option::Option', 'S -> a::m::S', 'p -> a::test::p', or 'q -> a::test::q' | ||
= modules: 'Self -> a::test', 'm -> a::m', 'option -> std::option', or 'vector -> std::vector' | ||
= addresses: 'B -> 0x42', 'K -> 0x19', 'M -> 0x40', 'a -> 0x44', 'b -> 0x45', 'k -> 0x19', 'std -> 0x1', or 'sui -> 0x2' | ||
= type params: | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:11:5 | ||
│ | ||
9 │ public fun p(a: | ||
│ - To match this '(' | ||
10 │ | ||
11 │ public fun q(): | ||
│ ^ Expected ')' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:11:5 | ||
│ | ||
11 │ public fun q(): | ||
│ ^^^^^^ | ||
│ │ | ||
│ Unexpected 'public' | ||
│ Expected a type name | ||
|
||
note[I15006]: IDE path autocomplete | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:11:16 | ||
│ | ||
11 │ public fun q(): | ||
│ ^ Possible in-scope names | ||
│ | ||
= members: 'A -> a::m::A', 'Option -> std::option::Option', 'S -> a::m::S', 'p -> a::test::p', or 'q -> a::test::q' | ||
= modules: 'Self -> a::test', 'm -> a::m', 'option -> std::option', or 'vector -> std::vector' | ||
= addresses: 'B -> 0x42', 'K -> 0x19', 'M -> 0x40', 'a -> 0x44', 'b -> 0x45', 'k -> 0x19', 'std -> 0x1', or 'sui -> 0x2' | ||
= type params: | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:12:1 | ||
│ | ||
12 │ } | ||
│ ^ | ||
│ │ | ||
│ Unexpected '}' | ||
│ Expected a type name | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/missing_type_suggestions.move:14:1 | ||
│ | ||
14 │ | ||
│ ^ | ||
│ | ||
│ Unexpected end-of-file | ||
│ Expected '{' | ||
|
13 changes: 13 additions & 0 deletions
13
...l-crates/move/crates/move-compiler/tests/move_2024/ide_mode/missing_type_suggestions.move
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,13 @@ | ||
module a::m { | ||
public struct S<T> { x: T } | ||
public struct A {} | ||
} | ||
|
||
module a::test { | ||
use a::m::{Self, S, A}; | ||
|
||
public fun p(a: | ||
|
||
public fun q(): | ||
} | ||
|
66 changes: 66 additions & 0 deletions
66
...al-crates/move/crates/move-compiler/tests/move_2024/ide_mode/partial_type_suggestions.exp
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,66 @@ | ||
warning[W09001]: unused alias | ||
┌─ tests/move_2024/ide_mode/partial_type_suggestions.move:7:16 | ||
│ | ||
7 │ use a::m::{Self, S, A}; | ||
│ ^^^^ Unused 'use' of alias 'm'. Consider removing it | ||
│ | ||
= This warning can be suppressed with '#[allow(unused_use)]' applied to the 'module' or module member ('const', 'fun', or 'struct') | ||
|
||
error[E03008]: too few type arguments | ||
┌─ tests/move_2024/ide_mode/partial_type_suggestions.move:9:28 | ||
│ | ||
9 │ public fun p(): vector<S | ||
│ ^ Invalid instantiation of 'a::m::S'. Expected 1 type argument(s) but got 0 | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/partial_type_suggestions.move:11:5 | ||
│ | ||
9 │ public fun p(): vector<S | ||
│ - To match this '<' | ||
10 │ | ||
11 │ public fun q(x: S<A | ||
│ ^ Expected '>' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/partial_type_suggestions.move:11:5 | ||
│ | ||
11 │ public fun q(x: S<A | ||
│ ^^^^^^ | ||
│ │ | ||
│ Unexpected 'public' | ||
│ Expected '{' | ||
|
||
warning[W09002]: unused variable | ||
┌─ tests/move_2024/ide_mode/partial_type_suggestions.move:11:18 | ||
│ | ||
11 │ public fun q(x: S<A | ||
│ ^ Unused parameter 'x'. Consider removing or prefixing with an underscore: '_x' | ||
│ | ||
= This warning can be suppressed with '#[allow(unused_variable)]' applied to the 'module' or module member ('const', 'fun', or 'struct') | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/partial_type_suggestions.move:12:1 | ||
│ | ||
11 │ public fun q(x: S<A | ||
│ - To match this '<' | ||
12 │ } | ||
│ ^ Expected '>' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/partial_type_suggestions.move:12:1 | ||
│ | ||
12 │ } | ||
│ ^ | ||
│ │ | ||
│ Unexpected '}' | ||
│ Expected ',' or ')' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/partial_type_suggestions.move:14:1 | ||
│ | ||
11 │ public fun q(x: S<A | ||
│ - To match this '(' | ||
· | ||
14 │ | ||
│ ^ Expected ')' | ||
|
Empty file.
Oops, something went wrong.