mirror of
https://github.com/roc-lang/roc.git
synced 2025-07-29 17:33:45 +00:00
Rename PackageName to PackagePath
This commit is contained in:
parent
16ce22d455
commit
8a9e152a5b
14 changed files with 45 additions and 45 deletions
|
@ -2,7 +2,7 @@ use crate::ast::{Collection, CommentOrNewline, Spaced, Spaces, StrLiteral, TypeA
|
|||
use crate::blankspace::space0_e;
|
||||
use crate::ident::{lowercase_ident, UppercaseIdent};
|
||||
use crate::parser::{optional, then};
|
||||
use crate::parser::{specialize, word1, EPackageEntry, EPackageName, Parser};
|
||||
use crate::parser::{specialize, word1, EPackageEntry, EPackagePath, Parser};
|
||||
use crate::string_literal;
|
||||
use bumpalo::collections::Vec;
|
||||
use roc_module::symbol::{ModuleId, Symbol};
|
||||
|
@ -59,9 +59,9 @@ pub enum VersionComparison {
|
|||
}
|
||||
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
pub struct PackageName<'a>(&'a str);
|
||||
pub struct PackagePath<'a>(&'a str);
|
||||
|
||||
impl<'a> PackageName<'a> {
|
||||
impl<'a> PackagePath<'a> {
|
||||
pub fn to_str(self) -> &'a str {
|
||||
self.0
|
||||
}
|
||||
|
@ -71,13 +71,13 @@ impl<'a> PackageName<'a> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> From<PackageName<'a>> for &'a str {
|
||||
fn from(name: PackageName<'a>) -> &'a str {
|
||||
impl<'a> From<PackagePath<'a>> for &'a str {
|
||||
fn from(name: PackagePath<'a>) -> &'a str {
|
||||
name.0
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> From<&'a str> for PackageName<'a> {
|
||||
impl<'a> From<&'a str> for PackagePath<'a> {
|
||||
fn from(string: &'a str) -> Self {
|
||||
Self(string)
|
||||
}
|
||||
|
@ -181,7 +181,7 @@ pub struct HostedHeader<'a> {
|
|||
#[derive(Copy, Clone, Debug, PartialEq, Eq)]
|
||||
pub enum To<'a> {
|
||||
ExistingPackage(&'a str),
|
||||
NewPackage(PackageName<'a>),
|
||||
NewPackage(PackagePath<'a>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
|
@ -209,13 +209,13 @@ pub struct ProvidesTo<'a> {
|
|||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct PackageHeader<'a> {
|
||||
pub before_name: &'a [CommentOrNewline<'a>],
|
||||
pub name: Loc<PackageName<'a>>,
|
||||
pub name: Loc<PackagePath<'a>>,
|
||||
|
||||
pub exposes_keyword: Spaces<'a, ExposesKeyword>,
|
||||
pub exposes: Vec<'a, Loc<Spaced<'a, ExposedName<'a>>>>,
|
||||
|
||||
pub packages_keyword: Spaces<'a, PackagesKeyword>,
|
||||
pub packages: Vec<'a, (Loc<&'a str>, Loc<PackageName<'a>>)>,
|
||||
pub packages: Vec<'a, (Loc<&'a str>, Loc<PackagePath<'a>>)>,
|
||||
|
||||
pub imports_keyword: Spaces<'a, ImportsKeyword>,
|
||||
pub imports: Vec<'a, Loc<ImportsEntry<'a>>>,
|
||||
|
@ -230,7 +230,7 @@ pub struct PlatformRequires<'a> {
|
|||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct PlatformHeader<'a> {
|
||||
pub before_name: &'a [CommentOrNewline<'a>],
|
||||
pub name: Loc<PackageName<'a>>,
|
||||
pub name: Loc<PackagePath<'a>>,
|
||||
|
||||
pub requires: KeywordItem<'a, RequiresKeyword, PlatformRequires<'a>>,
|
||||
pub exposes: KeywordItem<'a, ExposesKeyword, Collection<'a, Loc<Spaced<'a, ModuleName<'a>>>>>,
|
||||
|
@ -271,7 +271,7 @@ pub struct TypedIdent<'a> {
|
|||
pub struct PackageEntry<'a> {
|
||||
pub shorthand: &'a str,
|
||||
pub spaces_after_shorthand: &'a [CommentOrNewline<'a>],
|
||||
pub package_name: Loc<PackageName<'a>>,
|
||||
pub package_path: Loc<PackagePath<'a>>,
|
||||
}
|
||||
|
||||
pub fn package_entry<'a>() -> impl Parser<'a, Spaced<'a, PackageEntry<'a>>, EPackageEntry<'a>> {
|
||||
|
@ -288,19 +288,19 @@ pub fn package_entry<'a>() -> impl Parser<'a, Spaced<'a, PackageEntry<'a>>, EPac
|
|||
),
|
||||
space0_e(EPackageEntry::IndentPackage)
|
||||
)),
|
||||
loc!(specialize(EPackageEntry::BadPackage, package_name()))
|
||||
loc!(specialize(EPackageEntry::BadPackage, package_path()))
|
||||
),
|
||||
move |(opt_shorthand, package_or_path)| {
|
||||
let entry = match opt_shorthand {
|
||||
Some((shorthand, spaces_after_shorthand)) => PackageEntry {
|
||||
shorthand,
|
||||
spaces_after_shorthand,
|
||||
package_name: package_or_path,
|
||||
package_path: package_or_path,
|
||||
},
|
||||
None => PackageEntry {
|
||||
shorthand: "",
|
||||
spaces_after_shorthand: &[],
|
||||
package_name: package_or_path,
|
||||
package_path: package_or_path,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -309,13 +309,13 @@ pub fn package_entry<'a>() -> impl Parser<'a, Spaced<'a, PackageEntry<'a>>, EPac
|
|||
)
|
||||
}
|
||||
|
||||
pub fn package_name<'a>() -> impl Parser<'a, PackageName<'a>, EPackageName<'a>> {
|
||||
pub fn package_path<'a>() -> impl Parser<'a, PackagePath<'a>, EPackagePath<'a>> {
|
||||
then(
|
||||
loc!(specialize(EPackageName::BadPath, string_literal::parse())),
|
||||
loc!(specialize(EPackagePath::BadPath, string_literal::parse())),
|
||||
move |_arena, state, progress, text| match text.value {
|
||||
StrLiteral::PlainLine(text) => Ok((progress, PackageName(text), state)),
|
||||
StrLiteral::Line(_) => Err((progress, EPackageName::Escapes(text.region.start()))),
|
||||
StrLiteral::Block(_) => Err((progress, EPackageName::Multiline(text.region.start()))),
|
||||
StrLiteral::PlainLine(text) => Ok((progress, PackagePath(text), state)),
|
||||
StrLiteral::Line(_) => Err((progress, EPackagePath::Escapes(text.region.start()))),
|
||||
StrLiteral::Block(_) => Err((progress, EPackagePath::Multiline(text.region.start()))),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue