Module Params' proposal import syntax

I previously implemented the syntax in "Proposal: Module and Package Changes" [1]:

```
import [map, map2] from JsonDecode as JD
```

However, we decided [2] to use the one that appears in "Proposal: Module Params" [3]:

```
import JsonDecode as JD exposing [map, map2]
```

The new implementation also now supports comments and newlines between all the tokens.

[1] https://docs.google.com/document/d/1E_77fO-44BtoBtXoVeWyGh1xN2KRTWTu8q6i25RNNx0/edit
[2] 405410612
[3] https://docs.google.com/document/d/110MwQi7Dpo1Y69ECFXyyvDWzF4OYv1BLojIm08qDTvg/edit
This commit is contained in:
Agus Zubiaga 2023-12-04 09:13:09 -03:00
parent 5cd084b73c
commit c56091ee3e
No known key found for this signature in database
20 changed files with 767 additions and 204 deletions

View file

@ -456,11 +456,14 @@ pub enum ValueDef<'a> {
preceding_comment: Region,
},
/// e.g. `import [Req] as Http from InternalHttp`.
/// e.g. `import InternalHttp as Http exposing [Req]`.
ModuleImport {
name: Loc<crate::header::ModuleName<'a>>,
alias: Option<Loc<crate::header::ModuleName<'a>>>,
exposed: Collection<'a, Loc<Spaced<'a, crate::header::ExposedName<'a>>>>,
name: Loc<Spaced<'a, crate::header::ModuleName<'a>>>,
alias: Option<Loc<Spaced<'a, crate::header::ModuleName<'a>>>>,
exposed: Option<(
&'a [CommentOrNewline<'a>],
Collection<'a, Loc<Spaced<'a, crate::header::ExposedName<'a>>>>,
)>,
},
}
@ -1803,7 +1806,10 @@ impl<'a> Malformed for ValueDef<'a> {
name,
alias,
exposed: _,
} => name.value.contains_dot() || alias.map_or(false, |x| x.value.contains_dot()),
} => {
name.value.item().contains_dot()
|| alias.map_or(false, |x| x.value.item().contains_dot())
}
}
}
}