From 4b09d06fdb80aa7b7d8b09b9c12760fa8ac05d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Lars=C3=A9n?= Date: Wed, 17 Mar 2021 15:31:48 +0100 Subject: [PATCH 1/4] Add Windows build --- .github/workflows/tests.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index f7f4811f..d7a477fc 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -18,7 +18,7 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - os: [ ubuntu-latest, macos-latest ] + os: [ ubuntu-latest, macos-latest, windows-latest ] steps: - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 From 142c7e208628eec1ab6bf3e6127e522d96ad01f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Lars=C3=A9n?= Date: Thu, 18 Mar 2021 15:48:09 +0100 Subject: [PATCH 2/4] Explicitly specify UTF8 charset in tests --- src/main/kotlin/se/kth/spork/spoon/Parser.kt | 3 ++- src/test/java/se/kth/spork/Util.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/se/kth/spork/spoon/Parser.kt b/src/main/kotlin/se/kth/spork/spoon/Parser.kt index 45379ff1..d3431fb6 100644 --- a/src/main/kotlin/se/kth/spork/spoon/Parser.kt +++ b/src/main/kotlin/se/kth/spork/spoon/Parser.kt @@ -13,6 +13,7 @@ import spoon.reflect.declaration.CtType import spoon.support.compiler.FileSystemFile import spoon.support.compiler.VirtualFile import java.io.IOException +import java.nio.charset.StandardCharsets import java.nio.file.Files import java.nio.file.Path @@ -115,7 +116,7 @@ object Parser { */ fun read(path: Path): String { return try { - java.lang.String.join("\n", Files.readAllLines(path)) + java.lang.String.join("\n", Files.readAllLines(path, StandardCharsets.UTF_8)) } catch (e: IOException) { e.printStackTrace() throw RuntimeException("Error reading from $path") diff --git a/src/test/java/se/kth/spork/Util.java b/src/test/java/se/kth/spork/Util.java index 8a3cd818..889ff181 100644 --- a/src/test/java/se/kth/spork/Util.java +++ b/src/test/java/se/kth/spork/Util.java @@ -4,6 +4,7 @@ import gumtree.spoon.builder.SpoonGumTreeBuilder; import java.io.File; import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; @@ -50,7 +51,7 @@ private static Stream getArgumentSourcesStream( } public static String read(Path path) throws IOException { - return String.join("\n", Files.readAllLines(path)); + return String.join("\n", Files.readAllLines(path, StandardCharsets.UTF_8)); } public static ITree toGumTree(String clazz) { From d0012455efa8f30bab8ceb2abf280956a4a2fac5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Lars=C3=A9n?= Date: Thu, 18 Mar 2021 16:00:40 +0100 Subject: [PATCH 3/4] Force UTF8 encoding and LF line endings --- .../java/se/kth/spork/spoon/printer/SporkPrettyPrinter.java | 3 +++ src/main/kotlin/se/kth/spork/spoon/Parser.kt | 1 + 2 files changed, 4 insertions(+) diff --git a/src/main/java/se/kth/spork/spoon/printer/SporkPrettyPrinter.java b/src/main/java/se/kth/spork/spoon/printer/SporkPrettyPrinter.java index 30409da2..58d5b819 100644 --- a/src/main/java/se/kth/spork/spoon/printer/SporkPrettyPrinter.java +++ b/src/main/java/se/kth/spork/spoon/printer/SporkPrettyPrinter.java @@ -47,6 +47,9 @@ public SporkPrettyPrinter(Environment env) { // instead of just String, it will print java.lang.String. Which isn't great. setIgnoreImplicit(false); + // TODO detect these values instead of setting unconditionally + printerHelper.setLineSeparator("\n"); + globalContentConflicts = DEFAULT_CONFLICT_MAP; } diff --git a/src/main/kotlin/se/kth/spork/spoon/Parser.kt b/src/main/kotlin/se/kth/spork/spoon/Parser.kt index d3431fb6..75c0cd1c 100644 --- a/src/main/kotlin/se/kth/spork/spoon/Parser.kt +++ b/src/main/kotlin/se/kth/spork/spoon/Parser.kt @@ -61,6 +61,7 @@ object Parser { env.useTabulations(useTabs) env.setPrettyPrinterCreator { SporkPrettyPrinter(env) } env.noClasspath = true + env.encoding = StandardCharsets.UTF_8 // TODO detect instead of setting unconditionally } private fun parse(configureLauncher: (Launcher) -> Unit): CtModule { From 4bc807ba4efc38c8d523c28ffe0b651896b18443 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Lars=C3=A9n?= Date: Mon, 19 Apr 2021 16:26:17 +0200 Subject: [PATCH 4/4] Disable autocrlf in Git --- .github/workflows/tests.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 91a32da6..5a207a50 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -24,6 +24,8 @@ jobs: os: [ ubuntu-latest, macos-latest, windows-latest ] steps: + - name: Disable Git's autocrlf + run: git config --global core.autocrlf false - uses: actions/checkout@5a4ac9002d0be2fb38bd78e4b4dbde5606d7042f # v2.3.4 with: fetch-depth: 2