Skip to content

Commit

Permalink
Renamed litho-export to litho-codegen.
Browse files Browse the repository at this point in the history
  • Loading branch information
cutsoy committed Jan 15, 2023
1 parent 568ea5a commit 8f43c89
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
[workspace]
members = [
"litho-cli",
"litho-codegen",
"litho-compiler",
"litho-diagnostics",
"litho-export",
"litho-import",
"litho-language",
"litho-lsp",
"litho-lsp-wasm",
"litho-tests",
"litho-types",
"litho-validation",
"litho-validation",
]
2 changes: 1 addition & 1 deletion litho-cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ edition = "2021"
name = "litho"

[dependencies]
litho-codegen = { path = "../litho-codegen" }
litho-compiler = { path = "../litho-compiler" }
litho-export = { path = "../litho-export" }
litho-language = { path = "../litho-language" }

ariadne = "0.1.5"
Expand Down
2 changes: 1 addition & 1 deletion litho-cli/src/commands/generate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ pub fn generate() -> ExitCode {
match success {
true => {
for output in outputs {
litho_export::export(
litho_codegen::codegen(
workspace.compiler().database(),
workspace
.files()
Expand Down
2 changes: 1 addition & 1 deletion litho-export/Cargo.toml → litho-codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "litho-export"
name = "litho-codegen"
version = "0.0.0"
edition = "2021"

Expand Down
16 changes: 8 additions & 8 deletions litho-export/src/lib.rs → litho-codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,33 +8,33 @@ use litho_types::Database;

mod typescript;

use typescript::{export_typescript, TypescriptError};
use typescript::{codegen_typescript, TypescriptError};

#[derive(Debug)]
pub enum ExportError {
pub enum CodegenError {
UnrecognizedExtension,
Typescript(TypescriptError),
}

impl From<TypescriptError> for ExportError {
impl From<TypescriptError> for CodegenError {
fn from(value: TypescriptError) -> Self {
ExportError::Typescript(value)
CodegenError::Typescript(value)
}
}

pub fn export<T, P>(
pub fn codegen<T, P>(
database: &Database<T>,
source_map: HashMap<SourceId, (&str, &str)>,
path: P,
) -> Result<(), ExportError>
) -> Result<(), CodegenError>
where
T: Eq + Hash + Borrow<str>,
P: AsRef<Path>,
{
let path = path.as_ref();

match path.extension().and_then(|ext| ext.to_str()) {
Some("js" | "ts") => export_typescript(database, source_map, path).map_err(Into::into),
_ => Err(ExportError::UnrecognizedExtension),
Some("js" | "ts") => codegen_typescript(database, source_map, path).map_err(Into::into),
_ => Err(CodegenError::UnrecognizedExtension),
}
}
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl From<Error> for TypescriptError {
}
}

pub fn export_typescript<T>(
pub fn codegen_typescript<T>(
database: &Database<T>,
source_map: HashMap<SourceId, (&str, &str)>,
path: &Path,
Expand Down

0 comments on commit 8f43c89

Please sign in to comment.