mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 05:49:08 +00:00
Parse and format import package shorthand
The original proposal [1] suggested dropping the package shorthand,
but we later decided to keep it [2] to improve UX.
[1] https://docs.google.com/document/d/1E_77fO-44BtoBtXoVeWyGh1xN2KRTWTu8q6i25RNNx0/edit?usp=sharing
[2] 385104011
This commit is contained in:
parent
c56091ee3e
commit
65ce811587
15 changed files with 349 additions and 115 deletions
|
@ -4,9 +4,9 @@ use roc_module::called_via::{BinOp, UnaryOp};
|
|||
use roc_parse::{
|
||||
ast::{
|
||||
AbilityImpls, AbilityMember, AssignedField, Collection, CommentOrNewline, Defs, Expr,
|
||||
Header, Implements, ImplementsAbilities, ImplementsAbility, ImplementsClause, Module,
|
||||
Pattern, PatternAs, RecordBuilderField, Spaced, Spaces, StrLiteral, StrSegment, Tag,
|
||||
TypeAnnotation, TypeDef, TypeHeader, ValueDef, WhenBranch,
|
||||
Header, Implements, ImplementsAbilities, ImplementsAbility, ImplementsClause, ImportAlias,
|
||||
ImportedModuleName, Module, Pattern, PatternAs, RecordBuilderField, Spaced, Spaces,
|
||||
StrLiteral, StrSegment, Tag, TypeAnnotation, TypeDef, TypeHeader, ValueDef, WhenBranch,
|
||||
},
|
||||
header::{
|
||||
AppHeader, ExposedName, HostedHeader, ImportsEntry, InterfaceHeader, KeywordItem,
|
||||
|
@ -571,7 +571,7 @@ impl<'a> RemoveSpaces<'a> for ValueDef<'a> {
|
|||
exposed,
|
||||
} => ModuleImport {
|
||||
name: name.remove_spaces(arena),
|
||||
alias: alias.map(|alias_name| alias_name.remove_spaces(arena)),
|
||||
alias: alias.remove_spaces(arena),
|
||||
exposed: if let Some((spaces, exposed)) = exposed {
|
||||
Some((spaces, exposed.remove_spaces(arena)))
|
||||
} else {
|
||||
|
@ -582,6 +582,21 @@ impl<'a> RemoveSpaces<'a> for ValueDef<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> RemoveSpaces<'a> for ImportedModuleName<'a> {
|
||||
fn remove_spaces(&self, arena: &'a Bump) -> Self {
|
||||
ImportedModuleName {
|
||||
package: self.package.remove_spaces(arena),
|
||||
name: self.name.remove_spaces(arena),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> RemoveSpaces<'a> for ImportAlias<'a> {
|
||||
fn remove_spaces(&self, _arena: &'a Bump) -> Self {
|
||||
*self
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> RemoveSpaces<'a> for Implements<'a> {
|
||||
fn remove_spaces(&self, _arena: &'a Bump) -> Self {
|
||||
Implements::Implements
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue