target
stringlengths
20
113k
src_fm
stringlengths
11
86.3k
src_fm_fc
stringlengths
21
86.4k
src_fm_fc_co
stringlengths
30
86.4k
src_fm_fc_ms
stringlengths
42
86.8k
src_fm_fc_ms_ff
stringlengths
43
86.8k
@Test public void nextReducedVariable_from_string_alpha_beta_gamma_offset_4_is_alpha() { assertEquals("alpha", SimpleStringUtils.nextReducedVariableWord("alpha beta gamma", 4)); }
public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void nextReducedVariable_from_string_alpha_beta_gamma_offset_6_is_beta() { assertEquals("beta", SimpleStringUtils.nextReducedVariableWord("alpha beta gamma", 6)); }
public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void nextReducedVariable_from_string_alpha_beta_gamma_offset_5_is_empty() { assertEquals("", SimpleStringUtils.nextReducedVariableWord("alpha beta gamma", 5)); }
public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void nextReducedVariable_from_string_alpha_beta_gamma_offset_9_is_beta() { assertEquals("beta", SimpleStringUtils.nextReducedVariableWord("alpha beta gamma", 9)); }
public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void nextReducedVariable_from_string_alpha_beta_gamma_offset_10_is_empty() { assertEquals("", SimpleStringUtils.nextReducedVariableWord("alpha beta gamma", 10)); }
public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void three_spaces_then_a_followed_by_three_spaces_only_are_one_entry_a_list() { assertEquals(asList("a"), converterToTest.convert(" a ")); }
public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
@Test public void enable_debugging_empty_code_results_in_firstline_including_temp_debugger_file() throws Exception { String newCode = supportToTest.enableDebugging("","localhost", BashDebugConstants.DEFAULT_DEBUG_PORT); String[] asArray = newCode.split("\n"); assertEquals(1, asArray.length); assertTrue(asArray[0].startsWith(EXPECTED_DEBUG_ENABLED_CODE)); }
public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
@Test public void nextReducedVariable_from_string_alpha_beta_gamma_offset_13_is_gamma() { assertEquals("gamma", SimpleStringUtils.nextReducedVariableWord("alpha beta gamma", 13)); }
public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void nextReducedVariable_from_string_alpha_beta_gamma_offset_15_is_gamma() { assertEquals("gamma", SimpleStringUtils.nextReducedVariableWord("alpha beta gamma", 15)); }
public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void nextReducedVariable_from_string_alpha_beta_gamma_offset_16_is_empty() { assertEquals("", SimpleStringUtils.nextReducedVariableWord("alpha beta gamma", 10)); }
public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void _ith_reducedVariableWordEndDetector_from_string_$PS1_is_double_quote_x_double_quote_offset_0_returns_$PS1() { assertEquals("$PS1", SimpleStringUtils.nextReducedVariableWord("$PS1=\"x\"", 0)); }
public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void _ith_reducedVariableWordEndDetector_from_string_$BASH_VERSIN_ARRAY_returns_$BASH_VERSIN() { assertEquals("$BASH_VERSIN", SimpleStringUtils.nextReducedVariableWord("$BASH_VERSIN[0]", 0)); }
public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String nextReducedVariableWord(String string, int offset) { return nextWord(string, offset, new ReducedVariableWordEndDetector()); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void short_string_null_1_returns_empty_string() { assertEquals("", SimpleStringUtils.shortString(null, 1)); }
public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void short_string_a_0_returns_empty_string() { assertEquals("", SimpleStringUtils.shortString("a", 0)); }
public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void short_string_a_1_returns_a_string() { assertEquals("a", SimpleStringUtils.shortString("a", 1)); }
public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void short_string_a_2_returns_a_string() { assertEquals("a", SimpleStringUtils.shortString("a", 2)); }
public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void short_string_12345678901_10_returns_1234567_dot_dot_dot_string() { assertEquals("1234567...", SimpleStringUtils.shortString("12345678901", 10)); }
public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void three_spaces_then_a_followed_by_three_spaces_then_b__are_two_entry_a_b_list() { assertEquals(asList("a","b"), converterToTest.convert(" a b")); }
public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
@Test public void short_string_1234567890_10_returns_1234567890_string() { assertEquals("1234567890", SimpleStringUtils.shortString("1234567890", 10)); }
public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static String shortString(String string, int max) { if (max == 0) { return EMPTY; } if (string == null) { return EMPTY; } if (string.length() <= max) { return string; } if (max == 1) { return "."; } if (max == 2) { return ".."; } if (max == 3) { return "..."; } StringBuilder sb = new StringBuilder(); sb.append(string.substring(0, max - 3)); sb.append("..."); return sb.toString(); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void null_equals_null__is_true() { assertTrue(SimpleStringUtils.equals(null, null)); }
public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void a_equals_a__is_true() { assertTrue(SimpleStringUtils.equals("a", "a")); }
public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void a_equals_null__is_false() { assertFalse(SimpleStringUtils.equals("a", null)); }
public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void a_equals_b__is_false() { assertFalse(SimpleStringUtils.equals("a","b")); }
public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void b_equals_a__is_false() { assertFalse(SimpleStringUtils.equals("b","a")); }
public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void null_equals_a__is_false() { assertFalse(SimpleStringUtils.equals(null,"a")); }
public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
SimpleStringUtils { public static boolean equals(String text1, String text2) { if (text1 == null) { if (text2 == null) { return true; } return false; } if (text2 == null) { return false; } return text2.equals(text1); } static boolean equals(String text1, String text2); static String shortString(String string, int max); static String nextReducedVariableWord(String string, int offset); static String nextWord(String string, int offset, WordEndDetector wordEndDetector); static boolean isNotBlank(String wd); static boolean isBlank(String wd); }
@Test public void three_spaces_then_a_followed_by_three_spaces_then_b_one_space_are_two_entry_a_b_list() { assertEquals(asList("a","b"), converterToTest.convert(" a b ")); }
public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
@Test public void a_followd_by_2_parameters() { assertEquals(asList("a", "-b", "-c"), converterToTest.convert("a -b -c")); }
public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
@Test public void a_space_b_singlequote_x_singlequote_x_space_c__are_three_entries_a_b_quote_x_quote_x_c() { assertEquals(asList("a", "b'x'", "c"), converterToTest.convert("a b'x' c")); }
public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
@Test public void a_space_b_doublequote_x_doublequote_x_space_c__are_three_entries_a_b_quote_x_quote_x_c() { assertEquals(asList("a", "b\"x\"", "c"), converterToTest.convert("a b\"x\" c")); }
public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
@Test public void null_handled_as_empty_list() { assertEquals(asList(), converterToTest.convert(null)); }
public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
@Test public void empty_handled_as_empty_list() { assertEquals(asList(), converterToTest.convert("")); }
public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
CommandStringToCommandListConverter { public List<String> convert(String commandString) { List<String> list = new ArrayList<>(); if (commandString == null) { return list; } String inspect = commandString.trim(); if (inspect.isEmpty()) { return list; } String[] commands = commandString.split(" "); for (String command: commands) { if (command==null || command.isEmpty()) { continue; } list.add(command); } return list; } List<String> convert(String commandString); }
@Test public void bugfix_139_convert_unixpathes_in_windows() throws Exception { assertEquals("/C/Users/albert/.basheditor/remote-debugging-v1.sh", OSUtil.toUnixPath("C:\\Users\\albert\\.basheditor\\remote-debugging-v1.sh")); assertEquals("/D/some/Other/.path/xYz.sh", OSUtil.toUnixPath("D:\\some\\Other\\.path\\xYz.sh")); assertEquals("/X", OSUtil.toUnixPath("X:")); assertEquals("/Y/file1.txt", OSUtil.toUnixPath("Y:\\file1.txt")); assertEquals("/C/Users/albert/.basheditor/remote-debugging-v1.sh", OSUtil.toUnixPath("/C/Users/albert/.basheditor/remote-debugging-v1.sh")); assertEquals("/D/some/Other/.path/xYz.sh", OSUtil.toUnixPath("/D/some/Other/.path/xYz.sh")); assertEquals("/X", OSUtil.toUnixPath("/X")); assertEquals("/Y/file1.txt", OSUtil.toUnixPath("/Y/file1.txt")); assertEquals("/file1.txt", OSUtil.toUnixPath("/file1.txt")); }
public static String toUnixPath(String path) { if (path==null) { return "null"; } int index = path.indexOf(':'); if (index!=1) { return path; } char windowsDrive = path.charAt(0); String remaining = path.substring(2); StringBuilder sb = new StringBuilder(); sb.append('/'); sb.append(windowsDrive); sb.append(WINDOWS_BACKSLASH_TO_SLASH_PATTERN.matcher(remaining).replaceAll("/")); return sb.toString(); }
OSUtil { public static String toUnixPath(String path) { if (path==null) { return "null"; } int index = path.indexOf(':'); if (index!=1) { return path; } char windowsDrive = path.charAt(0); String remaining = path.substring(2); StringBuilder sb = new StringBuilder(); sb.append('/'); sb.append(windowsDrive); sb.append(WINDOWS_BACKSLASH_TO_SLASH_PATTERN.matcher(remaining).replaceAll("/")); return sb.toString(); } }
OSUtil { public static String toUnixPath(String path) { if (path==null) { return "null"; } int index = path.indexOf(':'); if (index!=1) { return path; } char windowsDrive = path.charAt(0); String remaining = path.substring(2); StringBuilder sb = new StringBuilder(); sb.append('/'); sb.append(windowsDrive); sb.append(WINDOWS_BACKSLASH_TO_SLASH_PATTERN.matcher(remaining).replaceAll("/")); return sb.toString(); } }
OSUtil { public static String toUnixPath(String path) { if (path==null) { return "null"; } int index = path.indexOf(':'); if (index!=1) { return path; } char windowsDrive = path.charAt(0); String remaining = path.substring(2); StringBuilder sb = new StringBuilder(); sb.append('/'); sb.append(windowsDrive); sb.append(WINDOWS_BACKSLASH_TO_SLASH_PATTERN.matcher(remaining).replaceAll("/")); return sb.toString(); } static boolean isWindows(); static String toUnixPath(String path); static boolean isMacOS(); }
OSUtil { public static String toUnixPath(String path) { if (path==null) { return "null"; } int index = path.indexOf(':'); if (index!=1) { return path; } char windowsDrive = path.charAt(0); String remaining = path.substring(2); StringBuilder sb = new StringBuilder(); sb.append('/'); sb.append(windowsDrive); sb.append(WINDOWS_BACKSLASH_TO_SLASH_PATTERN.matcher(remaining).replaceAll("/")); return sb.toString(); } static boolean isWindows(); static String toUnixPath(String path); static boolean isMacOS(); }
@Test public void real_life_example() { Map<String, String> map = new HashMap<>(); map.put("BE_CMD_CALL", "cd /tmp;./xyz4722810921592969191.txt -a 1 -b 2;_exit_status=$?;echo \"Exit code=$_exit_status\";"); map.put("BE_CMD_TITLE", "Bash Editor DEBUG Session:xyz4722810921592969191.txt"); String result = supportToTest.replaceVariables("bash -c x-terminal-emulator -e bash --login -c '${BE_CMD_CALL}' &", map); assertEquals("bash -c x-terminal-emulator -e bash --login -c 'cd /tmp;./xyz4722810921592969191.txt -a 1 -b 2;_exit_status=$?;echo \"Exit code=$_exit_status\";' &",result); }
public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
@Test public void variables_are_replaced_unkonwn_is_kept2() { Map<String, String> map = new HashMap<>(); map.put("xxx", "123456"); map.put("yyy", "abcdefghijk"); String result = supportToTest.replaceVariables("a '${xxx}' with ${yyy} not ${zzz} a", map); assertEquals("a '123456' with abcdefghijk not ${zzz} a",result); }
public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
@Test public void enable_debugging_starting_with_comment_results_in_firstline_including_temp_debugger_file_and_with_comment_before() throws Exception { String newCode = supportToTest.enableDebugging("#! /bin/mybash","localhost", BashDebugConstants.DEFAULT_DEBUG_PORT); String[] asArray = newCode.split("\n"); assertEquals(1, asArray.length); assertEquals(EXPECTED_DEBUG_ENABLED_CODE+"#! /bin/mybash", asArray[0]); }
public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
@Test public void variables_are_replaced() { Map<String, String> map = new HashMap<>(); map.put("xxx", "123456"); map.put("yyy", "abcdefghijk"); String result = supportToTest.replaceVariables("a '${xxx}' with ${yyy}", map); assertEquals("a '123456' with abcdefghijk",result); }
public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
@Test public void variables_are_replaced2() { Map<String, String> map = new HashMap<>(); map.put("xxx", "123456"); map.put("yyy", "abcdefghijk"); String result = supportToTest.replaceVariables("a '${xxx}' with ${yyy},", map); assertEquals("a '123456' with abcdefghijk,",result); }
public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
@Test public void variables_are_replaced_unkonwn_is_kept() { Map<String, String> map = new HashMap<>(); map.put("xxx", "123456"); map.put("yyy", "abcdefghijk"); String result = supportToTest.replaceVariables("a '${xxx}' with ${yyy} not ${zzz}", map); assertEquals("a '123456' with abcdefghijk not ${zzz}",result); }
public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
@Test public void variables_are_replaced_null_is_shown_as_null() { Map<String, String> map = new HashMap<>(); map.put("xxx", "123456"); map.put("yyy", "abcdefghijk"); map.put("zzz", "null"); String result = supportToTest.replaceVariables("a '${xxx}' with ${yyy} null: ${zzz}", map); assertEquals("a '123456' with abcdefghijk null: null",result); }
public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
CommandStringVariableReplaceSupport { public String replaceVariables(String commandLineWithVariables, Map<String,String> mapping) { if (mapping==null) { return commandLineWithVariables; } String result = ""+commandLineWithVariables; for (String key: mapping.keySet()) { String replace = mapping.get(key); if (replace==null) { continue; } String search = buildSearchString(key); int length = search.length(); int index = -1; while ( (index = result.indexOf(search))!=-1) { StringBuilder sb = new StringBuilder(); sb.append(result.substring(0,index)); sb.append(replace); int indexAfterReplace = index+length; if (result.length()>indexAfterReplace) { sb.append(result.substring(indexAfterReplace)); } result = sb.toString(); }; } return result; } String replaceVariables(String commandLineWithVariables, Map<String,String> mapping); }
@Test public void null_results_in_empty_string() { assertEquals("", toTest.build(null)); }
public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } String build(TerminalLaunchContext context); }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } String build(TerminalLaunchContext context); }
@Test public void context_1() { assertTrue(toTest.build(context).contains("./null;_exit_status=$?;echo \"Exit code=$_exit_status\";")); }
public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } String build(TerminalLaunchContext context); }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } String build(TerminalLaunchContext context); }
@Test public void context_2() { context.file=null; context.terminalCommand="terminalCommand"; context.waitAlways=true; context.waitOnErrors=true; assertTrue(toTest.build(context).contains("cd null;./null;_exit_status=$?;echo \"Exit code=$_exit_status\";read -p \"Press enter to continue...\"")); }
public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } String build(TerminalLaunchContext context); }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } String build(TerminalLaunchContext context); }
@Test public void context_3() throws IOException { context.file=Files.createTempFile("test", ".txt").toFile(); context.terminalCommand="terminalCommand"; context.waitAlways=true; context.waitOnErrors=true; context.params=null; String path = OSUtil.toUnixPath(context.file.getParentFile().toPath().toRealPath().toAbsolutePath().toString()); String name = context.file.getName(); String result = toTest.build(context); String contained ="cd "+path+";./"+name+";_exit_status=$?;echo \"Exit code=$_exit_status\";read -p \"Press enter to continue...\""; if (!result.contains(contained)){ assertEquals("Not contained:\n"+contained,result); } }
public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } String build(TerminalLaunchContext context); }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } String build(TerminalLaunchContext context); }
@Test public void context_4() throws IOException { context.file=Files.createTempFile("test", ".txt").toFile(); context.terminalCommand="terminalCommand"; context.waitAlways=true; context.waitOnErrors=true; context.params="-a 1 -b 2"; String path = OSUtil.toUnixPath(context.file.getParentFile().toPath().toRealPath().toAbsolutePath().toString()); String name = context.file.getName(); assertTrue(toTest.build(context).contains("cd "+path+";./"+name+" -a 1 -b 2;_exit_status=$?;echo \"Exit code=$_exit_status\";read -p \"Press enter to continue...\"")); }
public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } String build(TerminalLaunchContext context); }
InternalTerminalCommandStringBuilder { public String build(TerminalLaunchContext context) { if (context == null) { return ""; } StringBuilder sb = new StringBuilder(); sb.append(bashPIDFileSupport.buildWritePIDToPortSpecificTmpFileSnippet(context.getPort())); sb.append("cd "); sb.append(context.getUnixStyledWorkingDir()); sb.append(";"); String fileName = null; if (context.file != null) { fileName = context.file.getName(); } sb.append("./" + fileName); if (context.params != null) { sb.append(" "); sb.append(context.params); } sb.append(";"); sb.append("_exit_status=$?;"); sb.append("echo \"Exit code=$_exit_status\""); sb.append(";"); if (context.waitAlways) { sb.append("read -p \"Press enter to continue...\""); } else if (context.waitOnErrors) { sb.append( "if [ $_exit_status -ne 0 ]; then read -p \"Unexpected exit code:$_exit_status , press enter to continue\";fi"); } return sb.toString(); } String build(TerminalLaunchContext context); }
@Test public void test_matching() { assertTrue(matcherToTest.isMatching(null)); assertTrue(matcherToTest.isMatching("")); assertTrue(matcherToTest.isMatching("bash")); assertTrue(matcherToTest.isMatching("sh")); assertTrue(matcherToTest.isMatching(".bash")); assertTrue(matcherToTest.isMatching(".sh")); assertTrue(matcherToTest.isMatching(".bash",true)); }
public boolean isMatching(String fileExtension) { return isMatching(fileExtension,true); }
BashFileExtensionMatcher { public boolean isMatching(String fileExtension) { return isMatching(fileExtension,true); } }
BashFileExtensionMatcher { public boolean isMatching(String fileExtension) { return isMatching(fileExtension,true); } }
BashFileExtensionMatcher { public boolean isMatching(String fileExtension) { return isMatching(fileExtension,true); } boolean isMatching(String fileExtension); boolean isMatching(String fileExtension, boolean removePoint); }
BashFileExtensionMatcher { public boolean isMatching(String fileExtension) { return isMatching(fileExtension,true); } boolean isMatching(String fileExtension); boolean isMatching(String fileExtension, boolean removePoint); }
@Test public void enable_debugging_starting_with_not_comment_but_code_results_in_firstline_including_temp_debugger_file_and_new_line_with_command_before() throws Exception { String newCode = supportToTest.enableDebugging("echo alpha","localhost", BashDebugConstants.DEFAULT_DEBUG_PORT); String[] asArray = newCode.split("\n"); assertEquals(2, asArray.length); assertEquals(EXPECTED_DEBUG_ENABLED_CODE, asArray[0]); assertEquals("echo alpha", asArray[1]); }
public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
@Test public void test_not_matching() { assertFalse(matcherToTest.isMatching(".ash")); assertFalse(matcherToTest.isMatching(".")); assertFalse(matcherToTest.isMatching("hash")); assertFalse(matcherToTest.isMatching(".bashi")); assertFalse(matcherToTest.isMatching(".she")); assertFalse(matcherToTest.isMatching(".bash",false)); assertFalse(matcherToTest.isMatching(".bash",false)); }
public boolean isMatching(String fileExtension) { return isMatching(fileExtension,true); }
BashFileExtensionMatcher { public boolean isMatching(String fileExtension) { return isMatching(fileExtension,true); } }
BashFileExtensionMatcher { public boolean isMatching(String fileExtension) { return isMatching(fileExtension,true); } }
BashFileExtensionMatcher { public boolean isMatching(String fileExtension) { return isMatching(fileExtension,true); } boolean isMatching(String fileExtension); boolean isMatching(String fileExtension, boolean removePoint); }
BashFileExtensionMatcher { public boolean isMatching(String fileExtension) { return isMatching(fileExtension,true); } boolean isMatching(String fileExtension); boolean isMatching(String fileExtension, boolean removePoint); }
@Test public void bugfix_196_inside_heredoc_something_looking_like_a_function_is_not_a_function() throws Exception{ String testScript = "cat << -EOT\n" + "st.getval();\n" + "-EOT"; BashScriptModel bashScriptModel = builderToTest.build(testScript); assertThat(bashScriptModel). hasNoErrors(). hasNoFunctions(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void an_empty_script_has_novariables() throws Exception{ String script = ""; BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel). hasNoErrors(). hasNoVariables(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void bugfix_115_one_function_with_keyword_and_name_but__space_in_brackets_is_recognized() throws Exception { String script = "function deploy ( ) {\n\n}"; BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel). hasFunction("deploy").and(). hasFunctions(1). hasNoErrors(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void bugfix_116_one_function_with_keyword_and_name_but__space_in_brackets_is_recognized() throws Exception { String script = "function test ( ) {\n\n}"; BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel). hasFunction("test").and(). hasFunctions(1); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void bugfix_116_one_function_with_name_only_but__space_in_brackets_is_recognized() throws Exception { String script = "test ( ) {\n\n}"; BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel). hasFunction("test").and(). hasFunctions(1); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void bugfix_116_functions_with_spaces_in_brackets_are_recognized_as_well() throws Exception { String script = TestScriptLoader.loadScriptFromTestScripts("bugfix_116.sh"); BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel). hasFunction("warn").and(). hasFunction("die").and(). hasFunction("other").and(). hasFunctions(3); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void has_no_debugtoken_list__when_debug_is_turned_off_means_default() throws Exception { String script = "a b"; BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel).hasNoDebugTokens(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void bugfix_52_$x_followed_by_comment_line_with_if_results_in_no_error() throws Exception { String script = "a=$x\n# check if the host is pingable"; BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel).hasErrors(0); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void bugfix_47_no_longer_errors_for_file() throws Exception { String script = TestScriptLoader.loadScriptFromTestScripts("bugfix_47.sh"); BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel).hasErrors(0); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void when_source_already_in_first_line_we_ignore_it() throws Exception { String origin = "source scriptHome/.basheditor/remote-debugging-v2.sh localhost 33333 #BASHEDITOR-TMP-REMOTE-DEBUGGING-END|Origin line:\nbla..."; assertEquals(origin, supportToTest.enableDebugging(origin,"localhost",33333)); }
public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
@Test public void bugfix_46_no_longer_errors_for_file() throws Exception { String script = TestScriptLoader.loadScriptFromTestScripts("bugfix_46.sh"); BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel).hasErrors(0); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void bugfix_41_1_handle_arrays() throws Exception { String script = TestScriptLoader.loadScriptFromTestScripts("bugfix_41_1.sh"); BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel).hasErrors(0); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void bugfix_41_2_handle_arrays() throws Exception { String script = TestScriptLoader.loadScriptFromTestScripts("bugfix_41_2.sh"); BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel).hasErrors(0); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void bugfix_41_3_handle_arrays_simplified() throws Exception { String script = TestScriptLoader.loadScriptFromTestScripts("bugfix_41_3.sh"); BashScriptModel bashScriptModel = builderToTest.build(script); assertThat(bashScriptModel).hasErrors(0); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void bugfix_39__variable_with_hash_do_not_result_errors() throws Exception { String code = "declare -A TitleMap\nif [ ${#TitleMap[*]} -eq 0 ]\nthen\n displayerr \"Map is empty\"\n exit 1\nfi"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasErrors(0); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void function_a_open_bracket_open_bracket_close_bracket_has_error() throws Exception { String code = "function a {{}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunction("a").and().hasErrors(1); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void usage_space_x_msg_space_y_fatal_space_z() throws Exception { String code = "Usage () {x} Msg () {y} Fatal () {z}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunction("Usage").and().hasFunction("Msg").and().hasFunction("Fatal").and().hasFunctions(3); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void usage_x_msg_y_fatal_z() throws Exception { String code = "Usage() {x} Msg() {y} Fatal() {z}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunction("Usage").and().hasFunction("Msg").and().hasFunction("Fatal").and().hasFunctions(3); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void semicolon_function_xy_is_recognized_as_function_xy() throws Exception { String code = ";function xy{}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunctions(1).hasFunction("xy").and().hasNoErrors(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void method_Usage_space_open_close_brackets__is_recognized_as_function_Usage() throws Exception { String code = "Usage () {}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunctions(1).hasFunction("Usage"); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void enable_debugging_will_automatically_create_debug_bash_code_file_which_contains_data_of_code_builder() throws Exception { File file = new File(infoProvider.getSystemUserHomePath(),"/.basheditor/remote-debugging-v2.sh"); if (file.exists()) { file.delete(); } assertFalse(file.exists()); String sourceCode = ""; supportToTest.enableDebugging(sourceCode,"localhost",BashDebugConstants.DEFAULT_DEBUG_PORT); assertTrue(file.exists()); BashDebugCodeBuilder codeBuilder = new BashDebugCodeBuilder(); String expected = codeBuilder.buildDebugBashCodeSnippet(); String contentOfFile = TestScriptLoader.loadScript(file); assertEquals(expected, contentOfFile); }
public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
DebugBashCodeToggleSupport { public String enableDebugging(String sourceCode, String hostname, int port) throws IOException { bashPIDSnippetSupport.ensureKillOldTerminalFileExistsInSystemUserHome(); bashPIDSnippetSupport.ensureStoreTerminalPIDFileExistsInSystemUserHome(); ensureDebugFileExistsInSystemUserHome(); String nSourceCode= disableDebugging(sourceCode); StringBuilder sb = new StringBuilder(); sb.append(createSourceToInclude(infoProvider.getResultingScriptPathToUserHome())).append(" ").append(hostname).append(" ").append(port).append(" "); sb.append(DEBUG_POSTFIX); if (!nSourceCode.startsWith("#!")) { sb.append("\n"); } sb.append(nSourceCode); return sb.toString(); } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
@Test public void space_semicolon_function_xy_is_recognized_as_function_xy() throws Exception { String code = " ;function xy{}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunctions(1).hasFunction("xy").and().hasNoErrors(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void space_semicolon_space_function_xy_is_recognized_as_function_xy() throws Exception { String code = " ; function xy{}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunctions(1).hasFunction("xy").and().hasNoErrors(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void semicolon_space_function_xy_is_recognized_as_function_xy() throws Exception { String code = "; function xy{}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunctions(1).hasFunction("xy").and().hasNoErrors(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void a_comments_with_function_is_not_handled_as_function() throws Exception { String code = "#\n# this function displays...\nfunction display {\n}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunction("display").and().hasFunctions(1).and().hasNoErrors(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void function_f1_has_only_open_bracket__must_have_no_function_but_two_error() throws Exception { String code = "function f1(){"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasNoFunctions().hasErrors(2); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void function_f1_containing_illegal_child_function_f1b__followed_by_function_f2__results_in_functions_f1_f2__only() throws Exception { String code = "function f1(){function f1b() {}} function f2 {}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunctions(2).hasFunction("f1").and().hasFunction("f2").and().hasNoFunction("f1b"); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void function_xyz_no_curly_brackets_is_not_recognized_as_function_and_has_an_error() throws Exception { String code = "function xy"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasNoFunctions().hasErrors(1); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void function_read_hyphen_file__curlyBrackets_open_close__is_recognized_as_function_read_hyphen_file__and_has_no_errors() throws Exception { String code = "function read-file{}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunctions(1).hasFunction("read-file").and().hasNoErrors(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void function_read_hyphen_file_curlyBraceOpen_NewLine__content_NewLine_curlybraceClose_is_recognized_as_function_read_hyphen_file() throws Exception { String code = "function read-file{\n#something\n}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunctions(1).hasFunction("read-file"); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void function_read_hyphen_file_hypen_format_followed_with_brackets_is_recognized_as_function_read_hyphen_file_hypen_format() throws Exception { String code = "function read-file-format()\n{\n}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunctions(1).hasFunction("read-file-format"); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void disable_debugging_empty_code_results_in_empty_code() throws Exception { assertEquals("", supportToTest.disableDebugging("")); }
public String disableDebugging(String sourceCode) throws IOException { int index = sourceCode.indexOf(DEBUG_POSTFIX); if (index == -1) { return sourceCode; } int pos = index + DEBUG_POSTFIX.length(); String data = sourceCode.substring(pos); if (data.startsWith("\n")) { data=data.substring(1); } return data; }
DebugBashCodeToggleSupport { public String disableDebugging(String sourceCode) throws IOException { int index = sourceCode.indexOf(DEBUG_POSTFIX); if (index == -1) { return sourceCode; } int pos = index + DEBUG_POSTFIX.length(); String data = sourceCode.substring(pos); if (data.startsWith("\n")) { data=data.substring(1); } return data; } }
DebugBashCodeToggleSupport { public String disableDebugging(String sourceCode) throws IOException { int index = sourceCode.indexOf(DEBUG_POSTFIX); if (index == -1) { return sourceCode; } int pos = index + DEBUG_POSTFIX.length(); String data = sourceCode.substring(pos); if (data.startsWith("\n")) { data=data.substring(1); } return data; } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); }
DebugBashCodeToggleSupport { public String disableDebugging(String sourceCode) throws IOException { int index = sourceCode.indexOf(DEBUG_POSTFIX); if (index == -1) { return sourceCode; } int pos = index + DEBUG_POSTFIX.length(); String data = sourceCode.substring(pos); if (data.startsWith("\n")) { data=data.substring(1); } return data; } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
DebugBashCodeToggleSupport { public String disableDebugging(String sourceCode) throws IOException { int index = sourceCode.indexOf(DEBUG_POSTFIX); if (index == -1) { return sourceCode; } int pos = index + DEBUG_POSTFIX.length(); String data = sourceCode.substring(pos); if (data.startsWith("\n")) { data=data.substring(1); } return data; } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
@Test public void function_read_hyphen_file_hypen_format_space_followed_with_brackets_is_recognized_as_function_read_hyphen_file_hypen_format() throws Exception { String code = "function read-file-format (){}"; BashScriptModel bashScriptModel = builderToTest.build(code); assertThat(bashScriptModel).hasFunctions(1).hasFunction("read-file-format"); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void an_empty_line_returns_not_null_AST() throws Exception { BashScriptModel bashScriptModel = builderToTest.build(""); assertNotNull(bashScriptModel); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void a_line_with_Xfunction_test_is_NOT_recognized() throws Exception { BashScriptModel bashScriptModel = builderToTest.build("Xfunction test {}"); assertThat(bashScriptModel).hasNoFunctions(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void a_line_with_method_having_underscores_is_correct_parsed() throws Exception { BashScriptModel bashScriptModel = builderToTest.build("function show_something_else{}"); assertThat(bashScriptModel).hasFunctions(1).hasFunction("show_something_else"); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void a_line_with_function_test_is_recognized_and_returns_function_with_name_test() throws Exception { BashScriptModel bashScriptModel = builderToTest.build("function test {}"); assertThat(bashScriptModel).hasFunctions(1).hasFunction("test"); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void two_lines_with_functions_test1_and_test2_are_recognized_and_returns_2_function_with_name_test1_and_teset2() throws Exception { BashScriptModel bashScriptModel = builderToTest .build("function test1 {\n#something\n}\n #other line\n\nfunction test2 {\n#something else\n}\n"); assertThat(bashScriptModel).hasFunction("test1").and().hasFunction("test2").and().hasFunctions(2); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void two_lines_with_functions_test1_and_test2_are_recognized_and_returns_2_function_with_name_test1_and_teset2__but_with_backslash_r() throws Exception { String bashScript = "function test1 {\n#something\n}\n #other line\n\nfunction test2 {\r\n#something else\r\n}\r\n"; BashScriptModel bashScriptModel = builderToTest.build(bashScript); assertThat(bashScriptModel).hasNoErrors().hasFunction("test1").and().hasFunction("test2").and().hasFunctions(2); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void a_line_with_function_test_is_recognized_and_returns_function_with_pos_0_and_has_no_errors() throws Exception { BashScriptModel bashScriptModel = builderToTest.build("function test {}"); assertNotNull(bashScriptModel); assertThat(bashScriptModel).hasFunctions(1).hasFunctionWithPosition("test", 0).and().hasNoErrors(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void a_line_with_function_test_is_recognized_and_returns_function_with_pos_1_when_first_line_empty() throws Exception { BashScriptModel bashScriptModel = builderToTest.build("\nfunction test {}"); assertThat(bashScriptModel).hasFunctions(1).hasFunctionWithPosition("test", 1); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void a_line_with_5_spaces_and_function_test_is_recognized_and_returns_function_with_pos_5() throws Exception { BashScriptModel bashScriptModel = builderToTest.build(" function test {}"); assertThat(bashScriptModel).hasFunctions(1).hasFunctionWithPosition("test", 5); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void disable_debugging_first_line_has_include_but_nothing_else_results_in_empty_code() throws Exception { assertEquals("", supportToTest.disableDebugging(EXPECTED_DEBUG_ENABLED_CODE+"\n")); }
public String disableDebugging(String sourceCode) throws IOException { int index = sourceCode.indexOf(DEBUG_POSTFIX); if (index == -1) { return sourceCode; } int pos = index + DEBUG_POSTFIX.length(); String data = sourceCode.substring(pos); if (data.startsWith("\n")) { data=data.substring(1); } return data; }
DebugBashCodeToggleSupport { public String disableDebugging(String sourceCode) throws IOException { int index = sourceCode.indexOf(DEBUG_POSTFIX); if (index == -1) { return sourceCode; } int pos = index + DEBUG_POSTFIX.length(); String data = sourceCode.substring(pos); if (data.startsWith("\n")) { data=data.substring(1); } return data; } }
DebugBashCodeToggleSupport { public String disableDebugging(String sourceCode) throws IOException { int index = sourceCode.indexOf(DEBUG_POSTFIX); if (index == -1) { return sourceCode; } int pos = index + DEBUG_POSTFIX.length(); String data = sourceCode.substring(pos); if (data.startsWith("\n")) { data=data.substring(1); } return data; } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); }
DebugBashCodeToggleSupport { public String disableDebugging(String sourceCode) throws IOException { int index = sourceCode.indexOf(DEBUG_POSTFIX); if (index == -1) { return sourceCode; } int pos = index + DEBUG_POSTFIX.length(); String data = sourceCode.substring(pos); if (data.startsWith("\n")) { data=data.substring(1); } return data; } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
DebugBashCodeToggleSupport { public String disableDebugging(String sourceCode) throws IOException { int index = sourceCode.indexOf(DEBUG_POSTFIX); if (index == -1) { return sourceCode; } int pos = index + DEBUG_POSTFIX.length(); String data = sourceCode.substring(pos); if (data.startsWith("\n")) { data=data.substring(1); } return data; } DebugBashCodeToggleSupport(BashDebugInfoProvider infoProvider); String enableDebugging(String sourceCode, String hostname, int port); String disableDebugging(String sourceCode); }
@Test public void a_line_with_5_spaces_and_Xfunction_test_is_NOT_recognized() throws Exception { BashScriptModel bashScriptModel = builderToTest.build(" Xfunction test {}"); assertThat(bashScriptModel).hasNoFunctions(); }
public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
BashScriptModelBuilder { public BashScriptModel build(String bashScript) throws BashScriptModelException { BashScriptModel model = new BashScriptModel(); TokenParser parser = new TokenParser(); List<ParseToken> tokens; try { tokens = parser.parse(bashScript); } catch (TokenParserException e) { throw new BashScriptModelException("Was not able to build bashscript", e); } buildScriptVariablesByTokens(model,false,true, tokens); buildFunctionsByTokens(model, tokens); List<ValidationResult> results = new ArrayList<>(); for (BashScriptValidator<List<ParseToken>> validator : createParseTokenValidators()) { results.addAll(validator.validate(tokens)); } for (ValidationResult result : results) { if (result instanceof BashError) { model.errors.add((BashError) result); } } if (debugMode) { appendDebugTokens(model, tokens); } return model; } BashScriptModel build(String bashScript); void setIgnoreBlockValidation(boolean ignoreBlockValidation); void setIgnoreVariables(boolean ignoreVariables); void setIgnoreDoValidation(boolean ignoreDoValidation); void setIgnoreIfValidation(boolean ignoreIfValidation); void setIgnoreFunctionValidation(boolean ignoreFunctionValidation); void setDebug(boolean debugMode); }
@Test public void has_errors_returns_false_when_no_error_is_added() { assertFalse(modelToTest.hasErrors()); }
public boolean hasErrors() { return !getErrors().isEmpty(); }
BashScriptModel implements BashVariableRegistry { public boolean hasErrors() { return !getErrors().isEmpty(); } }
BashScriptModel implements BashVariableRegistry { public boolean hasErrors() { return !getErrors().isEmpty(); } }
BashScriptModel implements BashVariableRegistry { public boolean hasErrors() { return !getErrors().isEmpty(); } Collection<BashFunction> getFunctions(); Collection<BashError> getErrors(); boolean hasErrors(); List<ParseToken> getDebugTokens(); boolean hasDebugTokens(); Map<String, BashVariable> getVariables(); BashVariable getVariable(String varName); BashFunction findBashFunctionByName(String name); }
BashScriptModel implements BashVariableRegistry { public boolean hasErrors() { return !getErrors().isEmpty(); } Collection<BashFunction> getFunctions(); Collection<BashError> getErrors(); boolean hasErrors(); List<ParseToken> getDebugTokens(); boolean hasDebugTokens(); Map<String, BashVariable> getVariables(); BashVariable getVariable(String varName); BashFunction findBashFunctionByName(String name); }
@Test public void token_var_starting_with_underscore_is_var() { assertTrue(new ParseToken("_XYZ=").isVariableDefinition()); }
public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
@Test public void token_var_ending_with_underscore_is_var() { assertTrue(new ParseToken("XYZ_=").isVariableDefinition()); }
public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
@Test public void token_var1_equal_is_var() { assertTrue(new ParseToken("var1=").isVariableDefinition()); }
public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
@Test public void token_XYZ_equal_is_var() { assertTrue(new ParseToken("XYZ=").isVariableDefinition()); }
public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isVariableDefinition() { String t = getSafeText(); boolean isVariable = t.endsWith("="); isVariable = isVariable && t.length()>1; isVariable = isVariable && VALID_VARIABLE_NAME_PATTERN.matcher(t).matches(); return isVariable; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
@Test public void token_do_is_do() { assertTrue(new ParseToken("do").isDo()); }
public boolean isDo() { return getSafeText().equals("do"); }
ParseToken { public boolean isDo() { return getSafeText().equals("do"); } }
ParseToken { public boolean isDo() { return getSafeText().equals("do"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isDo() { return getSafeText().equals("do"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isDo() { return getSafeText().equals("do"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
@Test public void token_done_is_done() { assertTrue(new ParseToken("done").isDone()); }
public boolean isDone() { return getSafeText().equals("done"); }
ParseToken { public boolean isDone() { return getSafeText().equals("done"); } }
ParseToken { public boolean isDone() { return getSafeText().equals("done"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isDone() { return getSafeText().equals("done"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isDone() { return getSafeText().equals("done"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
@Test public void token_if_is_if() { assertTrue(new ParseToken("if").isIf()); }
public boolean isIf() { return getSafeText().equals("if"); }
ParseToken { public boolean isIf() { return getSafeText().equals("if"); } }
ParseToken { public boolean isIf() { return getSafeText().equals("if"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isIf() { return getSafeText().equals("if"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isIf() { return getSafeText().equals("if"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
@Test public void token_fi_is_fi() { assertTrue(new ParseToken("fi").isFi()); }
public boolean isFi() { return getSafeText().equals("fi"); }
ParseToken { public boolean isFi() { return getSafeText().equals("fi"); } }
ParseToken { public boolean isFi() { return getSafeText().equals("fi"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); }
ParseToken { public boolean isFi() { return getSafeText().equals("fi"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }
ParseToken { public boolean isFi() { return getSafeText().equals("fi"); } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); String getText(); int getStart(); int getEnd(); @Override String toString(); String createTypeDescription(); boolean isComment(); boolean isSingleString(); boolean isDoubleString(); boolean isDoubleTickedString(); boolean isString(); boolean isFunctionKeyword(); boolean isFunction(); boolean isLegalFunctionName(); boolean endsWithFunctionBrackets(); boolean isFunctionStartBracket(); boolean isFunctionEndBracket(); boolean hasLength(int length); String getTextAsFunctionName(); String getTextAsVariableName(); boolean isOpenBlock(); boolean isCloseBlock(); boolean isVariableDefinition(); boolean isDo(); boolean isDone(); boolean isIf(); boolean isFi(); boolean isHereDoc(); boolean isHereString(); boolean isCase(); boolean isEsac(); boolean isLocalDef(); }