diff --git a/src/test/java/org/cadixdev/mercury/test/Java10Tests.java b/src/test/java/org/cadixdev/mercury/test/Java10Tests.java new file mode 100644 index 0000000..a5da033 --- /dev/null +++ b/src/test/java/org/cadixdev/mercury/test/Java10Tests.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.cadixdev.mercury.test; + +import org.cadixdev.mercury.Mercury; +import org.eclipse.jdt.core.JavaCore; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class Java10Tests { + + @Test + @DisplayName("doesn't remove var keyword (remapped type)") + void remapVarKeywordRemappedType() throws Exception { + new RemapperTest("java-10", Java10Tests::configureMercury) + .copy("a") + .register("b", "b") + .test(); + } + @Test + @DisplayName("doesn't remove var keyword (not remapped type)") + void remapVarKeywordNotRemappedType() throws Exception { + new RemapperTest("java-10", Java10Tests::configureMercury) + .register("c", "c") + .test(); + } + + static void configureMercury(final Mercury mercury) { + mercury.setSourceCompatibility(JavaCore.VERSION_10); + } + +} diff --git a/src/test/java/org/cadixdev/mercury/test/Java11Tests.java b/src/test/java/org/cadixdev/mercury/test/Java11Tests.java new file mode 100644 index 0000000..978b525 --- /dev/null +++ b/src/test/java/org/cadixdev/mercury/test/Java11Tests.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.cadixdev.mercury.test; + +import org.cadixdev.mercury.Mercury; +import org.eclipse.jdt.core.JavaCore; +import org.junit.jupiter.api.DisplayName; +import org.junit.jupiter.api.Test; + +class Java11Tests { + + @Test + @DisplayName("doesn't remove var keyword in lambda parameter (remapped type)") + void remapVarKeywordRemappedTypeLambdaParameter() throws Exception { + new RemapperTest("java-11", Java11Tests::configureMercury) + .copy("a") + .register("b", "b") + .test(); + } + @Test + @DisplayName("doesn't remove var keyword in lambda parameter (not remapped type)") + void remapVarKeywordNotRemappedTypeLambdaParameter() throws Exception { + new RemapperTest("java-11", Java11Tests::configureMercury) + .register("c", "c") + .test(); + } + + static void configureMercury(final Mercury mercury) { + mercury.setSourceCompatibility(JavaCore.VERSION_11); + } + +} diff --git a/src/test/java/org/cadixdev/mercury/test/RemapperTest.java b/src/test/java/org/cadixdev/mercury/test/RemapperTest.java new file mode 100644 index 0000000..a7de4be --- /dev/null +++ b/src/test/java/org/cadixdev/mercury/test/RemapperTest.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +package org.cadixdev.mercury.test; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import org.cadixdev.bombe.util.ByteStreams; +import org.cadixdev.lorenz.MappingSet; +import org.cadixdev.lorenz.io.MappingFormats; +import org.cadixdev.lorenz.io.MappingsReader; +import org.cadixdev.mercury.Mercury; +import org.cadixdev.mercury.remapper.MercuryRemapper; + +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.StandardCopyOption; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Consumer; + +public class RemapperTest { + + private final String name; + private final Consumer mercuryConfigure; + + private final Path dir; + private final MappingSet mappings; + + private final Map expected = new HashMap<>(); + + public RemapperTest(final String name) throws IOException { + this(name, mercury -> {}); + } + + public RemapperTest(final String name, final Consumer mercuryConfigure) throws IOException { + this.name = name; + this.mercuryConfigure = mercuryConfigure; + + // Create temporary directory, as Mercury needs to operate on the actual file + // system. + this.dir = Files.createTempDirectory("mercury-test"); + Files.createDirectories(this.dir.resolve("a")); + Files.createDirectories(this.dir.resolve("b")); + + // Read test mappings + this.mappings = MappingSet.create(); + try (final MappingsReader reader = MappingFormats.byId("jam") + .createReader(RemapperTest.class.getResourceAsStream("/" + this.name + "/test.jam"))) { + reader.read(this.mappings); + } + } + + public RemapperTest copy(final String file) throws IOException { + final Path path = this.dir.resolve("a").resolve(file + ".java"); + + // Make sure the parent directory exists + Files.createDirectories(path.getParent()); + + // Copy the file to the file system + Files.copy( + RemapperTest.class.getResourceAsStream("/" + this.name + "/a/" + file + ".java"), + path, + StandardCopyOption.REPLACE_EXISTING + ); + + // Finally verify the file exists, to prevent issues later on + assertTrue(Files.exists(path), file + " failed to copy!"); + + return this; + } + + public RemapperTest register(final String a, final String b) throws IOException { + // Copy to a + this.copy(a); + + // Register test + this.expected.put(a + ".java", b + ".java"); + + return this; + } + + public void test() throws Exception { + final Path in = this.dir.resolve("a"); + final Path out = this.dir.resolve("b"); + + final Mercury mercury = new Mercury(); + this.mercuryConfigure.accept(mercury); + mercury.getProcessors().add(MercuryRemapper.create(this.mappings)); + mercury.rewrite(in, out); + + for (final String file : this.expected.values()) { + final Path path = out.resolve(file); + + // First check the path exists + assertTrue(Files.exists(path), file + " doesn't exists!"); + + // Check the file matches the expected output + final String expected; + try (final InputStream is = RemapperTest.class.getResourceAsStream("/" + this.name + "/b/" + file)) { + final ByteArrayOutputStream baos = new ByteArrayOutputStream(); + ByteStreams.copy(is, baos); + expected = baos.toString(); + } + final String actual = new String(Files.readAllBytes(path)); + assertEquals(expected, actual, "Remapped code for " + file + " does not match expected"); + } + } + +} diff --git a/src/test/java/org/cadixdev/mercury/test/RemappingTests.java b/src/test/java/org/cadixdev/mercury/test/RemappingTests.java index e7668b5..1b6ebff 100644 --- a/src/test/java/org/cadixdev/mercury/test/RemappingTests.java +++ b/src/test/java/org/cadixdev/mercury/test/RemappingTests.java @@ -20,6 +20,7 @@ import org.cadixdev.mercury.Mercury; import org.cadixdev.mercury.remapper.MercuryRemapper; import org.eclipse.jdt.core.JavaCore; +import org.junit.jupiter.api.DisplayName; import org.junit.jupiter.api.Test; import java.io.ByteArrayOutputStream; @@ -33,6 +34,134 @@ class RemappingTests { + @Test + @DisplayName("remaps class declaration") + void remapClassDeclaration() throws Exception { + new RemapperTest("remap-class") + .register("a", "Declaration") + .test(); + } + + @Test + @DisplayName("remaps field type") + void remapFieldType() throws Exception { + new RemapperTest("remap-class") + .copy("a") + .register("b", "b") + .test(); + } + + @Test + @DisplayName("remaps method type") + void remapMethodType() throws Exception { + new RemapperTest("remap-class") + .copy("a") + .register("c", "c") + .test(); + } + + @Test + @DisplayName("remaps method declaration") + void remapMethodDeclaration() throws Exception { + new RemapperTest("remap-method") + .register("a", "a") + .test(); + } + + @Test + @DisplayName("remaps method call") + void remapMethodCall() throws Exception { + new RemapperTest("remap-method") + .copy("a") + .register("b", "b") + .test(); + } + + @Test + @DisplayName("remaps field declaration") + void remapFieldDeclaration() throws Exception { + new RemapperTest("remap-field") + .register("a", "a") + .test(); + } + + @Test + @DisplayName("remaps field usage") + void remapFieldUsage() throws Exception { + new RemapperTest("remap-field") + .copy("a") + .register("b", "b") + .test(); + } + + @Test + @DisplayName("remaps enum constant declaration") + void remapEnumConstantDeclaration() throws Exception { + new RemapperTest("remap-field") + .register("c", "c") + .test(); + } + + @Test + @DisplayName("remaps enum constant usage") + void remapEnumConstantUsage() throws Exception { + new RemapperTest("remap-field") + .copy("c") + .register("d", "d") + .test(); + } + + @Test + @DisplayName("remaps single method parameter") + void remapSingleParameter() throws Exception { + new RemapperTest("remap-param") + .register("a", "a") + .test(); + } + + @Test + @DisplayName("remaps multiple method parameters") + void remapMultipleParameters() throws Exception { + new RemapperTest("remap-param") + .register("b", "b") + .test(); + } + + @Test + @DisplayName("remaps class reference in javadocs") + void remapJavadocClassReference() throws Exception { + new RemapperTest("remap-javadocs") + .copy("a") + .register("b", "b") + .test(); + } + + @Test + @DisplayName("remaps field reference in javadocs") + void remapJavadocFieldReference() throws Exception { + new RemapperTest("remap-javadocs") + .copy("a") + .register("c", "c") + .test(); + } + + @Test + @DisplayName("remaps method reference in javadocs") + void remapJavadocMethodReference() throws Exception { + new RemapperTest("remap-javadocs") + .copy("a") + .register("d", "d") + .test(); + } + + @Test + @DisplayName("remaps parameter reference in javadocs") + void remapJavadocParamReference() throws Exception { + new RemapperTest("remap-javadocs") + .register("e", "e") + .test(); + } + // Mercury contains the following tests: // 1. Simple remaps // This test is used to verify that Mercury can remap simple things: diff --git a/src/test/resources/java-10/a/a.java b/src/test/resources/java-10/a/a.java new file mode 100644 index 0000000..68ef840 --- /dev/null +++ b/src/test/resources/java-10/a/a.java @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class a { +} diff --git a/src/test/resources/java-10/a/b.java b/src/test/resources/java-10/a/b.java new file mode 100644 index 0000000..60fd413 --- /dev/null +++ b/src/test/resources/java-10/a/b.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + public static void main(final String[] args) { + final var instance = new a(); + } +} diff --git a/src/test/resources/java-10/a/c.java b/src/test/resources/java-10/a/c.java new file mode 100644 index 0000000..eda485f --- /dev/null +++ b/src/test/resources/java-10/a/c.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class c { + public static void main(final String[] args) { + final var name = "Demo Name"; + } +} diff --git a/src/test/resources/java-10/b/Remapped.java b/src/test/resources/java-10/b/Remapped.java new file mode 100644 index 0000000..5db4323 --- /dev/null +++ b/src/test/resources/java-10/b/Remapped.java @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class Remapped { +} diff --git a/src/test/resources/java-10/b/b.java b/src/test/resources/java-10/b/b.java new file mode 100644 index 0000000..aee0100 --- /dev/null +++ b/src/test/resources/java-10/b/b.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + public static void main(final String[] args) { + final var instance = new Remapped(); + } +} diff --git a/src/test/resources/java-10/b/c.java b/src/test/resources/java-10/b/c.java new file mode 100644 index 0000000..eda485f --- /dev/null +++ b/src/test/resources/java-10/b/c.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class c { + public static void main(final String[] args) { + final var name = "Demo Name"; + } +} diff --git a/src/test/resources/java-10/test.jam b/src/test/resources/java-10/test.jam new file mode 100644 index 0000000..afd3866 --- /dev/null +++ b/src/test/resources/java-10/test.jam @@ -0,0 +1 @@ +CL a Remapped diff --git a/src/test/resources/java-11/a/a.java b/src/test/resources/java-11/a/a.java new file mode 100644 index 0000000..68ef840 --- /dev/null +++ b/src/test/resources/java-11/a/a.java @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class a { +} diff --git a/src/test/resources/java-11/a/b.java b/src/test/resources/java-11/a/b.java new file mode 100644 index 0000000..6fc67c1 --- /dev/null +++ b/src/test/resources/java-11/a/b.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +import java.util.function.Consumer; + +public class b { + public static void main(final String[] args) { + using(new a(), (var instance) -> { + }); + } + + private static void using(final a instance, final Consumer consumer) { + consumer.accept(instance); + } +} diff --git a/src/test/resources/java-11/a/c.java b/src/test/resources/java-11/a/c.java new file mode 100644 index 0000000..c5435b3 --- /dev/null +++ b/src/test/resources/java-11/a/c.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +import java.util.function.Consumer; + +public class b { + public static void main(final String[] args) { + using("Demo", (var name) -> { + }); + } + + private static void using(final String name, final Consumer consumer) { + consumer.accept(name); + } +} diff --git a/src/test/resources/java-11/b/Remapped.java b/src/test/resources/java-11/b/Remapped.java new file mode 100644 index 0000000..5db4323 --- /dev/null +++ b/src/test/resources/java-11/b/Remapped.java @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class Remapped { +} diff --git a/src/test/resources/java-11/b/b.java b/src/test/resources/java-11/b/b.java new file mode 100644 index 0000000..3dcbe46 --- /dev/null +++ b/src/test/resources/java-11/b/b.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +import java.util.function.Consumer; + +public class b { + public static void main(final String[] args) { + using(new Remapped(), (var instance) -> { + }); + } + + private static void using(final Remapped instance, final Consumer consumer) { + consumer.accept(instance); + } +} diff --git a/src/test/resources/java-11/b/c.java b/src/test/resources/java-11/b/c.java new file mode 100644 index 0000000..c5435b3 --- /dev/null +++ b/src/test/resources/java-11/b/c.java @@ -0,0 +1,22 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +import java.util.function.Consumer; + +public class b { + public static void main(final String[] args) { + using("Demo", (var name) -> { + }); + } + + private static void using(final String name, final Consumer consumer) { + consumer.accept(name); + } +} diff --git a/src/test/resources/java-11/test.jam b/src/test/resources/java-11/test.jam new file mode 100644 index 0000000..afd3866 --- /dev/null +++ b/src/test/resources/java-11/test.jam @@ -0,0 +1 @@ +CL a Remapped diff --git a/src/test/resources/remap-class/a/a.java b/src/test/resources/remap-class/a/a.java new file mode 100644 index 0000000..68ef840 --- /dev/null +++ b/src/test/resources/remap-class/a/a.java @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class a { +} diff --git a/src/test/resources/remap-class/a/b.java b/src/test/resources/remap-class/a/b.java new file mode 100644 index 0000000..b14b43c --- /dev/null +++ b/src/test/resources/remap-class/a/b.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + private a a; + + public b(final a a) { + this.a = a; + } +} diff --git a/src/test/resources/remap-class/a/c.java b/src/test/resources/remap-class/a/c.java new file mode 100644 index 0000000..d9b1c0f --- /dev/null +++ b/src/test/resources/remap-class/a/c.java @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class c { + void a(final a a) { + } +} diff --git a/src/test/resources/remap-class/b/Declaration.java b/src/test/resources/remap-class/b/Declaration.java new file mode 100644 index 0000000..e68d0dc --- /dev/null +++ b/src/test/resources/remap-class/b/Declaration.java @@ -0,0 +1,12 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class Declaration { +} diff --git a/src/test/resources/remap-class/b/b.java b/src/test/resources/remap-class/b/b.java new file mode 100644 index 0000000..250b473 --- /dev/null +++ b/src/test/resources/remap-class/b/b.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + private Declaration a; + + public b(final Declaration a) { + this.a = a; + } +} diff --git a/src/test/resources/remap-class/b/c.java b/src/test/resources/remap-class/b/c.java new file mode 100644 index 0000000..c58d62a --- /dev/null +++ b/src/test/resources/remap-class/b/c.java @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class c { + void a(final Declaration a) { + } +} diff --git a/src/test/resources/remap-class/test.jam b/src/test/resources/remap-class/test.jam new file mode 100644 index 0000000..05e98e7 --- /dev/null +++ b/src/test/resources/remap-class/test.jam @@ -0,0 +1 @@ +CL a Declaration diff --git a/src/test/resources/remap-field/a/a.java b/src/test/resources/remap-field/a/a.java new file mode 100644 index 0000000..73364a8 --- /dev/null +++ b/src/test/resources/remap-field/a/a.java @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class a { + public String a; +} diff --git a/src/test/resources/remap-field/a/b.java b/src/test/resources/remap-field/a/b.java new file mode 100644 index 0000000..640e181 --- /dev/null +++ b/src/test/resources/remap-field/a/b.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + public static void main(final String[] args) { + final a instance = new a(); + System.out.println(instance.a); + } +} diff --git a/src/test/resources/remap-field/a/c.java b/src/test/resources/remap-field/a/c.java new file mode 100644 index 0000000..47ad698 --- /dev/null +++ b/src/test/resources/remap-field/a/c.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public enum c { + a, + b, + ; +} diff --git a/src/test/resources/remap-field/a/d.java b/src/test/resources/remap-field/a/d.java new file mode 100644 index 0000000..80c0a8a --- /dev/null +++ b/src/test/resources/remap-field/a/d.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class d { + public static void main(final String[] args) { + System.out.println(c.a.toString()); + System.out.println(c.b.toString()); + } +} diff --git a/src/test/resources/remap-field/b/a.java b/src/test/resources/remap-field/b/a.java new file mode 100644 index 0000000..3aca2d2 --- /dev/null +++ b/src/test/resources/remap-field/b/a.java @@ -0,0 +1,13 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class a { + public String name; +} diff --git a/src/test/resources/remap-field/b/b.java b/src/test/resources/remap-field/b/b.java new file mode 100644 index 0000000..b933ea1 --- /dev/null +++ b/src/test/resources/remap-field/b/b.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + public static void main(final String[] args) { + final a instance = new a(); + System.out.println(instance.name); + } +} diff --git a/src/test/resources/remap-field/b/c.java b/src/test/resources/remap-field/b/c.java new file mode 100644 index 0000000..6b41d32 --- /dev/null +++ b/src/test/resources/remap-field/b/c.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public enum c { + FIRST, + SECOND, + ; +} diff --git a/src/test/resources/remap-field/b/d.java b/src/test/resources/remap-field/b/d.java new file mode 100644 index 0000000..8dec180 --- /dev/null +++ b/src/test/resources/remap-field/b/d.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class d { + public static void main(final String[] args) { + System.out.println(c.FIRST.toString()); + System.out.println(c.SECOND.toString()); + } +} diff --git a/src/test/resources/remap-field/test.jam b/src/test/resources/remap-field/test.jam new file mode 100644 index 0000000..fc82165 --- /dev/null +++ b/src/test/resources/remap-field/test.jam @@ -0,0 +1,4 @@ +FD a a Ljava/lang/String; name + +FD c a Lc; FIRST +FD c b Lc; SECOND diff --git a/src/test/resources/remap-javadocs/a/a.java b/src/test/resources/remap-javadocs/a/a.java new file mode 100644 index 0000000..20ba037 --- /dev/null +++ b/src/test/resources/remap-javadocs/a/a.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class a { + public String a; + + void b() { + } +} diff --git a/src/test/resources/remap-javadocs/a/b.java b/src/test/resources/remap-javadocs/a/b.java new file mode 100644 index 0000000..801b96b --- /dev/null +++ b/src/test/resources/remap-javadocs/a/b.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + /** + * {@link a} + */ + void demo() { + } +} diff --git a/src/test/resources/remap-javadocs/a/c.java b/src/test/resources/remap-javadocs/a/c.java new file mode 100644 index 0000000..f735cf0 --- /dev/null +++ b/src/test/resources/remap-javadocs/a/c.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class c { + /** + * {@link a#a} + */ + void demo() { + } +} diff --git a/src/test/resources/remap-javadocs/a/d.java b/src/test/resources/remap-javadocs/a/d.java new file mode 100644 index 0000000..6f9d44b --- /dev/null +++ b/src/test/resources/remap-javadocs/a/d.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class d { + /** + * {@link a#b()} + */ + void demo() { + } +} diff --git a/src/test/resources/remap-javadocs/a/e.java b/src/test/resources/remap-javadocs/a/e.java new file mode 100644 index 0000000..29a9b7e --- /dev/null +++ b/src/test/resources/remap-javadocs/a/e.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class e { + /** + * @param a + */ + void a(final String a) { + } +} diff --git a/src/test/resources/remap-javadocs/b/Remapped.java b/src/test/resources/remap-javadocs/b/Remapped.java new file mode 100644 index 0000000..442ef98 --- /dev/null +++ b/src/test/resources/remap-javadocs/b/Remapped.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class Remapped { + public String name; + + void run() { + } +} diff --git a/src/test/resources/remap-javadocs/b/b.java b/src/test/resources/remap-javadocs/b/b.java new file mode 100644 index 0000000..dc5f51b --- /dev/null +++ b/src/test/resources/remap-javadocs/b/b.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + /** + * {@link Remapped} + */ + void demo() { + } +} diff --git a/src/test/resources/remap-javadocs/b/c.java b/src/test/resources/remap-javadocs/b/c.java new file mode 100644 index 0000000..e976a16 --- /dev/null +++ b/src/test/resources/remap-javadocs/b/c.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class c { + /** + * {@link Remapped#name} + */ + void demo() { + } +} diff --git a/src/test/resources/remap-javadocs/b/d.java b/src/test/resources/remap-javadocs/b/d.java new file mode 100644 index 0000000..85a993b --- /dev/null +++ b/src/test/resources/remap-javadocs/b/d.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class d { + /** + * {@link Remapped#run()} + */ + void demo() { + } +} diff --git a/src/test/resources/remap-javadocs/b/e.java b/src/test/resources/remap-javadocs/b/e.java new file mode 100644 index 0000000..8e1b2dc --- /dev/null +++ b/src/test/resources/remap-javadocs/b/e.java @@ -0,0 +1,17 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class e { + /** + * @param group + */ + void a(final String group) { + } +} diff --git a/src/test/resources/remap-javadocs/test.jam b/src/test/resources/remap-javadocs/test.jam new file mode 100644 index 0000000..dd3ed49 --- /dev/null +++ b/src/test/resources/remap-javadocs/test.jam @@ -0,0 +1,7 @@ +CL a Remapped + +FD a a Ljava/lang/String; name + +MD a b ()V; run + +MP e a (Ljava/lang/String;)V 0 group diff --git a/src/test/resources/remap-method/a/a.java b/src/test/resources/remap-method/a/a.java new file mode 100644 index 0000000..b7ea198 --- /dev/null +++ b/src/test/resources/remap-method/a/a.java @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class a { + public void a() { + } +} diff --git a/src/test/resources/remap-method/a/b.java b/src/test/resources/remap-method/a/b.java new file mode 100644 index 0000000..8978e61 --- /dev/null +++ b/src/test/resources/remap-method/a/b.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + public static void main(final String[] args) { + final a instance = new a(); + a.a(); + } +} diff --git a/src/test/resources/remap-method/b/a.java b/src/test/resources/remap-method/b/a.java new file mode 100644 index 0000000..bb94afc --- /dev/null +++ b/src/test/resources/remap-method/b/a.java @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class a { + public void run() { + } +} diff --git a/src/test/resources/remap-method/b/b.java b/src/test/resources/remap-method/b/b.java new file mode 100644 index 0000000..d6592aa --- /dev/null +++ b/src/test/resources/remap-method/b/b.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + public static void main(final String[] args) { + final a instance = new a(); + a.run(); + } +} diff --git a/src/test/resources/remap-method/test.jam b/src/test/resources/remap-method/test.jam new file mode 100644 index 0000000..97bbf9a --- /dev/null +++ b/src/test/resources/remap-method/test.jam @@ -0,0 +1 @@ +MD a a ()V; run diff --git a/src/test/resources/remap-param/a/a.java b/src/test/resources/remap-param/a/a.java new file mode 100644 index 0000000..b176716 --- /dev/null +++ b/src/test/resources/remap-param/a/a.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class a { + void a(final String a) { + System.out.println(a); + } +} diff --git a/src/test/resources/remap-param/a/b.java b/src/test/resources/remap-param/a/b.java new file mode 100644 index 0000000..2942eec --- /dev/null +++ b/src/test/resources/remap-param/a/b.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + void a(final String a, final String b) { + System.out.println(a); + System.out.println(b); + } +} diff --git a/src/test/resources/remap-param/b/a.java b/src/test/resources/remap-param/b/a.java new file mode 100644 index 0000000..356d75c --- /dev/null +++ b/src/test/resources/remap-param/b/a.java @@ -0,0 +1,15 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class a { + void a(final String name) { + System.out.println(name); + } +} diff --git a/src/test/resources/remap-param/b/b.java b/src/test/resources/remap-param/b/b.java new file mode 100644 index 0000000..c5f9c3b --- /dev/null +++ b/src/test/resources/remap-param/b/b.java @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2018 Cadix Development (https://www.cadixdev.org) + * + * This program and the accompanying materials are made available under the + * terms of the Eclipse Public License 2.0 which accompanies this distribution, + * and is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + */ + +public class b { + void a(final String id, final String name) { + System.out.println(id); + System.out.println(name); + } +} diff --git a/src/test/resources/remap-param/test.jam b/src/test/resources/remap-param/test.jam new file mode 100644 index 0000000..d69cbd3 --- /dev/null +++ b/src/test/resources/remap-param/test.jam @@ -0,0 +1,6 @@ +# a.java +MP a a (Ljava/lang/String;)V 0 name + +# b.java +MP b a (Ljava/lang/String;Ljava/lang/String;)V 0 id +MP b a (Ljava/lang/String;Ljava/lang/String;)V 1 name