diff --git a/build.gradle b/build.gradle index cfb8986..e02ace1 100644 --- a/build.gradle +++ b/build.gradle @@ -24,7 +24,7 @@ plugins { apply from: "https://gist.githubusercontent.com/raw/$spotlessRulesGistId/spotless.gradle" group 'io.yooksi' -version '1.0.1' +version '1.0.2' idea { project { diff --git a/src/main/java/io/yooksi/pz/zdoc/element/LuaMethod.java b/src/main/java/io/yooksi/pz/zdoc/element/LuaMethod.java index 8c0f6d4..b73ea11 100644 --- a/src/main/java/io/yooksi/pz/zdoc/element/LuaMethod.java +++ b/src/main/java/io/yooksi/pz/zdoc/element/LuaMethod.java @@ -28,6 +28,7 @@ /** * This class represents a parsed Lua method. */ +@SuppressWarnings("unused") public class LuaMethod extends Method { private final String qualifier; @@ -78,7 +79,7 @@ public String toString() { sb.append("function "); if (!qualifier.isEmpty()) { - sb.append(qualifier).append('.'); + sb.append(qualifier).append(':'); } sb.append(name).append('('); diff --git a/src/test/java/io/yooksi/pz/zdoc/MainTest.java b/src/test/java/io/yooksi/pz/zdoc/MainTest.java index a32b108..a2f8553 100644 --- a/src/test/java/io/yooksi/pz/zdoc/MainTest.java +++ b/src/test/java/io/yooksi/pz/zdoc/MainTest.java @@ -41,6 +41,33 @@ public class MainTest extends TestWorkspace { super("sampleLua.lua"); } + private static Executable runMain(@Nullable Command command, String input, String output) { + return () -> Main.main(formatAppArgs(command != null ? command.getName() : "", input, output)); + } + + @TestOnly + public static String[] formatAppArgs(String command, String input, String output) { + + List args = new java.util.ArrayList<>(); + args.add(command); + if (!input.isEmpty()) + { + args.add("-i"); + args.add(input); + } + if (!output.isEmpty()) + { + args.add("-o"); + args.add(output); + } + return args.toArray(new String[]{}); + } + + @TestOnly + public static String[] formatAppArgs(Command command, String input, String output) { + return formatAppArgs(command.getName(), input, output); + } + @Test void shouldThrowExceptionWhenApplicationRunWithMissingCommand() { @@ -155,32 +182,4 @@ void whenApplicationRunShouldConvertJavaToLuaDoc() throws Throwable { Assertions.assertEquals(expected[i], actual.get(i)); } } - - private static Executable runMain(@Nullable Command command, String input, String output) { - return () -> Main.main(formatAppArgs(command != null ? command.getName() : "", input, output)); - } - - @TestOnly - public static String[] formatAppArgs(String command, String input, String output) { - - List args = new java.util.ArrayList<>(); - args.add(command); - if (!input.isEmpty()) - { - args.add("-i"); - args.add(input); - } - if (!output.isEmpty()) - { - args.add("-o"); - args.add(output); - } - return args.toArray(new String[]{}); - } - - - @TestOnly - public static String[] formatAppArgs(Command command, String input, String output) { - return formatAppArgs(command.getName(), input, output); - } } diff --git a/src/test/java/io/yooksi/pz/zdoc/cmd/CommandTest.java b/src/test/java/io/yooksi/pz/zdoc/cmd/CommandTest.java index 7a83c45..8f4da9b 100644 --- a/src/test/java/io/yooksi/pz/zdoc/cmd/CommandTest.java +++ b/src/test/java/io/yooksi/pz/zdoc/cmd/CommandTest.java @@ -51,9 +51,9 @@ void shouldRecognizeAllCommands() { @Test void shouldDetectAllCommandLineOptions() throws ParseException { - String[][] argArrays = new String[][] { - new String[] { "-i", "input/path", "-o", "output/path" }, - new String[] { "-o", "output/path", "-i", "input/path", } + String[][] argArrays = new String[][]{ + new String[]{ "-i", "input/path", "-o", "output/path" }, + new String[]{ "-o", "output/path", "-i", "input/path", } }; for (Command command : Command.WORK_COMMANDS) { @@ -72,19 +72,20 @@ void shouldDetectAllCommandLineOptions() throws ParseException { @Test void shouldThrowExceptionWhenMissingCommandArguments() { - String[][] missingArgs = new String[][] { + String[][] missingArgs = new String[][]{ // new String[] { "-i", "input/path" }, // missing output path - new String[] { "-o", "output/path" } // missing input path + new String[]{ "-o", "output/path" } // missing input path }; for (String[] args : missingArgs) { Arrays.stream(Command.WORK_COMMANDS).forEach(c -> Assertions.assertThrows(ParseException.class, () -> CommandLine.parse(c.options, ArrayUtils.addFirst(args, c.name)))); } - String[][] correctArgs = new String[][] { - new String[] { "-i", "input/path", "-o", "output/path" }, - new String[] { "-o", "output/path", "-i", "input/path", } + String[][] correctArgs = new String[][]{ + new String[]{ "-i", "input/path", "-o", "output/path" }, + new String[]{ "-o", "output/path", "-i", "input/path", } }; - for (String[] args : correctArgs) { + for (String[] args : correctArgs) + { Arrays.stream(Command.WORK_COMMANDS).forEach(c -> Assertions.assertDoesNotThrow(() -> CommandLine.parse(c.options, ArrayUtils.addFirst(args, c.name)))); } diff --git a/src/test/java/io/yooksi/pz/zdoc/doc/LuaDocTest.java b/src/test/java/io/yooksi/pz/zdoc/doc/LuaDocTest.java index c96248f..a6c302f 100644 --- a/src/test/java/io/yooksi/pz/zdoc/doc/LuaDocTest.java +++ b/src/test/java/io/yooksi/pz/zdoc/doc/LuaDocTest.java @@ -58,7 +58,7 @@ void shouldNotThrowExceptionWhenParsingTopLineLuaFile() throws IOException { } @Test - void shouldNotWriteToFileIfNoDocElementsFound() throws IOException { + void shouldNotWriteToFileIfNoDocElementsFound() { String[] expected = new String[]{ "--- No doc elements" }; String actual = writeParseAndReadLua(expected).get(0); @@ -67,7 +67,7 @@ void shouldNotWriteToFileIfNoDocElementsFound() throws IOException { } @Test - void shouldOverwriteExistingLuaAnnotation() throws IOException { + void shouldOverwriteExistingLuaAnnotation() { List read = writeParseAndReadLua(new String[]{ "--- This is a sample comment", @@ -78,7 +78,7 @@ void shouldOverwriteExistingLuaAnnotation() throws IOException { } @Test - void shouldReadAnnotationsWithWhitespaces() throws IOException { + void shouldReadAnnotationsWithWhitespaces() { List read = writeParseAndReadLua(new String[]{ "--- @class otherSampleLua", @@ -88,7 +88,7 @@ void shouldReadAnnotationsWithWhitespaces() throws IOException { } @Test - void shouldParseAnnotationIncludeParentType() throws IOException { + void shouldParseAnnotationIncludeParentType() { String[] write = { "---@class sampleLua",