pub enum Concern {
LintWarning(Warning),
ParseError(Error),
ValidationFailure(Failure),
}
Expand description
A concern.
A concern is defined as any information that is important to interpretting a returned parse or abstract syntax tree. There are three classes of concerns that can be returned:
- Parse errors, which are errors that are return by Pest during the building of the parse tree.
- Validation failures, which are error that are occur when validating a parse tree or abstract syntax tree.
- Lint warnings, which are notifications about syntactically and semantically correct code that is otherwise notable, such as stylistic errors, programming mistakes, or deviations from best practices.
Variants§
LintWarning(Warning)
A lint warning.
ParseError(Error)
A parse error.
ValidationFailure(Failure)
A validation failure.
Implementations§
Source§impl Concern
impl Concern
Sourcepub fn as_lint_warning(&self) -> Option<&Warning>
pub fn as_lint_warning(&self) -> Option<&Warning>
Returns [Some(&lint::Warning)
] if the Concern
is a
lint::Warning
. Otherwise, returns None
.
§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;
let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.as_lint_warning().is_none());
let failure = validation::failure::Builder::default()
.code(Code::try_new(Kind::Error, Version::V1, 1)?)
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::ValidationFailure(failure);
assert!(concern.as_lint_warning().is_none());
let warning = lint::warning::Builder::default()
.code(Code::try_new(Kind::Warning, Version::V1, 1)?)
.level(Level::High)
.tags(TagSet::new(&[lint::Tag::Style]))
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::LintWarning(warning);
assert!(concern.as_lint_warning().is_some());
Sourcepub fn into_lint_warning(self) -> Option<Warning>
pub fn into_lint_warning(self) -> Option<Warning>
Consumes self
and returns [Some(lint::Warning)
] if the Concern
is a lint::Warning
. Otherwise, returns None
.
§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;
let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.into_lint_warning().is_none());
let failure = validation::failure::Builder::default()
.code(Code::try_new(Kind::Error, Version::V1, 1)?)
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::ValidationFailure(failure);
assert!(concern.into_lint_warning().is_none());
let warning = lint::warning::Builder::default()
.code(Code::try_new(Kind::Warning, Version::V1, 1)?)
.level(Level::High)
.tags(TagSet::new(&[lint::Tag::Style]))
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::LintWarning(warning);
assert!(concern.into_lint_warning().is_some());
Sourcepub fn as_validation_failure(&self) -> Option<&Failure>
pub fn as_validation_failure(&self) -> Option<&Failure>
Returns [Some(&validation::Failure)
] if the Concern
is a
validation::Failure
. Otherwise, returns None
.
§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;
let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.as_validation_failure().is_none());
let failure = validation::failure::Builder::default()
.code(Code::try_new(Kind::Error, Version::V1, 1)?)
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::ValidationFailure(failure);
assert!(concern.as_validation_failure().is_some());
let warning = lint::warning::Builder::default()
.code(Code::try_new(Kind::Warning, Version::V1, 1)?)
.level(Level::High)
.tags(TagSet::new(&[lint::Tag::Style]))
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::LintWarning(warning);
assert!(concern.as_validation_failure().is_none());
Sourcepub fn into_validation_failure(self) -> Option<Failure>
pub fn into_validation_failure(self) -> Option<Failure>
Consumes self
and returns [Some(validation::Failure)
] if the
Concern
is a validation::Failure
. Otherwise, returns None
.
§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;
let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.into_validation_failure().is_none());
let failure = validation::failure::Builder::default()
.code(Code::try_new(Kind::Error, Version::V1, 1)?)
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::ValidationFailure(failure);
assert!(concern.into_validation_failure().is_some());
let warning = lint::warning::Builder::default()
.code(Code::try_new(Kind::Warning, Version::V1, 1)?)
.level(Level::High)
.tags(TagSet::new(&[lint::Tag::Style]))
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::LintWarning(warning);
assert!(concern.into_validation_failure().is_none());
Sourcepub fn as_parse_error(&self) -> Option<&Error>
pub fn as_parse_error(&self) -> Option<&Error>
Returns [Some(&parse::Error)
] if the Concern
is a
parse::Error
. Otherwise, returns None
.
§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;
let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.as_parse_error().is_some());
let failure = validation::failure::Builder::default()
.code(Code::try_new(Kind::Error, Version::V1, 1)?)
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::ValidationFailure(failure);
assert!(concern.as_parse_error().is_none());
let warning = lint::warning::Builder::default()
.code(Code::try_new(Kind::Warning, Version::V1, 1)?)
.level(Level::High)
.tags(TagSet::new(&[lint::Tag::Style]))
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::LintWarning(warning);
assert!(concern.as_parse_error().is_none());
Sourcepub fn into_parse_error(self) -> Option<Error>
pub fn into_parse_error(self) -> Option<Error>
Consumes self
and returns [Some(parse::Error)
] if the Concern
is
a parse::Error
. Otherwise, returns None
.
§Examples
use wdl_core::concern::code::Kind;
use wdl_core::concern::lint;
use wdl_core::concern::lint::Level;
use wdl_core::concern::lint::TagSet;
use wdl_core::concern::parse;
use wdl_core::concern::validation;
use wdl_core::concern::Code;
use wdl_core::file::Location;
use wdl_core::Concern;
use wdl_core::Version;
let error = parse::Error::new("Hello, world!", Location::Unplaced);
let concern = Concern::ParseError(error);
assert!(concern.into_parse_error().is_some());
let failure = validation::failure::Builder::default()
.code(Code::try_new(Kind::Error, Version::V1, 1)?)
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::ValidationFailure(failure);
assert!(concern.into_parse_error().is_none());
let warning = lint::warning::Builder::default()
.code(Code::try_new(Kind::Warning, Version::V1, 1)?)
.level(Level::High)
.tags(TagSet::new(&[lint::Tag::Style]))
.push_location(Location::Unplaced)
.subject("Hello, world!")
.body("A body.")
.fix("How to fix the issue.")
.try_build()?;
let concern = Concern::LintWarning(warning);
assert!(concern.into_parse_error().is_none());