@Test public void buildSourceCode() throws IOException { final CodeSnippet snippet = new CodeSnippet(); snippet.getProperties().put(MODULE_NAME_PROPERTY, "sfx.Golo"); snippet.getProperties().put(IMPORTS_PROPERTY, "import mypackage\nmysecondpackage"); snippet.getProperties().put(WRAP_IN_MAIN_PROPERTY, "true"); snippet.setCode("println(\"Hello\")"); final String expected = IOUtils.read(GoloSnippetExecutorTest.class.getResourceAsStream("/com/twasyl/slideshowfx/snippet/executor/golo/buildSourceCode_expected.txt")); assertEquals(expected, snippetExecutor.buildSourceCode(snippet)); }
protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); sourceCode.append(getStartModuleDefinition(codeSnippet)).append("\n\n"); if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("function main = |args| {\n") .append(codeSnippet.getCode()) .append("\n}"); } else { sourceCode.append(codeSnippet.getCode()); } sourceCode.append("\n"); return sourceCode.toString(); }
GoloSnippetExecutor extends AbstractSnippetExecutor<GoloSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); sourceCode.append(getStartModuleDefinition(codeSnippet)).append("\n\n"); if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("function main = |args| {\n") .append(codeSnippet.getCode()) .append("\n}"); } else { sourceCode.append(codeSnippet.getCode()); } sourceCode.append("\n"); return sourceCode.toString(); } }
GoloSnippetExecutor extends AbstractSnippetExecutor<GoloSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); sourceCode.append(getStartModuleDefinition(codeSnippet)).append("\n\n"); if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("function main = |args| {\n") .append(codeSnippet.getCode()) .append("\n}"); } else { sourceCode.append(codeSnippet.getCode()); } sourceCode.append("\n"); return sourceCode.toString(); } GoloSnippetExecutor(); }
GoloSnippetExecutor extends AbstractSnippetExecutor<GoloSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); sourceCode.append(getStartModuleDefinition(codeSnippet)).append("\n\n"); if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("function main = |args| {\n") .append(codeSnippet.getCode()) .append("\n}"); } else { sourceCode.append(codeSnippet.getCode()); } sourceCode.append("\n"); return sourceCode.toString(); } GoloSnippetExecutor(); @Override Parent getUI(final CodeSnippet codeSnippet); @Override Node getConfigurationUI(); @Override void saveNewOptions(); @Override ObservableList<String> execute(final CodeSnippet codeSnippet); }
GoloSnippetExecutor extends AbstractSnippetExecutor<GoloSnippetExecutorOptions> { protected String buildSourceCode(final CodeSnippet codeSnippet) throws IOException { final StringBuilder sourceCode = new StringBuilder(); sourceCode.append(getStartModuleDefinition(codeSnippet)).append("\n\n"); if (hasImports(codeSnippet)) { sourceCode.append(getImports(codeSnippet)).append("\n\n"); } if (mustBeWrappedIn(codeSnippet, WRAP_IN_MAIN_PROPERTY)) { sourceCode.append("function main = |args| {\n") .append(codeSnippet.getCode()) .append("\n}"); } else { sourceCode.append(codeSnippet.getCode()); } sourceCode.append("\n"); return sourceCode.toString(); } GoloSnippetExecutor(); @Override Parent getUI(final CodeSnippet codeSnippet); @Override Node getConfigurationUI(); @Override void saveNewOptions(); @Override ObservableList<String> execute(final CodeSnippet codeSnippet);  }