@Test public void buildSourceCodeWithoutWrapInMain() throws IOException { final CodeSnippet snippet = new CodeSnippet(); snippet.getProperties().put(PACKAGE_NAME_PROPERTY, "SlideshowFX"); snippet.getProperties().put(IMPORTS_PROPERTY, "import mypackage\nmysecondpackage"); snippet.setCode("fun main(args: Array<String>) {\n\tprintln(\"Hello\")\n}"); final String expected = IOUtils.read(KotlinSnippetExecutorTest.class.getResourceAsStream("/com/twasyl/slideshowfx/snippet/executor/kotlin/buildSourceCodeWithoutWrapInMain_expected.txt")); assertEquals(expected, snippetExecutor.buildSourceCode(snippet)); }
protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); if (hasPackage(codeSnippet)) { sourceCode.append(getPackage(codeSnippet)).append("\n\n"); } if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("fun main(args: Array<String>) {\n") .append(codeSnippet.getCode()) .append("\n}"); } else { sourceCode.append(codeSnippet.getCode()); } return sourceCode.toString(); }
KotlinSnippetExecutor extends AbstractSnippetExecutor<KotlinSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); if (hasPackage(codeSnippet)) { sourceCode.append(getPackage(codeSnippet)).append("\n\n"); } if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("fun main(args: Array<String>) {\n") .append(codeSnippet.getCode()) .append("\n}"); } else { sourceCode.append(codeSnippet.getCode()); } return sourceCode.toString(); } }
KotlinSnippetExecutor extends AbstractSnippetExecutor<KotlinSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); if (hasPackage(codeSnippet)) { sourceCode.append(getPackage(codeSnippet)).append("\n\n"); } if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("fun main(args: Array<String>) {\n") .append(codeSnippet.getCode()) .append("\n}"); } else { sourceCode.append(codeSnippet.getCode()); } return sourceCode.toString(); } KotlinSnippetExecutor(); }
KotlinSnippetExecutor extends AbstractSnippetExecutor<KotlinSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); if (hasPackage(codeSnippet)) { sourceCode.append(getPackage(codeSnippet)).append("\n\n"); } if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("fun main(args: Array<String>) {\n") .append(codeSnippet.getCode()) .append("\n}"); } else { sourceCode.append(codeSnippet.getCode()); } return sourceCode.toString(); } KotlinSnippetExecutor(); @Override Parent getUI(final CodeSnippet codeSnippet); @Override Node getConfigurationUI(); @Override void saveNewOptions(); @Override ObservableList<String> execute(final CodeSnippet codeSnippet); }
KotlinSnippetExecutor extends AbstractSnippetExecutor<KotlinSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); if (hasPackage(codeSnippet)) { sourceCode.append(getPackage(codeSnippet)).append("\n\n"); } if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("fun main(args: Array<String>) {\n") .append(codeSnippet.getCode()) .append("\n}"); } else { sourceCode.append(codeSnippet.getCode()); } return sourceCode.toString(); } KotlinSnippetExecutor(); @Override Parent getUI(final CodeSnippet codeSnippet); @Override Node getConfigurationUI(); @Override void saveNewOptions(); @Override ObservableList<String> execute(final CodeSnippet codeSnippet);  }