Define 'ExtraData' trait for errors
This should allow passing some extra information to LSP diagnostic in order to provide quickfix actions, such as auto-imports.
This commit is contained in:
@@ -4,6 +4,7 @@ use crate::{
|
||||
};
|
||||
use aiken_lang::{
|
||||
ast::{self, BinOp, Span},
|
||||
error::ExtraData,
|
||||
parser::error::ParseError,
|
||||
tipo,
|
||||
};
|
||||
@@ -172,6 +173,34 @@ impl From<Error> for Vec<Error> {
|
||||
}
|
||||
}
|
||||
|
||||
impl ExtraData for Error {
|
||||
fn extra_data(&self) -> Option<String> {
|
||||
match self {
|
||||
Error::DuplicateModule { .. } => None,
|
||||
Error::FileIo { .. } => None,
|
||||
Error::Format { .. } => None,
|
||||
Error::StandardIo { .. } => None,
|
||||
Error::Blueprint { .. } => None,
|
||||
Error::MissingManifest { .. } => None,
|
||||
Error::TomlLoading { .. } => None,
|
||||
Error::ImportCycle { .. } => None,
|
||||
Error::Parse { .. } => None,
|
||||
Error::Type { error, .. } => error.extra_data(),
|
||||
Error::TestFailure { .. } => None,
|
||||
Error::Http { .. } => None,
|
||||
Error::ZipExtract { .. } => None,
|
||||
Error::JoinError { .. } => None,
|
||||
Error::UnknownPackageVersion { .. } => None,
|
||||
Error::UnableToResolvePackage { .. } => None,
|
||||
Error::Json { .. } => None,
|
||||
Error::MalformedStakeAddress { .. } => None,
|
||||
Error::NoValidatorNotFound { .. } => None,
|
||||
Error::MoreThanOneValidatorFound { .. } => None,
|
||||
Error::Module { .. } => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub trait GetSource {
|
||||
fn path(&self) -> Option<PathBuf>;
|
||||
fn src(&self) -> Option<String>;
|
||||
@@ -481,6 +510,16 @@ pub enum Warning {
|
||||
DependencyAlreadyExists { name: PackageName },
|
||||
}
|
||||
|
||||
impl ExtraData for Warning {
|
||||
fn extra_data(&self) -> Option<String> {
|
||||
match self {
|
||||
Warning::NoValidators { .. } => None,
|
||||
Warning::DependencyAlreadyExists { .. } => None,
|
||||
Warning::Type { warning, .. } => warning.extra_data(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl GetSource for Warning {
|
||||
fn path(&self) -> Option<PathBuf> {
|
||||
match self {
|
||||
|
||||
Reference in New Issue
Block a user