mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
drilling into every error type when getting region
This commit is contained in:
parent
81f2095e61
commit
7eb81fbcf3
2 changed files with 642 additions and 48 deletions
|
@ -73,7 +73,7 @@ impl<'a> SyntaxError<'a> {
|
||||||
SyntaxError::Type(e_type) => Some(e_type.get_region()),
|
SyntaxError::Type(e_type) => Some(e_type.get_region()),
|
||||||
SyntaxError::Pattern(e_pattern) => Some(e_pattern.get_region()),
|
SyntaxError::Pattern(e_pattern) => Some(e_pattern.get_region()),
|
||||||
SyntaxError::NotEndOfFile(pos) => Some(Region::from_pos(*pos)),
|
SyntaxError::NotEndOfFile(pos) => Some(Region::from_pos(*pos)),
|
||||||
SyntaxError::Expr(e_expr, pos) => Some(Region::from_pos(*pos)),
|
SyntaxError::Expr(e_expr, _) => Some(e_expr.get_region()),
|
||||||
SyntaxError::Header(e_header) => Some(e_header.get_region()),
|
SyntaxError::Header(e_header) => Some(e_header.get_region()),
|
||||||
SyntaxError::NotYetImplemented(_) => None,
|
SyntaxError::NotYetImplemented(_) => None,
|
||||||
SyntaxError::OutdentedTooFar => None,
|
SyntaxError::OutdentedTooFar => None,
|
||||||
|
@ -158,19 +158,19 @@ pub enum EHeader<'a> {
|
||||||
impl<'a> EHeader<'a> {
|
impl<'a> EHeader<'a> {
|
||||||
pub fn get_region(&self) -> Region {
|
pub fn get_region(&self) -> Region {
|
||||||
match self {
|
match self {
|
||||||
EHeader::Provides(_, pos)
|
EHeader::Provides(provides, pos) => provides.get_region(),
|
||||||
| EHeader::Params(_, pos)
|
EHeader::Params(params, pos) => params.get_region(),
|
||||||
| EHeader::Exposes(_, pos)
|
EHeader::Exposes(_, pos) => Region::from_pos(*pos),
|
||||||
| EHeader::Imports(_, pos)
|
EHeader::Imports(_, pos) => Region::from_pos(*pos),
|
||||||
| EHeader::Requires(_, pos)
|
EHeader::Requires(requires, pos) => requires.get_region(),
|
||||||
| EHeader::Packages(_, pos)
|
EHeader::Packages(packages, pos) => packages.get_region(),
|
||||||
| EHeader::Space(_, pos)
|
EHeader::Space(_, pos) => Region::from_pos(*pos),
|
||||||
| EHeader::Start(pos)
|
EHeader::Start(pos) => Region::from_pos(*pos),
|
||||||
| EHeader::ModuleName(pos)
|
EHeader::ModuleName(pos) => Region::from_pos(*pos),
|
||||||
| EHeader::AppName(_, pos)
|
EHeader::AppName(app_name, pos) => app_name.get_region(),
|
||||||
| EHeader::PackageName(_, pos)
|
EHeader::PackageName(package_name, pos) => package_name.get_region(),
|
||||||
| EHeader::PlatformName(_, pos)
|
EHeader::PlatformName(platform_name, pos) => platform_name.get_region(),
|
||||||
| EHeader::IndentStart(pos) => Region::from_pos(*pos),
|
EHeader::IndentStart(pos) => Region::from_pos(*pos),
|
||||||
EHeader::InconsistentModuleName(region) => *region,
|
EHeader::InconsistentModuleName(region) => *region,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -192,6 +192,26 @@ pub enum EProvides<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EProvides<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
let pos = match self {
|
||||||
|
EProvides::Provides(p)
|
||||||
|
| EProvides::Open(p)
|
||||||
|
| EProvides::To(p)
|
||||||
|
| EProvides::IndentProvides(p)
|
||||||
|
| EProvides::IndentTo(p)
|
||||||
|
| EProvides::IndentListStart(p)
|
||||||
|
| EProvides::IndentPackage(p)
|
||||||
|
| EProvides::ListStart(p)
|
||||||
|
| EProvides::ListEnd(p)
|
||||||
|
| EProvides::Identifier(p)
|
||||||
|
| EProvides::Package(_, p)
|
||||||
|
| EProvides::Space(_, p) => p,
|
||||||
|
};
|
||||||
|
Region::from_pos(*pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EParams<'a> {
|
pub enum EParams<'a> {
|
||||||
Pattern(PRecord<'a>, Position),
|
Pattern(PRecord<'a>, Position),
|
||||||
|
@ -201,6 +221,19 @@ pub enum EParams<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EParams<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
let pos = match self {
|
||||||
|
EParams::Pattern(_, p)
|
||||||
|
| EParams::BeforeArrow(p)
|
||||||
|
| EParams::Arrow(p)
|
||||||
|
| EParams::AfterArrow(p)
|
||||||
|
| EParams::Space(_, p) => p,
|
||||||
|
};
|
||||||
|
Region::from_pos(*pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum EExposes {
|
pub enum EExposes {
|
||||||
Exposes(Position),
|
Exposes(Position),
|
||||||
|
@ -213,6 +246,22 @@ pub enum EExposes {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl EExposes {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
let pos = match self {
|
||||||
|
EExposes::Exposes(p)
|
||||||
|
| EExposes::Open(p)
|
||||||
|
| EExposes::IndentExposes(p)
|
||||||
|
| EExposes::IndentListStart(p)
|
||||||
|
| EExposes::ListStart(p)
|
||||||
|
| EExposes::ListEnd(p)
|
||||||
|
| EExposes::Identifier(p)
|
||||||
|
| EExposes::Space(_, p) => p,
|
||||||
|
};
|
||||||
|
Region::from_pos(*pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum ERequires<'a> {
|
pub enum ERequires<'a> {
|
||||||
Requires(Position),
|
Requires(Position),
|
||||||
|
@ -226,6 +275,23 @@ pub enum ERequires<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> ERequires<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
let pos = match self {
|
||||||
|
ERequires::Requires(p)
|
||||||
|
| ERequires::Open(p)
|
||||||
|
| ERequires::IndentRequires(p)
|
||||||
|
| ERequires::IndentListStart(p)
|
||||||
|
| ERequires::ListStart(p)
|
||||||
|
| ERequires::ListEnd(p)
|
||||||
|
| ERequires::TypedIdent(_, p)
|
||||||
|
| ERequires::Rigid(p)
|
||||||
|
| ERequires::Space(_, p) => p,
|
||||||
|
};
|
||||||
|
Region::from_pos(*pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum ETypedIdent<'a> {
|
pub enum ETypedIdent<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
|
@ -237,6 +303,21 @@ pub enum ETypedIdent<'a> {
|
||||||
Identifier(Position),
|
Identifier(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> ETypedIdent<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
let pos = match self {
|
||||||
|
ETypedIdent::Space(_, p)
|
||||||
|
| ETypedIdent::HasType(p)
|
||||||
|
| ETypedIdent::IndentHasType(p)
|
||||||
|
| ETypedIdent::Name(p)
|
||||||
|
| ETypedIdent::Type(_, p)
|
||||||
|
| ETypedIdent::IndentType(p)
|
||||||
|
| ETypedIdent::Identifier(p) => p,
|
||||||
|
};
|
||||||
|
Region::from_pos(*pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EPackages<'a> {
|
pub enum EPackages<'a> {
|
||||||
Open(Position),
|
Open(Position),
|
||||||
|
@ -250,6 +331,23 @@ pub enum EPackages<'a> {
|
||||||
PackageEntry(EPackageEntry<'a>, Position),
|
PackageEntry(EPackageEntry<'a>, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EPackages<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
let pos = match self {
|
||||||
|
EPackages::Open(p)
|
||||||
|
| EPackages::Space(_, p)
|
||||||
|
| EPackages::Packages(p)
|
||||||
|
| EPackages::IndentPackages(p)
|
||||||
|
| EPackages::ListStart(p)
|
||||||
|
| EPackages::ListEnd(p)
|
||||||
|
| EPackages::IndentListStart(p)
|
||||||
|
| EPackages::IndentListEnd(p)
|
||||||
|
| EPackages::PackageEntry(_, p) => p,
|
||||||
|
};
|
||||||
|
Region::from_pos(*pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EPackageName<'a> {
|
pub enum EPackageName<'a> {
|
||||||
BadPath(EString<'a>, Position),
|
BadPath(EString<'a>, Position),
|
||||||
|
@ -257,6 +355,17 @@ pub enum EPackageName<'a> {
|
||||||
Multiline(Position),
|
Multiline(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EPackageName<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
let pos = match self {
|
||||||
|
EPackageName::BadPath(_, p) | EPackageName::Escapes(p) | EPackageName::Multiline(p) => {
|
||||||
|
p
|
||||||
|
}
|
||||||
|
};
|
||||||
|
Region::from_pos(*pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EPackageEntry<'a> {
|
pub enum EPackageEntry<'a> {
|
||||||
BadPackage(EPackageName<'a>, Position),
|
BadPackage(EPackageName<'a>, Position),
|
||||||
|
@ -268,6 +377,21 @@ pub enum EPackageEntry<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EPackageEntry<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
let pos = match self {
|
||||||
|
EPackageEntry::BadPackage(_, p)
|
||||||
|
| EPackageEntry::Shorthand(p)
|
||||||
|
| EPackageEntry::Colon(p)
|
||||||
|
| EPackageEntry::IndentPackage(p)
|
||||||
|
| EPackageEntry::IndentPlatform(p)
|
||||||
|
| EPackageEntry::Platform(p)
|
||||||
|
| EPackageEntry::Space(_, p) => p,
|
||||||
|
};
|
||||||
|
Region::from_pos(*pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum EImports {
|
pub enum EImports {
|
||||||
Open(Position),
|
Open(Position),
|
||||||
|
@ -291,6 +415,33 @@ pub enum EImports {
|
||||||
StrLiteral(Position),
|
StrLiteral(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl EImports {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
let pos = match self {
|
||||||
|
EImports::Open(p)
|
||||||
|
| EImports::Imports(p)
|
||||||
|
| EImports::IndentImports(p)
|
||||||
|
| EImports::IndentListStart(p)
|
||||||
|
| EImports::IndentListEnd(p)
|
||||||
|
| EImports::ListStart(p)
|
||||||
|
| EImports::ListEnd(p)
|
||||||
|
| EImports::Identifier(p)
|
||||||
|
| EImports::ExposingDot(p)
|
||||||
|
| EImports::ShorthandDot(p)
|
||||||
|
| EImports::Shorthand(p)
|
||||||
|
| EImports::ModuleName(p)
|
||||||
|
| EImports::Space(_, p)
|
||||||
|
| EImports::IndentSetStart(p)
|
||||||
|
| EImports::SetStart(p)
|
||||||
|
| EImports::SetEnd(p)
|
||||||
|
| EImports::TypedIdent(p)
|
||||||
|
| EImports::AsKeyword(p)
|
||||||
|
| EImports::StrLiteral(p) => p,
|
||||||
|
};
|
||||||
|
Region::from_pos(*pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum BadInputError {
|
pub enum BadInputError {
|
||||||
HasTab,
|
HasTab,
|
||||||
|
@ -406,6 +557,69 @@ pub enum EExpr<'a> {
|
||||||
UnexpectedTopLevelExpr(Position),
|
UnexpectedTopLevelExpr(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EExpr<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Cases with child nodes that have get_region()
|
||||||
|
EExpr::Type(e_type, _) => e_type.get_region(),
|
||||||
|
EExpr::Pattern(e_pattern, _) => e_pattern.get_region(),
|
||||||
|
EExpr::Ability(e_ability, _) => e_ability.get_region(),
|
||||||
|
EExpr::When(e_when, _) => e_when.get_region(),
|
||||||
|
EExpr::If(e_if, _) => e_if.get_region(),
|
||||||
|
EExpr::Expect(e_expect, _) => e_expect.get_region(),
|
||||||
|
EExpr::Dbg(e_expect, _) => e_expect.get_region(),
|
||||||
|
EExpr::Import(e_import, _) => e_import.get_region(),
|
||||||
|
EExpr::Return(e_return, _) => e_return.get_region(),
|
||||||
|
EExpr::Closure(e_closure, _) => e_closure.get_region(),
|
||||||
|
EExpr::InParens(e_in_parens, _) => e_in_parens.get_region(),
|
||||||
|
EExpr::Record(e_record, _) => e_record.get_region(),
|
||||||
|
EExpr::Str(e_string, _) => e_string.get_region(),
|
||||||
|
EExpr::List(e_list, _) => e_list.get_region(),
|
||||||
|
|
||||||
|
// Cases with direct Region values
|
||||||
|
EExpr::RecordUpdateOldBuilderField(r)
|
||||||
|
| EExpr::RecordUpdateIgnoredField(r)
|
||||||
|
| EExpr::RecordBuilderOldBuilderField(r) => *r,
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
EExpr::TrailingOperator(p)
|
||||||
|
| EExpr::Start(p)
|
||||||
|
| EExpr::End(p)
|
||||||
|
| EExpr::BadExprEnd(p)
|
||||||
|
| EExpr::Space(_, p)
|
||||||
|
| EExpr::Dot(p)
|
||||||
|
| EExpr::Access(p)
|
||||||
|
| EExpr::UnaryNot(p)
|
||||||
|
| EExpr::UnaryNegate(p)
|
||||||
|
| EExpr::BadOperator(_, p)
|
||||||
|
| EExpr::DefMissingFinalExpr(p)
|
||||||
|
| EExpr::DefMissingFinalExpr2(_, p)
|
||||||
|
| EExpr::IndentDefBody(p)
|
||||||
|
| EExpr::IndentEquals(p)
|
||||||
|
| EExpr::IndentAnnotation(p)
|
||||||
|
| EExpr::Equals(p)
|
||||||
|
| EExpr::Colon(p)
|
||||||
|
| EExpr::DoubleColon(p)
|
||||||
|
| EExpr::Ident(p)
|
||||||
|
| EExpr::ElmStyleFunction(_, p)
|
||||||
|
| EExpr::MalformedPattern(p)
|
||||||
|
| EExpr::QualifiedTag(p)
|
||||||
|
| EExpr::BackpassComma(p)
|
||||||
|
| EExpr::BackpassArrow(p)
|
||||||
|
| EExpr::BackpassContinue(p)
|
||||||
|
| EExpr::DbgContinue(p)
|
||||||
|
| EExpr::Underscore(p)
|
||||||
|
| EExpr::Crash(p)
|
||||||
|
| EExpr::Try(p)
|
||||||
|
| EExpr::Number(_, p)
|
||||||
|
| EExpr::IndentStart(p)
|
||||||
|
| EExpr::IndentEnd(p)
|
||||||
|
| EExpr::UnexpectedComma(p)
|
||||||
|
| EExpr::UnexpectedTopLevelExpr(p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum ENumber {
|
pub enum ENumber {
|
||||||
End,
|
End,
|
||||||
|
@ -431,6 +645,29 @@ pub enum EString<'a> {
|
||||||
ExpectedDoubleQuoteGotSingleQuote(Position),
|
ExpectedDoubleQuoteGotSingleQuote(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EString<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Case with child node that has get_region()
|
||||||
|
EString::Format(expr, _) => expr.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
EString::Open(p)
|
||||||
|
| EString::CodePtOpen(p)
|
||||||
|
| EString::CodePtEnd(p)
|
||||||
|
| EString::InvalidSingleQuote(_, p)
|
||||||
|
| EString::Space(_, p)
|
||||||
|
| EString::EndlessSingleLine(p)
|
||||||
|
| EString::EndlessMultiLine(p)
|
||||||
|
| EString::EndlessSingleQuote(p)
|
||||||
|
| EString::UnknownEscape(p)
|
||||||
|
| EString::FormatEnd(p)
|
||||||
|
| EString::MultilineInsufficientIndent(p)
|
||||||
|
| EString::ExpectedDoubleQuoteGotSingleQuote(p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||||
pub enum ESingleQuote {
|
pub enum ESingleQuote {
|
||||||
Empty,
|
Empty,
|
||||||
|
@ -457,6 +694,27 @@ pub enum ERecord<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> ERecord<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Cases with child node that has get_region()
|
||||||
|
ERecord::Expr(expr, _) => expr.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
ERecord::End(p)
|
||||||
|
| ERecord::Open(p)
|
||||||
|
| ERecord::Prefix(p)
|
||||||
|
| ERecord::Field(p)
|
||||||
|
| ERecord::UnderscoreField(p)
|
||||||
|
| ERecord::Colon(p)
|
||||||
|
| ERecord::QuestionMark(p)
|
||||||
|
| ERecord::Arrow(p)
|
||||||
|
| ERecord::Ampersand(p)
|
||||||
|
| ERecord::Space(_, p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EInParens<'a> {
|
pub enum EInParens<'a> {
|
||||||
End(Position),
|
End(Position),
|
||||||
|
@ -472,6 +730,21 @@ pub enum EInParens<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EInParens<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Cases with child node that has get_region()
|
||||||
|
EInParens::Expr(expr, _) => expr.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
EInParens::End(p)
|
||||||
|
| EInParens::Open(p)
|
||||||
|
| EInParens::Empty(p)
|
||||||
|
| EInParens::Space(_, p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EClosure<'a> {
|
pub enum EClosure<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
|
@ -487,6 +760,26 @@ pub enum EClosure<'a> {
|
||||||
IndentArg(Position),
|
IndentArg(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EClosure<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Cases with child nodes that have get_region()
|
||||||
|
EClosure::Pattern(pattern, _) => pattern.get_region(),
|
||||||
|
EClosure::Body(expr, _) => expr.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
EClosure::Space(_, p)
|
||||||
|
| EClosure::Start(p)
|
||||||
|
| EClosure::Arrow(p)
|
||||||
|
| EClosure::Comma(p)
|
||||||
|
| EClosure::Arg(p)
|
||||||
|
| EClosure::IndentArrow(p)
|
||||||
|
| EClosure::IndentBody(p)
|
||||||
|
| EClosure::IndentArg(p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EList<'a> {
|
pub enum EList<'a> {
|
||||||
Open(Position),
|
Open(Position),
|
||||||
|
@ -496,6 +789,18 @@ pub enum EList<'a> {
|
||||||
Expr(&'a EExpr<'a>, Position),
|
Expr(&'a EExpr<'a>, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EList<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Case with child node that has get_region()
|
||||||
|
EList::Expr(expr, _) => expr.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
EList::Open(p) | EList::End(p) | EList::Space(_, p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EWhen<'a> {
|
pub enum EWhen<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
|
@ -519,6 +824,32 @@ pub enum EWhen<'a> {
|
||||||
PatternAlignment(u32, Position),
|
PatternAlignment(u32, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EWhen<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Cases with child nodes that have get_region()
|
||||||
|
EWhen::Pattern(pattern, _) => pattern.get_region(),
|
||||||
|
EWhen::IfGuard(expr, _) => expr.get_region(),
|
||||||
|
EWhen::Condition(expr, _) => expr.get_region(),
|
||||||
|
EWhen::Branch(expr, _) => expr.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
EWhen::Space(_, p)
|
||||||
|
| EWhen::When(p)
|
||||||
|
| EWhen::Is(p)
|
||||||
|
| EWhen::Arrow(p)
|
||||||
|
| EWhen::Bar(p)
|
||||||
|
| EWhen::IfToken(p)
|
||||||
|
| EWhen::IndentCondition(p)
|
||||||
|
| EWhen::IndentPattern(p)
|
||||||
|
| EWhen::IndentArrow(p)
|
||||||
|
| EWhen::IndentBranch(p)
|
||||||
|
| EWhen::IndentIfGuard(p)
|
||||||
|
| EWhen::PatternAlignment(_, p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EAbility<'a> {
|
pub enum EAbility<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
|
@ -529,6 +860,21 @@ pub enum EAbility<'a> {
|
||||||
DemandColon(Position),
|
DemandColon(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EAbility<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Case with child node that has get_region()
|
||||||
|
EAbility::Type(e_type, _) => e_type.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
EAbility::Space(_, p)
|
||||||
|
| EAbility::DemandAlignment(_, p)
|
||||||
|
| EAbility::DemandName(p)
|
||||||
|
| EAbility::DemandColon(p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EIf<'a> {
|
pub enum EIf<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
|
@ -548,6 +894,24 @@ pub enum EIf<'a> {
|
||||||
IndentElseBranch(Position),
|
IndentElseBranch(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EIf<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
EIf::Condition(expr, _) | EIf::ThenBranch(expr, _) | EIf::ElseBranch(expr, _) => expr.get_region(),
|
||||||
|
EIf::Space(_, p)
|
||||||
|
| EIf::If(p)
|
||||||
|
| EIf::Then(p)
|
||||||
|
| EIf::Else(p)
|
||||||
|
| EIf::IndentCondition(p)
|
||||||
|
| EIf::IndentIf(p)
|
||||||
|
| EIf::IndentThenToken(p)
|
||||||
|
| EIf::IndentElseToken(p)
|
||||||
|
| EIf::IndentThenBranch(p)
|
||||||
|
| EIf::IndentElseBranch(p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EExpect<'a> {
|
pub enum EExpect<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
|
@ -558,6 +922,18 @@ pub enum EExpect<'a> {
|
||||||
IndentCondition(Position),
|
IndentCondition(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EExpect<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
EExpect::Condition(expr, _) | EExpect::Continuation(expr, _) => expr.get_region(),
|
||||||
|
EExpect::Space(_, p)
|
||||||
|
| EExpect::Dbg(p)
|
||||||
|
| EExpect::Expect(p)
|
||||||
|
| EExpect::IndentCondition(p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EReturn<'a> {
|
pub enum EReturn<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
|
@ -565,6 +941,16 @@ pub enum EReturn<'a> {
|
||||||
ReturnValue(&'a EExpr<'a>, Position),
|
ReturnValue(&'a EExpr<'a>, Position),
|
||||||
IndentReturnValue(Position),
|
IndentReturnValue(Position),
|
||||||
}
|
}
|
||||||
|
impl<'a> EReturn<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
EReturn::ReturnValue(expr, _) => expr.get_region(),
|
||||||
|
EReturn::Space(_, p)
|
||||||
|
| EReturn::Return(p)
|
||||||
|
| EReturn::IndentReturnValue(p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EImport<'a> {
|
pub enum EImport<'a> {
|
||||||
|
@ -596,6 +982,44 @@ pub enum EImport<'a> {
|
||||||
EndNewline(Position),
|
EndNewline(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EImport<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Cases with child nodes that have get_region()
|
||||||
|
EImport::Params(params, _) => params.get_region(),
|
||||||
|
EImport::Annotation(e_type, _) => e_type.get_region(),
|
||||||
|
|
||||||
|
// Case with direct Region value
|
||||||
|
EImport::LowercaseAlias(r) => *r,
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
EImport::Import(p)
|
||||||
|
| EImport::IndentStart(p)
|
||||||
|
| EImport::PackageShorthand(p)
|
||||||
|
| EImport::PackageShorthandDot(p)
|
||||||
|
| EImport::ModuleName(p)
|
||||||
|
| EImport::IndentAs(p)
|
||||||
|
| EImport::As(p)
|
||||||
|
| EImport::IndentAlias(p)
|
||||||
|
| EImport::Alias(p)
|
||||||
|
| EImport::IndentExposing(p)
|
||||||
|
| EImport::Exposing(p)
|
||||||
|
| EImport::ExposingListStart(p)
|
||||||
|
| EImport::ExposedName(p)
|
||||||
|
| EImport::ExposingListEnd(p)
|
||||||
|
| EImport::IndentIngestedPath(p)
|
||||||
|
| EImport::IngestedPath(p)
|
||||||
|
| EImport::IndentIngestedName(p)
|
||||||
|
| EImport::IngestedName(p)
|
||||||
|
| EImport::IndentColon(p)
|
||||||
|
| EImport::Colon(p)
|
||||||
|
| EImport::IndentAnnotation(p)
|
||||||
|
| EImport::Space(_, p)
|
||||||
|
| EImport::EndNewline(p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EImportParams<'a> {
|
pub enum EImportParams<'a> {
|
||||||
Indent(Position),
|
Indent(Position),
|
||||||
|
@ -606,6 +1030,19 @@ pub enum EImportParams<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> EImportParams<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
EImportParams::Indent(p) | EImportParams::Record(_, p) | EImportParams::Space(_, p) => {
|
||||||
|
Region::from_pos(*p)
|
||||||
|
}
|
||||||
|
EImportParams::RecordUpdateFound(r)
|
||||||
|
| EImportParams::RecordBuilderFound(r)
|
||||||
|
| EImportParams::RecordIgnoredFieldFound(r) => *r,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EPattern<'a> {
|
pub enum EPattern<'a> {
|
||||||
Record(PRecord<'a>, Position),
|
Record(PRecord<'a>, Position),
|
||||||
|
@ -632,10 +1069,14 @@ pub enum EPattern<'a> {
|
||||||
|
|
||||||
impl<'a> EPattern<'a> {
|
impl<'a> EPattern<'a> {
|
||||||
pub fn get_region(&self) -> Region {
|
pub fn get_region(&self) -> Region {
|
||||||
let pos = match self {
|
match self {
|
||||||
EPattern::Record(_, position)
|
// Cases with child nodes that have get_region()
|
||||||
| EPattern::List(_, position)
|
EPattern::Record(expr, _) => expr.get_region(),
|
||||||
| EPattern::AsKeyword(position)
|
EPattern::List(expr, _) => expr.get_region(),
|
||||||
|
EPattern::PInParens(expr, _) => expr.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
EPattern::AsKeyword(position)
|
||||||
| EPattern::AsIdentifier(position)
|
| EPattern::AsIdentifier(position)
|
||||||
| EPattern::Underscore(position)
|
| EPattern::Underscore(position)
|
||||||
| EPattern::NotAPattern(position)
|
| EPattern::NotAPattern(position)
|
||||||
|
@ -648,9 +1089,8 @@ impl<'a> EPattern<'a> {
|
||||||
| EPattern::IndentEnd(position)
|
| EPattern::IndentEnd(position)
|
||||||
| EPattern::AsIndentStart(position)
|
| EPattern::AsIndentStart(position)
|
||||||
| EPattern::AccessorFunction(position)
|
| EPattern::AccessorFunction(position)
|
||||||
| EPattern::RecordUpdaterFunction(position) => position,
|
| EPattern::RecordUpdaterFunction(position) => Region::from_pos(*position),
|
||||||
};
|
}
|
||||||
Region::from_pos(*pos)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -669,6 +1109,24 @@ pub enum PRecord<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> PRecord<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Cases with child nodes that have get_region()
|
||||||
|
PRecord::Pattern(pattern, _) => pattern.get_region(),
|
||||||
|
PRecord::Expr(expr, _) => expr.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
PRecord::End(p)
|
||||||
|
| PRecord::Open(p)
|
||||||
|
| PRecord::Field(p)
|
||||||
|
| PRecord::Colon(p)
|
||||||
|
| PRecord::Optional(p)
|
||||||
|
| PRecord::Space(_, p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum PList<'a> {
|
pub enum PList<'a> {
|
||||||
End(Position),
|
End(Position),
|
||||||
|
@ -680,6 +1138,21 @@ pub enum PList<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> PList<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Case with child node that has get_region()
|
||||||
|
PList::Pattern(pattern, _) => pattern.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
PList::End(p)
|
||||||
|
| PList::Open(p)
|
||||||
|
| PList::Rest(p)
|
||||||
|
| PList::Space(_, p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum PInParens<'a> {
|
pub enum PInParens<'a> {
|
||||||
Empty(Position),
|
Empty(Position),
|
||||||
|
@ -690,6 +1163,21 @@ pub enum PInParens<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> PInParens<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Case with child node that has get_region()
|
||||||
|
PInParens::Pattern(pattern, _) => pattern.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
PInParens::Empty(p)
|
||||||
|
| PInParens::End(p)
|
||||||
|
| PInParens::Open(p)
|
||||||
|
| PInParens::Space(_, p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum EType<'a> {
|
pub enum EType<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
|
@ -715,31 +1203,32 @@ pub enum EType<'a> {
|
||||||
TIndentEnd(Position),
|
TIndentEnd(Position),
|
||||||
TAsIndentStart(Position),
|
TAsIndentStart(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> EType<'a> {
|
impl<'a> EType<'a> {
|
||||||
pub fn get_region(&self) -> Region {
|
pub fn get_region(&self) -> Region {
|
||||||
let pos = match self {
|
match self {
|
||||||
EType::Space(_, position)
|
// Cases with child nodes that have get_region()
|
||||||
| EType::UnderscoreSpacing(position)
|
EType::TRecord(expr, _) => expr.get_region(),
|
||||||
| EType::TRecord(_, position)
|
EType::TTagUnion(expr, _) => expr.get_region(),
|
||||||
| EType::TTagUnion(_, position)
|
EType::TInParens(expr, _) => expr.get_region(),
|
||||||
| EType::TInParens(_, position)
|
EType::TApply(eapply,_, )=> eapply.get_region(),
|
||||||
| EType::TApply(_, position)
|
EType::TInlineAlias(einline, _) => einline.get_region(),
|
||||||
| EType::TInlineAlias(_, position)
|
EType::TAbilityImpl(eability, _) => eability.get_region(),
|
||||||
| EType::TBadTypeVariable(position)
|
|
||||||
| EType::TWildcard(position)
|
// Cases with Position values
|
||||||
| EType::TInferred(position)
|
EType::Space(_, p)
|
||||||
| EType::TStart(position)
|
| EType::UnderscoreSpacing(p)
|
||||||
| EType::TEnd(position)
|
| EType::TBadTypeVariable(p)
|
||||||
| EType::TFunctionArgument(position)
|
| EType::TWildcard(p)
|
||||||
| EType::TWhereBar(position)
|
| EType::TInferred(p)
|
||||||
| EType::TImplementsClause(position)
|
| EType::TStart(p)
|
||||||
| EType::TAbilityImpl(_, position)
|
| EType::TEnd(p)
|
||||||
| EType::TIndentStart(position)
|
| EType::TFunctionArgument(p)
|
||||||
| EType::TIndentEnd(position)
|
| EType::TWhereBar(p)
|
||||||
| EType::TAsIndentStart(position) => position,
|
| EType::TImplementsClause(p)
|
||||||
};
|
| EType::TIndentStart(p)
|
||||||
Region::from_pos(*pos)
|
| EType::TIndentEnd(p)
|
||||||
|
| EType::TAsIndentStart(p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -761,6 +1250,27 @@ pub enum ETypeRecord<'a> {
|
||||||
IndentEnd(Position),
|
IndentEnd(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> ETypeRecord<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Case with child node that has get_region()
|
||||||
|
ETypeRecord::Type(type_expr, _) => type_expr.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
ETypeRecord::End(p)
|
||||||
|
| ETypeRecord::Open(p)
|
||||||
|
| ETypeRecord::Field(p)
|
||||||
|
| ETypeRecord::Colon(p)
|
||||||
|
| ETypeRecord::Optional(p)
|
||||||
|
| ETypeRecord::Space(_, p)
|
||||||
|
| ETypeRecord::IndentOpen(p)
|
||||||
|
| ETypeRecord::IndentColon(p)
|
||||||
|
| ETypeRecord::IndentOptional(p)
|
||||||
|
| ETypeRecord::IndentEnd(p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum ETypeTagUnion<'a> {
|
pub enum ETypeTagUnion<'a> {
|
||||||
End(Position),
|
End(Position),
|
||||||
|
@ -771,6 +1281,20 @@ pub enum ETypeTagUnion<'a> {
|
||||||
Space(BadInputError, Position),
|
Space(BadInputError, Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> ETypeTagUnion<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Case with child node that has get_region()
|
||||||
|
ETypeTagUnion::Type(type_expr, _) => type_expr.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
ETypeTagUnion::End(p)
|
||||||
|
| ETypeTagUnion::Open(p)
|
||||||
|
| ETypeTagUnion::Space(_, p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum ETypeInParens<'a> {
|
pub enum ETypeInParens<'a> {
|
||||||
/// e.g. (), which isn't a valid type
|
/// e.g. (), which isn't a valid type
|
||||||
|
@ -788,6 +1312,24 @@ pub enum ETypeInParens<'a> {
|
||||||
IndentEnd(Position),
|
IndentEnd(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl<'a> ETypeInParens<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Cases with child nodes that have get_region()
|
||||||
|
ETypeInParens::Type(type_expr, _) => type_expr.get_region(),
|
||||||
|
|
||||||
|
// Cases with Position values
|
||||||
|
ETypeInParens::Empty(p)
|
||||||
|
| ETypeInParens::End(p)
|
||||||
|
| ETypeInParens::Open(p)
|
||||||
|
| ETypeInParens::Space(_, p)
|
||||||
|
| ETypeInParens::IndentOpen(p)
|
||||||
|
| ETypeInParens::IndentEnd(p) => Region::from_pos(*p),
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum ETypeApply {
|
pub enum ETypeApply {
|
||||||
///
|
///
|
||||||
|
@ -800,6 +1342,20 @@ pub enum ETypeApply {
|
||||||
StartIsNumber(Position),
|
StartIsNumber(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ETypeApply {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
let pos = match self {
|
||||||
|
ETypeApply::StartNotUppercase(p)
|
||||||
|
| ETypeApply::End(p)
|
||||||
|
| ETypeApply::Space(_, p)
|
||||||
|
| ETypeApply::DoubleDot(p)
|
||||||
|
| ETypeApply::TrailingDot(p)
|
||||||
|
| ETypeApply::StartIsNumber(p) => p,
|
||||||
|
};
|
||||||
|
Region::from_pos(*pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum ETypeInlineAlias {
|
pub enum ETypeInlineAlias {
|
||||||
NotAnAlias(Position),
|
NotAnAlias(Position),
|
||||||
|
@ -807,6 +1363,17 @@ pub enum ETypeInlineAlias {
|
||||||
ArgumentNotLowercase(Position),
|
ArgumentNotLowercase(Position),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl ETypeInlineAlias {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
let pos = match self {
|
||||||
|
ETypeInlineAlias::NotAnAlias(p)
|
||||||
|
| ETypeInlineAlias::Qualified(p)
|
||||||
|
| ETypeInlineAlias::ArgumentNotLowercase(p) => p,
|
||||||
|
};
|
||||||
|
Region::from_pos(*pos)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||||
pub enum ETypeAbilityImpl<'a> {
|
pub enum ETypeAbilityImpl<'a> {
|
||||||
End(Position),
|
End(Position),
|
||||||
|
@ -828,6 +1395,31 @@ pub enum ETypeAbilityImpl<'a> {
|
||||||
IndentBar(Position),
|
IndentBar(Position),
|
||||||
IndentAmpersand(Position),
|
IndentAmpersand(Position),
|
||||||
}
|
}
|
||||||
|
impl<'a> ETypeAbilityImpl<'a> {
|
||||||
|
pub fn get_region(&self) -> Region {
|
||||||
|
match self {
|
||||||
|
// Case with child node that has get_region()
|
||||||
|
ETypeAbilityImpl::Type(type_expr, _) => type_expr.get_region(),
|
||||||
|
ETypeAbilityImpl::Expr(expr, _) => expr.get_region(),
|
||||||
|
// Cases with Position values
|
||||||
|
ETypeAbilityImpl::End(p)
|
||||||
|
| ETypeAbilityImpl::Open(p)
|
||||||
|
| ETypeAbilityImpl::Field(p)
|
||||||
|
| ETypeAbilityImpl::UnderscoreField(p)
|
||||||
|
| ETypeAbilityImpl::Colon(p)
|
||||||
|
| ETypeAbilityImpl::Arrow(p)
|
||||||
|
| ETypeAbilityImpl::Optional(p)
|
||||||
|
|
||||||
|
| ETypeAbilityImpl::Space(_, p)
|
||||||
|
| ETypeAbilityImpl::Prefix(p)
|
||||||
|
| ETypeAbilityImpl::QuestionMark(p)
|
||||||
|
| ETypeAbilityImpl::Ampersand(p)
|
||||||
|
|
||||||
|
| ETypeAbilityImpl::IndentBar(p)
|
||||||
|
| ETypeAbilityImpl::IndentAmpersand(p) => Region::from_pos(*p),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
impl<'a> From<ERecord<'a>> for ETypeAbilityImpl<'a> {
|
impl<'a> From<ERecord<'a>> for ETypeAbilityImpl<'a> {
|
||||||
fn from(e: ERecord<'a>) -> Self {
|
fn from(e: ERecord<'a>) -> Self {
|
||||||
|
|
|
@ -75,6 +75,7 @@ impl ToRocPosition for tower_lsp::lsp_types::Position {
|
||||||
pub(crate) mod diag {
|
pub(crate) mod diag {
|
||||||
use std::{fmt::Debug, path::Path};
|
use std::{fmt::Debug, path::Path};
|
||||||
|
|
||||||
|
use log::debug;
|
||||||
use roc_load::LoadingProblem;
|
use roc_load::LoadingProblem;
|
||||||
use roc_region::all::{LineInfo, Region};
|
use roc_region::all::{LineInfo, Region};
|
||||||
use roc_solve_problem::TypeError;
|
use roc_solve_problem::TypeError;
|
||||||
|
@ -117,6 +118,8 @@ pub(crate) mod diag {
|
||||||
))
|
))
|
||||||
.to_range(line_info);
|
.to_range(line_info);
|
||||||
|
|
||||||
|
debug!("range is {:?}", range);
|
||||||
|
|
||||||
let msg = match self {
|
let msg = match self {
|
||||||
LoadingProblem::FileProblem { filename, error } => {
|
LoadingProblem::FileProblem { filename, error } => {
|
||||||
format!(
|
format!(
|
||||||
|
@ -153,10 +156,8 @@ pub(crate) mod diag {
|
||||||
LoadingProblem::TriedToImportAppModule => {
|
LoadingProblem::TriedToImportAppModule => {
|
||||||
"Attempted to import app module".to_string()
|
"Attempted to import app module".to_string()
|
||||||
}
|
}
|
||||||
LoadingProblem::FormattedReport(report, region) => {
|
LoadingProblem::FormattedReport(report, region) =>
|
||||||
range = region.unwrap_or(Region::zero()).to_range(line_info);
|
report.clone(),
|
||||||
report.clone()
|
|
||||||
}
|
|
||||||
LoadingProblem::ImportCycle(_, _) => {
|
LoadingProblem::ImportCycle(_, _) => {
|
||||||
"Circular dependency between modules".to_string()
|
"Circular dependency between modules".to_string()
|
||||||
}
|
}
|
||||||
|
@ -204,6 +205,7 @@ pub(crate) mod diag {
|
||||||
))
|
))
|
||||||
.to_range(fmt.line_info);
|
.to_range(fmt.line_info);
|
||||||
|
|
||||||
|
debug!("range is {:?}", range);
|
||||||
let report = roc_reporting::report::can_problem(
|
let report = roc_reporting::report::can_problem(
|
||||||
fmt.alloc,
|
fmt.alloc,
|
||||||
fmt.line_info,
|
fmt.line_info,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue