mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
basic working
compiling, but still missing positions from expression errors
This commit is contained in:
parent
146710a129
commit
81f2095e61
14 changed files with 192 additions and 49 deletions
|
@ -122,7 +122,7 @@ pub(crate) fn global_analysis(doc_info: DocInfo) -> Vec<AnalyzedDocument> {
|
|||
Ok(module) => module,
|
||||
Err(problem) => {
|
||||
let all_problems = problem
|
||||
.into_lsp_diagnostic(&())
|
||||
.into_lsp_diagnostic(&doc_info.line_info)
|
||||
.into_iter()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
|
|
|
@ -1,3 +1,7 @@
|
|||
use std::any::Any;
|
||||
|
||||
use roc_load::LoadingProblem;
|
||||
use roc_parse::parser::{EHeader, EPattern, EType, SourceError, SyntaxError};
|
||||
use roc_region::all::{LineColumn, LineColumnRegion, LineInfo, Region};
|
||||
use tower_lsp::lsp_types::{Position, Range};
|
||||
|
||||
|
@ -69,7 +73,7 @@ impl ToRocPosition for tower_lsp::lsp_types::Position {
|
|||
}
|
||||
|
||||
pub(crate) mod diag {
|
||||
use std::path::Path;
|
||||
use std::{fmt::Debug, path::Path};
|
||||
|
||||
use roc_load::LoadingProblem;
|
||||
use roc_region::all::{LineInfo, Region};
|
||||
|
@ -102,19 +106,16 @@ pub(crate) mod diag {
|
|||
}
|
||||
|
||||
impl IntoLspDiagnostic<'_> for &LoadingProblem<'_> {
|
||||
type Feed = ();
|
||||
type Feed = LineInfo;
|
||||
|
||||
fn into_lsp_diagnostic(self, _feed: &()) -> Option<Diagnostic> {
|
||||
let range = Range {
|
||||
start: Position {
|
||||
line: 0,
|
||||
character: 0,
|
||||
},
|
||||
end: Position {
|
||||
line: 0,
|
||||
character: 1,
|
||||
},
|
||||
};
|
||||
fn into_lsp_diagnostic(self, line_info: &LineInfo) -> Option<Diagnostic> {
|
||||
let mut range = self
|
||||
.get_region()
|
||||
.unwrap_or(Region::new(
|
||||
roc_region::all::Position::new(0),
|
||||
roc_region::all::Position::new(10000000),
|
||||
))
|
||||
.to_range(line_info);
|
||||
|
||||
let msg = match self {
|
||||
LoadingProblem::FileProblem { filename, error } => {
|
||||
|
@ -152,7 +153,10 @@ pub(crate) mod diag {
|
|||
LoadingProblem::TriedToImportAppModule => {
|
||||
"Attempted to import app module".to_string()
|
||||
}
|
||||
LoadingProblem::FormattedReport(report) => report.clone(),
|
||||
LoadingProblem::FormattedReport(report, region) => {
|
||||
range = region.unwrap_or(Region::zero()).to_range(line_info);
|
||||
report.clone()
|
||||
}
|
||||
LoadingProblem::ImportCycle(_, _) => {
|
||||
"Circular dependency between modules".to_string()
|
||||
}
|
||||
|
@ -194,7 +198,10 @@ pub(crate) mod diag {
|
|||
fn into_lsp_diagnostic(self, fmt: &'a ProblemFmt<'a>) -> Option<Diagnostic> {
|
||||
let range = self
|
||||
.region()
|
||||
.unwrap_or_else(Region::zero)
|
||||
.unwrap_or(Region::new(
|
||||
roc_region::all::Position::new(0),
|
||||
roc_region::all::Position::new(10000000),
|
||||
))
|
||||
.to_range(fmt.line_info);
|
||||
|
||||
let report = roc_reporting::report::can_problem(
|
||||
|
@ -228,7 +235,10 @@ pub(crate) mod diag {
|
|||
fn into_lsp_diagnostic(self, fmt: &'a ProblemFmt<'a>) -> Option<Diagnostic> {
|
||||
let range = self
|
||||
.region()
|
||||
.unwrap_or_else(Region::zero)
|
||||
.unwrap_or(Region::new(
|
||||
roc_region::all::Position::new(0),
|
||||
roc_region::all::Position::new(10000000),
|
||||
))
|
||||
.to_range(fmt.line_info);
|
||||
|
||||
let report = roc_reporting::report::type_problem(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue