-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2caae8b
commit 8c0286b
Showing
6 changed files
with
90 additions
and
7 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
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,38 @@ | ||
pub(crate) use anyhow::Result; | ||
|
||
use interpreter::parser::{ParsedProgram, Parser}; | ||
use lsp_types::{Diagnostic, DiagnosticSeverity, Range, Uri}; | ||
|
||
use super::SonOfAnton; | ||
|
||
pub fn run_diagnostics(uri: Uri, lsp: &mut SonOfAnton) -> Result<Vec<Diagnostic>> { | ||
let mut parser = Parser::new(lsp.document_store.get_document(&uri)?); | ||
let parse_result = parser.parse_program(); | ||
|
||
Ok(match parse_result { | ||
ParsedProgram::ValidProgram(_) => Vec::with_capacity(0), | ||
ParsedProgram::InvalidProgram(errors) => errors | ||
.iter() | ||
.map(|error| { | ||
let error_location = &error.parse_error.token.location; | ||
let range = Range { | ||
start: lsp_types::Position { | ||
line: error_location.line_number - 1, | ||
character: 0, | ||
}, | ||
end: lsp_types::Position { | ||
line: error_location.line_number, | ||
character: 0, | ||
}, | ||
}; | ||
Diagnostic { | ||
range, | ||
severity: Some(DiagnosticSeverity::ERROR), | ||
source: Some("piperscript".to_owned()), | ||
message: error.to_string(), | ||
..Default::default() | ||
} | ||
}) | ||
.collect(), | ||
}) | ||
} |
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