diff options
| author | 2019-01-24 20:37:30 +0200 | |
|---|---|---|
| committer | 2019-01-24 19:37:30 +0100 | |
| commit | 2e5680a9fea5a18438af0bca0bba88e0a48cef4d (patch) | |
| tree | 5f5a681e79f551105af8c627cd71d948bb3921f8 /src | |
| parent | Revert "update Gradle to 4.9" (diff) | |
| download | enigma-2e5680a9fea5a18438af0bca0bba88e0a48cef4d.tar.gz enigma-2e5680a9fea5a18438af0bca0bba88e0a48cef4d.tar.xz enigma-2e5680a9fea5a18438af0bca0bba88e0a48cef4d.zip | |
Standardize mapping line endings to LF (#100)
Diffstat (limited to 'src')
3 files changed, 21 insertions, 3 deletions
diff --git a/src/main/java/cuchaz/enigma/translation/mapping/serde/EnigmaMappingsWriter.java b/src/main/java/cuchaz/enigma/translation/mapping/serde/EnigmaMappingsWriter.java index 3eef7390..5acb1da2 100644 --- a/src/main/java/cuchaz/enigma/translation/mapping/serde/EnigmaMappingsWriter.java +++ b/src/main/java/cuchaz/enigma/translation/mapping/serde/EnigmaMappingsWriter.java | |||
| @@ -21,6 +21,7 @@ import cuchaz.enigma.translation.mapping.VoidEntryResolver; | |||
| 21 | import cuchaz.enigma.translation.mapping.tree.EntryTree; | 21 | import cuchaz.enigma.translation.mapping.tree.EntryTree; |
| 22 | import cuchaz.enigma.translation.mapping.tree.EntryTreeNode; | 22 | import cuchaz.enigma.translation.mapping.tree.EntryTreeNode; |
| 23 | import cuchaz.enigma.translation.representation.entry.*; | 23 | import cuchaz.enigma.translation.representation.entry.*; |
| 24 | import cuchaz.enigma.utils.LFPrintWriter; | ||
| 24 | 25 | ||
| 25 | import java.io.IOException; | 26 | import java.io.IOException; |
| 26 | import java.io.PrintWriter; | 27 | import java.io.PrintWriter; |
| @@ -45,7 +46,7 @@ public enum EnigmaMappingsWriter implements MappingsWriter { | |||
| 45 | progress.init(classes.size(), "Writing classes"); | 46 | progress.init(classes.size(), "Writing classes"); |
| 46 | 47 | ||
| 47 | int steps = 0; | 48 | int steps = 0; |
| 48 | try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(path))) { | 49 | try (PrintWriter writer = new LFPrintWriter(Files.newBufferedWriter(path))) { |
| 49 | for (ClassEntry classEntry : classes) { | 50 | for (ClassEntry classEntry : classes) { |
| 50 | progress.step(steps++, classEntry.getFullName()); | 51 | progress.step(steps++, classEntry.getFullName()); |
| 51 | writeRoot(writer, mappings, classEntry); | 52 | writeRoot(writer, mappings, classEntry); |
| @@ -78,7 +79,7 @@ public enum EnigmaMappingsWriter implements MappingsWriter { | |||
| 78 | Files.deleteIfExists(classPath); | 79 | Files.deleteIfExists(classPath); |
| 79 | Files.createDirectories(classPath.getParent()); | 80 | Files.createDirectories(classPath.getParent()); |
| 80 | 81 | ||
| 81 | try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(classPath))) { | 82 | try (PrintWriter writer = new LFPrintWriter(Files.newBufferedWriter(classPath))) { |
| 82 | writeRoot(writer, mappings, classEntry); | 83 | writeRoot(writer, mappings, classEntry); |
| 83 | } | 84 | } |
| 84 | } catch (Throwable t) { | 85 | } catch (Throwable t) { |
diff --git a/src/main/java/cuchaz/enigma/translation/mapping/serde/SrgMappingsWriter.java b/src/main/java/cuchaz/enigma/translation/mapping/serde/SrgMappingsWriter.java index 15ba4d75..5ff91413 100644 --- a/src/main/java/cuchaz/enigma/translation/mapping/serde/SrgMappingsWriter.java +++ b/src/main/java/cuchaz/enigma/translation/mapping/serde/SrgMappingsWriter.java | |||
| @@ -13,6 +13,7 @@ import cuchaz.enigma.translation.representation.entry.ClassEntry; | |||
| 13 | import cuchaz.enigma.translation.representation.entry.Entry; | 13 | import cuchaz.enigma.translation.representation.entry.Entry; |
| 14 | import cuchaz.enigma.translation.representation.entry.FieldEntry; | 14 | import cuchaz.enigma.translation.representation.entry.FieldEntry; |
| 15 | import cuchaz.enigma.translation.representation.entry.MethodEntry; | 15 | import cuchaz.enigma.translation.representation.entry.MethodEntry; |
| 16 | import cuchaz.enigma.utils.LFPrintWriter; | ||
| 16 | 17 | ||
| 17 | import java.io.IOException; | 18 | import java.io.IOException; |
| 18 | import java.io.PrintWriter; | 19 | import java.io.PrintWriter; |
| @@ -52,7 +53,7 @@ public enum SrgMappingsWriter implements MappingsWriter { | |||
| 52 | } | 53 | } |
| 53 | 54 | ||
| 54 | progress.init(3, "Writing mappings"); | 55 | progress.init(3, "Writing mappings"); |
| 55 | try (PrintWriter writer = new PrintWriter(Files.newBufferedWriter(path))) { | 56 | try (PrintWriter writer = new LFPrintWriter(Files.newBufferedWriter(path))) { |
| 56 | progress.step(0, "Classes"); | 57 | progress.step(0, "Classes"); |
| 57 | classLines.forEach(writer::println); | 58 | classLines.forEach(writer::println); |
| 58 | progress.step(1, "Fields"); | 59 | progress.step(1, "Fields"); |
diff --git a/src/main/java/cuchaz/enigma/utils/LFPrintWriter.java b/src/main/java/cuchaz/enigma/utils/LFPrintWriter.java new file mode 100644 index 00000000..c12e9134 --- /dev/null +++ b/src/main/java/cuchaz/enigma/utils/LFPrintWriter.java | |||
| @@ -0,0 +1,16 @@ | |||
| 1 | package cuchaz.enigma.utils; | ||
| 2 | |||
| 3 | import java.io.PrintWriter; | ||
| 4 | import java.io.Writer; | ||
| 5 | |||
| 6 | public class LFPrintWriter extends PrintWriter { | ||
| 7 | public LFPrintWriter(Writer out) { | ||
| 8 | super(out); | ||
| 9 | } | ||
| 10 | |||
| 11 | @Override | ||
| 12 | public void println() { | ||
| 13 | // https://stackoverflow.com/a/14749004 | ||
| 14 | write('\n'); | ||
| 15 | } | ||
| 16 | } | ||