-
Notifications
You must be signed in to change notification settings - Fork 11.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[move-compler] Added parser resilience for use declarations (#18879)
## Description This PR adds parsing resilience when parsing use declarations. The idea is to recognize partially parsed statements (examples below and also in the new test) to enable auto-completion in the IDE. ``` use a::m2:: use a::m2::{foo use a::m2::{foo, bar use a::{m2::{foo, bar use a::{m2::{foo, bar}, m3 ``` ## Test plan New and all tests must pass --- ## 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: - [x] CLI: Additional compiler errors for incomplete name access chains (such as `use some_pkg::some_module::`) might appear in the compiler output. - [ ] Rust SDK: - [ ] REST API:
- Loading branch information
Showing
10 changed files
with
312 additions
and
63 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
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
77 changes: 77 additions & 0 deletions
77
external-crates/move/crates/move-compiler/tests/move_2024/ide_mode/use_incomplete.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,77 @@ | ||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/use_incomplete.move:5:9 | ||
│ | ||
5 │ let _tmp = 42; // reset parser to see if the next line compiles | ||
│ ^^^ | ||
│ │ | ||
│ Unexpected 'let' | ||
│ Expected an identifier | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/use_incomplete.move:11:9 | ||
│ | ||
11 │ let _tmp = 42; // reset parser to see if the next line compiles | ||
│ ^^^ | ||
│ │ | ||
│ Unexpected 'let' | ||
│ Expected ',' or '}' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/use_incomplete.move:11:22 | ||
│ | ||
10 │ use a::m2::{foo | ||
│ - To match this '{' | ||
11 │ let _tmp = 42; // reset parser to see if the next line compiles | ||
│ ^ Expected '}' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/use_incomplete.move:17:9 | ||
│ | ||
17 │ let _tmp = 42; // reset parser to see if the next lines compile | ||
│ ^^^ | ||
│ │ | ||
│ Unexpected 'let' | ||
│ Expected ',' or '}' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/use_incomplete.move:17:22 | ||
│ | ||
16 │ use a::m2::{foo, bar | ||
│ - To match this '{' | ||
17 │ let _tmp = 42; // reset parser to see if the next lines compile | ||
│ ^ Expected '}' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/use_incomplete.move:24:9 | ||
│ | ||
24 │ let _tmp = 42; // reset parser to see if the next lines compile | ||
│ ^^^ | ||
│ │ | ||
│ Unexpected 'let' | ||
│ Expected ',' or '}' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/use_incomplete.move:24:22 | ||
│ | ||
23 │ use a::{m2::{foo, bar | ||
│ - To match this '{' | ||
24 │ let _tmp = 42; // reset parser to see if the next lines compile | ||
│ ^ Expected '}' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/use_incomplete.move:32:9 | ||
│ | ||
32 │ let _tmp = 42; // reset parser to see if the next lines compile | ||
│ ^^^ | ||
│ │ | ||
│ Unexpected 'let' | ||
│ Expected ',' or '}' | ||
|
||
error[E01002]: unexpected token | ||
┌─ tests/move_2024/ide_mode/use_incomplete.move:32:22 | ||
│ | ||
31 │ use a::{m2::{foo, bar}, m3 | ||
│ - To match this '{' | ||
32 │ let _tmp = 42; // reset parser to see if the next lines compile | ||
│ ^ Expected '}' | ||
|
Oops, something went wrong.