Skip to content

Commit 4dc4b84

Browse files
committed
Remove indent. ustfmt can properly format the output now that there's no macro.
1 parent a3fd4f9 commit 4dc4b84

5 files changed

Lines changed: 18 additions & 27 deletions

File tree

‎java-spaghetti-gen/src/emit_rust/context.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,6 @@ impl<'a> Context<'a> {
123123

124124
pub fn write(&self, out: &mut impl io::Write) -> io::Result<()> {
125125
write_preamble(out)?;
126-
self.module.write(self, "", out)
126+
self.module.write(self, out)
127127
}
128128
}

‎java-spaghetti-gen/src/emit_rust/fields.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ impl<'a> Field<'a> {
3232
result
3333
}
3434

35-
pub fn emit(&self, context: &Context, indent: &str, mod_: &str, out: &mut impl io::Write) -> io::Result<()> {
35+
pub fn emit(&self, context: &Context, mod_: &str, out: &mut impl io::Write) -> io::Result<()> {
3636
let mut emit_reject_reasons = Vec::new();
3737

3838
if !self.java.is_public() {
@@ -151,12 +151,12 @@ impl<'a> Field<'a> {
151151

152152
let emit_reject_reasons = emit_reject_reasons; // Freeze
153153
let indent = if emit_reject_reasons.is_empty() {
154-
format!("{} ", indent)
154+
""
155155
} else {
156156
if !context.config.codegen.keep_rejected_emits {
157157
return Ok(());
158158
}
159-
format!("{} // ", indent)
159+
"// "
160160
};
161161

162162
let keywords = format!(

‎java-spaghetti-gen/src/emit_rust/methods.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl<'a> Method<'a> {
4242
};
4343
}
4444

45-
pub fn emit(&self, context: &Context, indent: &str, mod_: &str, out: &mut impl io::Write) -> io::Result<()> {
45+
pub fn emit(&self, context: &Context, mod_: &str, out: &mut impl io::Write) -> io::Result<()> {
4646
let mut emit_reject_reasons = Vec::new();
4747

4848
let java_class_method = format!("{}\x1f{}", self.class.path.as_str(), &self.java.name);
@@ -310,12 +310,12 @@ impl<'a> Method<'a> {
310310

311311
let emit_reject_reasons = emit_reject_reasons; // Freeze
312312
let indent = if emit_reject_reasons.is_empty() {
313-
format!("{} ", indent)
313+
""
314314
} else {
315315
if !context.config.codegen.keep_rejected_emits {
316316
return Ok(());
317317
}
318-
format!("{} // ", indent)
318+
"// "
319319
};
320320
let access = if self.java.is_public() { "pub " } else { "" };
321321
let attributes = (if self.java.deprecated { "#[deprecated] " } else { "" }).to_string();

‎java-spaghetti-gen/src/emit_rust/modules.rs‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,17 @@ pub(crate) struct Module {
1212
}
1313

1414
impl Module {
15-
pub(crate) fn write(&self, context: &Context, indent: &str, out: &mut impl Write) -> io::Result<()> {
16-
let next_indent = format!("{} ", indent);
17-
15+
pub(crate) fn write(&self, context: &Context, out: &mut impl Write) -> io::Result<()> {
1816
for (name, module) in self.modules.iter() {
1917
writeln!(out)?;
2018

21-
writeln!(out, "{}pub mod {} {{", indent, name)?;
22-
module.write(context, &next_indent[..], out)?;
23-
writeln!(out, "{}}}", indent)?;
19+
writeln!(out, "pub mod {} {{", name)?;
20+
module.write(context, out)?;
21+
writeln!(out, "}}")?;
2422
}
2523

2624
for (_, structure) in self.structs.iter() {
27-
structure.write(context, indent, out)?;
25+
structure.write(context, out)?;
2826
}
2927

3028
Ok(())

‎java-spaghetti-gen/src/emit_rust/structs.rs‎

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ impl Struct {
8686
Ok(Self { rust, java })
8787
}
8888

89-
pub(crate) fn write(&self, context: &Context, indent: &str, out: &mut impl io::Write) -> io::Result<()> {
89+
pub(crate) fn write(&self, context: &Context, out: &mut impl io::Write) -> io::Result<()> {
9090
writeln!(out)?;
9191

9292
// Ignored access_flags: SUPER, SYNTHETIC, ANNOTATION, ABSTRACT
@@ -107,16 +107,9 @@ impl Struct {
107107
let attributes = (if self.java.deprecated { "#[deprecated] " } else { "" }).to_string();
108108

109109
if let Some(url) = KnownDocsUrl::from_class(context, self.java.path.as_id()) {
110-
writeln!(out, "{} /// {} {} {}", indent, visibility, keyword, url)?;
110+
writeln!(out, "/// {} {} {}", visibility, keyword, url)?;
111111
} else {
112-
writeln!(
113-
out,
114-
"{} /// {} {} {}",
115-
indent,
116-
visibility,
117-
keyword,
118-
self.java.path.as_str()
119-
)?;
112+
writeln!(out, "/// {} {} {}", visibility, keyword, self.java.path.as_str())?;
120113
}
121114

122115
let rust_name = &self.rust.struct_name;
@@ -219,14 +212,14 @@ impl Struct {
219212
}
220213
}
221214

222-
method.emit(context, indent, &self.rust.mod_, out)?;
215+
method.emit(context, &self.rust.mod_, out)?;
223216
}
224217

225218
for field in &mut fields {
226-
field.emit(context, indent, &self.rust.mod_, out)?;
219+
field.emit(context, &self.rust.mod_, out)?;
227220
}
228221

229-
writeln!(out, "{}}}", indent)?;
222+
writeln!(out, "}}")?;
230223
Ok(())
231224
}
232225
}

0 commit comments

Comments
 (0)