mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +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()))),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
use crate::ast::{Collection, Defs, Header, Module, Spaced, Spaces};
|
||||
use crate::blankspace::{space0_around_ee, space0_before_e, space0_e};
|
||||
use crate::header::{
|
||||
package_entry, package_name, AppHeader, ExposedName, ExposesKeyword, GeneratesKeyword,
|
||||
package_entry, package_path, AppHeader, ExposedName, ExposesKeyword, GeneratesKeyword,
|
||||
HostedHeader, ImportsEntry, ImportsKeyword, InterfaceHeader, Keyword, KeywordItem, ModuleName,
|
||||
PackageEntry, PackagesKeyword, PlatformHeader, PlatformRequires, ProvidesKeyword, ProvidesTo,
|
||||
RequiresKeyword, To, ToKeyword, TypedIdent, WithKeyword,
|
||||
|
@ -187,7 +187,7 @@ fn app_header<'a>() -> impl Parser<'a, AppHeader<'a>, EHeader<'a>> {
|
|||
fn platform_header<'a>() -> impl Parser<'a, PlatformHeader<'a>, EHeader<'a>> {
|
||||
record!(PlatformHeader {
|
||||
before_name: space0_e(EHeader::IndentStart),
|
||||
name: loc!(specialize(EHeader::PlatformName, package_name())),
|
||||
name: loc!(specialize(EHeader::PlatformName, package_path())),
|
||||
requires: specialize(EHeader::Requires, requires()),
|
||||
exposes: specialize(EHeader::Exposes, exposes_modules()),
|
||||
packages: specialize(EHeader::Packages, packages()),
|
||||
|
@ -203,7 +203,7 @@ fn provides_to_package<'a>() -> impl Parser<'a, To<'a>, EProvides<'a>> {
|
|||
|_, pos| EProvides::Identifier(pos),
|
||||
map!(lowercase_ident(), To::ExistingPackage)
|
||||
),
|
||||
specialize(EProvides::Package, map!(package_name(), To::NewPackage))
|
||||
specialize(EProvides::Package, map!(package_path(), To::NewPackage))
|
||||
]
|
||||
}
|
||||
|
||||
|
|
|
@ -127,7 +127,7 @@ pub enum EHeader<'a> {
|
|||
Start(Position),
|
||||
ModuleName(Position),
|
||||
AppName(EString<'a>, Position),
|
||||
PlatformName(EPackageName<'a>, Position),
|
||||
PlatformName(EPackagePath<'a>, Position),
|
||||
IndentStart(Position),
|
||||
|
||||
InconsistentModuleName(Region),
|
||||
|
@ -146,7 +146,7 @@ pub enum EProvides<'a> {
|
|||
ListStart(Position),
|
||||
ListEnd(Position),
|
||||
Identifier(Position),
|
||||
Package(EPackageName<'a>, Position),
|
||||
Package(EPackagePath<'a>, Position),
|
||||
Space(BadInputError, Position),
|
||||
}
|
||||
|
||||
|
@ -202,7 +202,7 @@ pub enum EPackages<'a> {
|
|||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum EPackageName<'a> {
|
||||
pub enum EPackagePath<'a> {
|
||||
BadPath(EString<'a>, Position),
|
||||
Escapes(Position),
|
||||
Multiline(Position),
|
||||
|
@ -210,7 +210,7 @@ pub enum EPackageName<'a> {
|
|||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub enum EPackageEntry<'a> {
|
||||
BadPackage(EPackageName<'a>, Position),
|
||||
BadPackage(EPackagePath<'a>, Position),
|
||||
Shorthand(Position),
|
||||
Colon(Position),
|
||||
IndentPackage(Position),
|
||||
|
|
|
@ -3,7 +3,7 @@ Module {
|
|||
header: Platform(
|
||||
PlatformHeader {
|
||||
before_name: [],
|
||||
name: @9-25 PackageName(
|
||||
name: @9-25 PackagePath(
|
||||
"rtfeldman/blah",
|
||||
),
|
||||
requires: KeywordItem {
|
||||
|
|
|
@ -19,7 +19,7 @@ Module {
|
|||
@31-47 PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [],
|
||||
package_name: @35-47 PackageName(
|
||||
package_path: @35-47 PackagePath(
|
||||
"./platform",
|
||||
),
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@ Module {
|
|||
@31-47 PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [],
|
||||
package_name: @35-47 PackageName(
|
||||
package_path: @35-47 PackagePath(
|
||||
"./platform",
|
||||
),
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@ Module {
|
|||
header: Platform(
|
||||
PlatformHeader {
|
||||
before_name: [],
|
||||
name: @9-14 PackageName(
|
||||
name: @9-14 PackagePath(
|
||||
"cli",
|
||||
),
|
||||
requires: KeywordItem {
|
||||
|
|
|
@ -22,7 +22,7 @@ Module {
|
|||
after: [],
|
||||
},
|
||||
to: @30-38 NewPackage(
|
||||
PackageName(
|
||||
PackagePath(
|
||||
"./blah",
|
||||
),
|
||||
),
|
||||
|
|
|
@ -3,7 +3,7 @@ Module {
|
|||
header: Platform(
|
||||
PlatformHeader {
|
||||
before_name: [],
|
||||
name: @9-21 PackageName(
|
||||
name: @9-21 PackagePath(
|
||||
"foo/barbaz",
|
||||
),
|
||||
requires: KeywordItem {
|
||||
|
@ -52,7 +52,7 @@ Module {
|
|||
@87-99 PackageEntry {
|
||||
shorthand: "foo",
|
||||
spaces_after_shorthand: [],
|
||||
package_name: @92-99 PackageName(
|
||||
package_path: @92-99 PackagePath(
|
||||
"./foo",
|
||||
),
|
||||
},
|
||||
|
|
|
@ -19,7 +19,7 @@ Module {
|
|||
@26-42 PackageEntry {
|
||||
shorthand: "pf",
|
||||
spaces_after_shorthand: [],
|
||||
package_name: @30-42 PackageName(
|
||||
package_path: @30-42 PackagePath(
|
||||
"./platform",
|
||||
),
|
||||
},
|
||||
|
|
|
@ -3,7 +3,7 @@ Module {
|
|||
header: Platform(
|
||||
PlatformHeader {
|
||||
before_name: [],
|
||||
name: @9-21 PackageName(
|
||||
name: @9-21 PackagePath(
|
||||
"test/types",
|
||||
),
|
||||
requires: KeywordItem {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue