-
Notifications
You must be signed in to change notification settings - Fork 5.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## Description Closes #4782 Notes This implementation relies on the diagnostics that are provided in the context of a code action request. Conveniently, only the diagnostics related to the symbol in the request are provided in the context. Since we also need the name of the symbol to look up, I added a `DiagnosticData` type to the metadata that is published with diagnostics. For the errors that indicate a missing symbol, this data is attached, and then used to look for possible imports when the code action request handler runs. - Added `ProgramTypeKeyword` symbol kind to distinguish them from other keywords - Added `submodules_recursive` to lexed and parsed modules because LSP wasn't collecting tokens inside of nested submodules. This implementation comes from typed module, I just made it generic via the `HasSubmodules` and `HasModule` traits. - Added `TyIncludeStatement` to the compiler, and span and mod_name to `IncludeStatement` to populate it. This was needed to identify where the end of the last `mod` statement is in the file. - Added `span` to `UseStatment` and `TyUseStatement` so that we can replace an entire Group statement with the new one. e.g. `use a::b::{C, D, E};` - Added `CallPath` to several of the typed tokens that were missing it. ### Testing - integration tests for each type of item that can be imported - unit tests for the location of the generated import in the file ### Limitations I found several bugs / edge cases where auto-import doesn't work: - enum variants: #5188 - std-lib functions: #5191 - std-lib constants: #5192 ## Checklist - [ ] I have linked to any relevant issues. - [ ] I have commented my code, particularly in hard-to-understand areas. - [ ] I have updated the documentation where relevant (API docs, the reference, and the Sway book). - [ ] I have added tests that prove my fix is effective or that my feature works. - [ ] I have added (or requested a maintainer to add) the necessary `Breaking*` or `New Feature` labels where relevant. - [ ] I have done my best to ensure that my PR adheres to [the Fuel Labs Code Review Standards](https://github.com/FuelLabs/rfcs/blob/master/text/code-standards/external-contributors.md). - [ ] I have requested a review from the relevant team or maintainers.
- Loading branch information
Showing
66 changed files
with
1,834 additions
and
314 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1,8 +1,11 @@ | ||
use sway_types::span::Span; | ||
use sway_types::{span::Span, Ident}; | ||
|
||
use crate::language::Visibility; | ||
|
||
#[derive(Clone, Debug)] | ||
pub struct IncludeStatement { | ||
// this span may be used for errors in the future, although it is not right now. | ||
pub(crate) _span: Span, | ||
pub(crate) _mod_name_span: Span, | ||
pub span: Span, | ||
pub mod_name: Ident, | ||
pub visibility: Visibility, | ||
} |
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
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
Oops, something went wrong.