Skip to content

Commit

Permalink
Final cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
czocher committed Jun 20, 2023
1 parent b2e7217 commit 97a5ade
Show file tree
Hide file tree
Showing 11 changed files with 552 additions and 452 deletions.
4 changes: 2 additions & 2 deletions core/src/language/kotlin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use super::Language;
use crate::language::SupportedLanguage;
use crate::rust_types::{RustTypeFormatError, SpecialRustType};
use crate::{
helpers::remove_dash_from_identifier,
parser::helpers::StringExt,
rename::RenameExt,
rust_types::{RustEnum, RustEnumVariant, RustField, RustStruct, RustTypeAlias},
};
Expand Down Expand Up @@ -324,7 +324,7 @@ impl Kotlin {
write!(
w,
"\tval {}: {}{}",
remove_dash_from_identifier(&f.id.renamed),
&f.id.renamed.remove_dashes(),
ty,
(f.has_default && !f.ty.is_optional())
.then(|| "? = null")
Expand Down
4 changes: 2 additions & 2 deletions core/src/language/scala.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::language::SupportedLanguage;
use crate::parser::ParsedData;
use crate::rust_types::{RustType, RustTypeFormatError, SpecialRustType};
use crate::{
helpers::remove_dash_from_identifier,
parser::helpers::StringExt,
rust_types::{RustEnum, RustEnumVariant, RustField, RustStruct, RustTypeAlias},
};
use itertools::Itertools;
Expand Down Expand Up @@ -354,7 +354,7 @@ impl Scala {
write!(
w,
"\t{}: {}{}",
remove_dash_from_identifier(&f.id.renamed),
&f.id.renamed.remove_dashes(),
ty,
(f.has_default && !f.ty.is_optional())
.then(|| " = _")
Expand Down
16 changes: 7 additions & 9 deletions core/src/language/swift.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::rust_types::{RustTypeFormatError, SpecialRustType};
use crate::{
helpers::remove_dash_from_identifier,
language::{Language, SupportedLanguage},
parser::helpers::StringExt,
rename::RenameExt,
rust_types::{RustEnum, RustEnumVariant, RustStruct, RustTypeAlias},
};
Expand Down Expand Up @@ -317,17 +317,15 @@ impl Language for Swift {
if f.id.renamed.chars().any(|c| c == '-') {
coding_keys.push(format!(
r##"{} = "{}""##,
remove_dash_from_identifier(&swift_keyword_aware_rename(&f.id.renamed)),
swift_keyword_aware_rename(&f.id.renamed).remove_dashes(),
&f.id.renamed
));

// We only need to write out coding keys if we encounter a
// situation like this
should_write_coding_keys = true;
} else {
coding_keys.push(remove_dash_from_identifier(&swift_keyword_aware_rename(
&f.id.renamed,
)));
coding_keys.push(swift_keyword_aware_rename(&f.id.renamed).remove_dashes());
}

let case_type: String = match f.type_override(SupportedLanguage::Swift) {
Expand All @@ -340,7 +338,7 @@ impl Language for Swift {
writeln!(
w,
"\tpublic let {}: {}{}",
remove_dash_from_identifier(&swift_keyword_aware_rename(&f.id.renamed)),
&(swift_keyword_aware_rename(&f.id.renamed).remove_dashes()),
case_type,
(f.has_default && !f.ty.is_optional())
.then(|| "?")
Expand Down Expand Up @@ -374,7 +372,7 @@ impl Language for Swift {

init_params.push(format!(
"{}: {}{}",
remove_dash_from_identifier(&f.id.renamed),
&f.id.renamed.remove_dashes(),
swift_ty,
(f.has_default && !f.ty.is_optional())
.then(|| "?")
Expand All @@ -387,8 +385,8 @@ impl Language for Swift {
write!(
w,
"\n\t\tself.{} = {}",
remove_dash_from_identifier(&f.id.renamed),
remove_dash_from_identifier(&swift_keyword_aware_rename(&f.id.renamed))
f.id.renamed.remove_dashes(),
&swift_keyword_aware_rename(&f.id.renamed).remove_dashes()
)?;
}
if !rs.fields.is_empty() {
Expand Down
1 change: 0 additions & 1 deletion core/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ use thiserror::Error;

mod rename;

mod helpers;
/// Implementations for each language converter
pub mod language;
/// Parsing Rust code into a format the `language` modules can understand
Expand Down
Loading

0 comments on commit 97a5ade

Please sign in to comment.