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 xyz_followed_by_open_and_close_bracket_is_functionName() { assertTrue(new ParseToken("xyz()").isFunction()); } | public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } | ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } } | ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); } | ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } 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 isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } 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 only_open_and_close_bracket_is_NOT_functionName() { assertFalse(new ParseToken("()").isFunction()); } | public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } | ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } } | ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); } | ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } 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 isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } 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 function_params_equal_open_and_close_bracket_is_NOT_functionName() { assertFalse(new ParseToken("params=()").isFunction()); } | public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } | ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } } | ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); } | ParseToken { public boolean isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } 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 isFunction() { boolean isFunctionName = endsWithFunctionBrackets(); isFunctionName = isFunctionName && isLegalFunctionName(); isFunctionName = isFunctionName && !isComment(); isFunctionName = isFunctionName && text.length() > 2; isFunctionName = isFunctionName && !isString(); return isFunctionName; } 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 xyz_getTextAsFunctionName_returns_xyz() { assertEquals("xyz", new ParseToken("xyz").getTextAsFunctionName()); } | public String getTextAsFunctionName() { if (getSafeText().endsWith("()")) { return text.substring(0, text.length() - 2); } return text; } | ParseToken { public String getTextAsFunctionName() { if (getSafeText().endsWith("()")) { return text.substring(0, text.length() - 2); } return text; } } | ParseToken { public String getTextAsFunctionName() { if (getSafeText().endsWith("()")) { return text.substring(0, text.length() - 2); } return text; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); } | ParseToken { public String getTextAsFunctionName() { if (getSafeText().endsWith("()")) { return text.substring(0, text.length() - 2); } return text; } 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 String getTextAsFunctionName() { if (getSafeText().endsWith("()")) { return text.substring(0, text.length() - 2); } return text; } 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 xyz_open_close_bracketgetTextAsFunctionName_returns_xyz() { assertEquals("xyz", new ParseToken("xyz()").getTextAsFunctionName()); } | public String getTextAsFunctionName() { if (getSafeText().endsWith("()")) { return text.substring(0, text.length() - 2); } return text; } | ParseToken { public String getTextAsFunctionName() { if (getSafeText().endsWith("()")) { return text.substring(0, text.length() - 2); } return text; } } | ParseToken { public String getTextAsFunctionName() { if (getSafeText().endsWith("()")) { return text.substring(0, text.length() - 2); } return text; } ParseToken(); ParseToken(String text); ParseToken(String text, int start, int end); } | ParseToken { public String getTextAsFunctionName() { if (getSafeText().endsWith("()")) { return text.substring(0, text.length() - 2); } return text; } 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 String getTextAsFunctionName() { if (getSafeText().endsWith("()")) { return text.substring(0, text.length() - 2); } return text; } 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 $1_has_start_0_end_2() throws Exception { String string = "$1"; List<ParseToken> tokens = parserToTest.parse(string); ParseToken token = assertThat(tokens).resolveToken("$1"); assertEquals(0, token.getStart()); assertEquals(2, token.getEnd()); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void disable_debugging_first_line_has_include_and_comment_secondline_has_alpha_after_include_only_comment_remains_in_first_line_second_has_alpha() throws Exception { assertEquals("#! /bin/mybash\nalpha", supportToTest.disableDebugging(EXPECTED_DEBUG_ENABLED_CODE + "#! /bin/mybash\nalpha")); } | 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 moveUntilNextCharWillBeNoStringContent_no_string_contend_handled_as_expected() throws Exception { ParseContext context = new ParseContext(); context.chars = "$(tput 'STRING')".toCharArray(); context.pos = 2; parserToTest.moveUntilNextCharWillBeNoStringContent(context); context.moveForward(); parserToTest.moveUntilNextCharWillBeNoStringContent(context); context.moveForward(); parserToTest.moveUntilNextCharWillBeNoStringContent(context); context.moveForward(); parserToTest.moveUntilNextCharWillBeNoStringContent(context); context.moveForward(); assertEquals("tput", context.sb.toString()); parserToTest.moveUntilNextCharWillBeNoStringContent(context); context.moveForward(); assertEquals("tput ", context.sb.toString()); parserToTest.moveUntilNextCharWillBeNoStringContent(context); context.moveForward(); assertEquals("tput 'STRING'", context.sb.toString()); } | void moveUntilNextCharWillBeNoStringContent(ParseContext context) { context.appendCharToText(); char c = context.getCharAtPos(); if (!isStringChar(c)) { return; } if (c=='\'') { }else if (context.isCharBeforeEscapeSign()) { return; } char stringCharToScan = c; moveToNextCharNotInStringAndAppendMovements(context, stringCharToScan); } | TokenParser { void moveUntilNextCharWillBeNoStringContent(ParseContext context) { context.appendCharToText(); char c = context.getCharAtPos(); if (!isStringChar(c)) { return; } if (c=='\'') { }else if (context.isCharBeforeEscapeSign()) { return; } char stringCharToScan = c; moveToNextCharNotInStringAndAppendMovements(context, stringCharToScan); } } | TokenParser { void moveUntilNextCharWillBeNoStringContent(ParseContext context) { context.appendCharToText(); char c = context.getCharAtPos(); if (!isStringChar(c)) { return; } if (c=='\'') { }else if (context.isCharBeforeEscapeSign()) { return; } char stringCharToScan = c; moveToNextCharNotInStringAndAppendMovements(context, stringCharToScan); } TokenParser(); } | TokenParser { void moveUntilNextCharWillBeNoStringContent(ParseContext context) { context.appendCharToText(); char c = context.getCharAtPos(); if (!isStringChar(c)) { return; } if (c=='\'') { }else if (context.isCharBeforeEscapeSign()) { return; } char stringCharToScan = c; moveToNextCharNotInStringAndAppendMovements(context, stringCharToScan); } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { void moveUntilNextCharWillBeNoStringContent(ParseContext context) { context.appendCharToText(); char c = context.getCharAtPos(); if (!isStringChar(c)) { return; } if (c=='\'') { }else if (context.isCharBeforeEscapeSign()) { return; } char stringCharToScan = c; moveToNextCharNotInStringAndAppendMovements(context, stringCharToScan); } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void bugfix_39__a_variable_containing_hash_is_not_recognized_as_comment() throws Exception { String string = "if [ ${#TitleMap[*]} -eq 0 ]"; List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens).containsNotToken("#TitleMap[*]} -eq 0 ]"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void for_abc_10_newlines_x_token_x_has_position_13() throws Exception { String string = "abc\n\n\n\n\n\n\n\n\n\nx"; List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens).token("x").hasStart(13); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void for_a_cariage_return_newline_x__token_x_has_position_3() throws Exception { String string = "a\r\nx"; System.out.println(string); List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens).token("x").hasStart(3); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void for_ab_cariage_return_newline_x__token_x_has_position_4() throws Exception { String string = "ab\r\nx"; System.out.println(string); List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens).token("x").hasStart(4); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void for_ab_cariage_return_newline_cariage_return_newline_x__token_x_has_position_4() throws Exception { String string = "ab\r\n\r\nx"; System.out.println(string); List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens).token("x").hasStart(6); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void for_abc_10_cariage_return_newlines_x_token_x_has_position_13() throws Exception { String string = "abc\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\nx"; System.out.println(string); List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens).token("x").hasStart(23); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void for_abc__token_abc_has_pos_0() throws Exception { String string = "abc"; List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens).token("abc").hasStart(0); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void for_abc__token_abc_has_end_2() throws Exception { String string = "abc"; List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens).token("abc").hasEnd(3); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void for_space_abc__token_abc_has_pos_1() throws Exception { String string = " abc"; List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens).token("abc").hasStart(1); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void disable_debugging_first_line_has_include_and_second_an_echo_alpha_result_first_line_will_be_echo_alpha() throws Exception { assertEquals("echo alpha", supportToTest.disableDebugging(EXPECTED_DEBUG_ENABLED_CODE + "\necho alpha")); } | 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 for_space_abc__token_abc_has_end_3() throws Exception { String string = " abc"; List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens).token("abc").hasEnd(4); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void do_x_do_y_done() throws Exception { String string = "do\nx\ndo\ny\ndone"; List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens).containsToken("do", 2).containsOneToken("x").containsOneToken("y").containsOneToken("done"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void do_x_done_do_y_done_do_done_done_do() throws Exception { String string = "do\nx\ndone\ndo\ny\ndone\n\ndo\ndone\ndone\ndo\n\n"; List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens). containsTokens("do","x","done","do","y","done","do","done","done","do"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void do_x_done_do_y_done_do_done_done_do__with_backslash_r_inside() throws Exception { String string = "do\nx\ndone\ndo\r\ny\ndone\n\ndo\ndone\ndone\ndo\n\n"; List<ParseToken> tokens = parserToTest.parse(string); assertThat(tokens). containsTokens("do","x","done","do","y","done","do","done","done","do"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void a_simple_string_containing_space_do_space_does_not_result_in_a_token_do() throws Exception { List<ParseToken> tokens = parserToTest.parse("' do '"); assertThat(tokens).containsNotToken("do"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void a_double_string_containing_space_do_space_does_not_result_in_a_token_do() throws Exception { List<ParseToken> tokens = parserToTest.parse("\" do \""); assertThat(tokens).containsNotToken("do"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void a_double_ticked_string_containing_space_do_space_does_not_result_in_a_token_do() throws Exception { List<ParseToken> tokens = parserToTest.parse("` do `"); assertThat(tokens).containsNotToken("do"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void a_double_ticked_do_string_followed_by_space_and_do_does_result_in_do_token() throws Exception { List<ParseToken> tokens = parserToTest.parse("`do` do `"); assertThat(tokens).containsOneToken("do"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void a_double_ticked_do_string_followed_by_space_and_ESCAPE_and_do_does_result_in_NO_do_token() throws Exception { List<ParseToken> tokens = parserToTest.parse("`do\\` do `"); assertThat(tokens).containsNotToken("do"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void a_single_do_string_followed_by_space_and_ESCAPE_and_do_does_result_in_do_token() throws Exception { List<ParseToken> tokens = parserToTest.parse("'do\\' do '"); assertThat(tokens).containsOneToken("do"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void buildKillPIDSnippet() throws IOException { String expectedSnippet= "cd ~/.basheditor\n" + "KILL_TEXTFILE=\"./PID_debug-terminal_port_$1.txt\"\n" + "if [ -f \"$KILL_TEXTFILE\" ]; then\n" + " while IFS='' read -r LINE || [ -n \"${LINE}\" ]; do\n" + " kill -9 ${LINE}\n" + " done < $KILL_TEXTFILE;\n" + " \n" + " rm \"$KILL_TEXTFILE\"\n" + "else \n" + " echo \"No file found :$KILL_TEXTFILE inside pwd=$PWD\"\n" + "fi\n" + "";; assertEquals(expectedSnippet, snippetSupportToTest.buildKillOldTerminalsSnippet()); } | public String buildKillOldTerminalsSnippet() { String code= "cd ~/.basheditor\n" + "KILL_TEXTFILE=\"./PID_debug-terminal_port_$1.txt\"\n" + "if [ -f \"$KILL_TEXTFILE\" ]; then\n" + " while IFS='' read -r LINE || [ -n \"${LINE}\" ]; do\n" + " kill -9 ${LINE}\n" + " done < $KILL_TEXTFILE;\n" + " \n" + " rm \"$KILL_TEXTFILE\"\n" + "else \n" + " echo \"No file found :$KILL_TEXTFILE inside pwd=$PWD\"\n" + "fi\n" + ""; return code; } | BashPIDSnippetSupport { public String buildKillOldTerminalsSnippet() { String code= "cd ~/.basheditor\n" + "KILL_TEXTFILE=\"./PID_debug-terminal_port_$1.txt\"\n" + "if [ -f \"$KILL_TEXTFILE\" ]; then\n" + " while IFS='' read -r LINE || [ -n \"${LINE}\" ]; do\n" + " kill -9 ${LINE}\n" + " done < $KILL_TEXTFILE;\n" + " \n" + " rm \"$KILL_TEXTFILE\"\n" + "else \n" + " echo \"No file found :$KILL_TEXTFILE inside pwd=$PWD\"\n" + "fi\n" + ""; return code; } } | BashPIDSnippetSupport { public String buildKillOldTerminalsSnippet() { String code= "cd ~/.basheditor\n" + "KILL_TEXTFILE=\"./PID_debug-terminal_port_$1.txt\"\n" + "if [ -f \"$KILL_TEXTFILE\" ]; then\n" + " while IFS='' read -r LINE || [ -n \"${LINE}\" ]; do\n" + " kill -9 ${LINE}\n" + " done < $KILL_TEXTFILE;\n" + " \n" + " rm \"$KILL_TEXTFILE\"\n" + "else \n" + " echo \"No file found :$KILL_TEXTFILE inside pwd=$PWD\"\n" + "fi\n" + ""; return code; } BashPIDSnippetSupport(BashDebugInfoProvider infoProvider); } | BashPIDSnippetSupport { public String buildKillOldTerminalsSnippet() { String code= "cd ~/.basheditor\n" + "KILL_TEXTFILE=\"./PID_debug-terminal_port_$1.txt\"\n" + "if [ -f \"$KILL_TEXTFILE\" ]; then\n" + " while IFS='' read -r LINE || [ -n \"${LINE}\" ]; do\n" + " kill -9 ${LINE}\n" + " done < $KILL_TEXTFILE;\n" + " \n" + " rm \"$KILL_TEXTFILE\"\n" + "else \n" + " echo \"No file found :$KILL_TEXTFILE inside pwd=$PWD\"\n" + "fi\n" + ""; return code; } BashPIDSnippetSupport(BashDebugInfoProvider infoProvider); String buildKillOldTerminalsSnippet(); String buildStoreTerminalPIDSnippet(); String getAbsolutePathToEnsuredKillOldTerminalScript(); String getAbsolutePathToEnsuredStoreTerminalPIDsScript(); File ensureKillOldTerminalFileExistsInSystemUserHome(); File ensureStoreTerminalPIDFileExistsInSystemUserHome(); } | BashPIDSnippetSupport { public String buildKillOldTerminalsSnippet() { String code= "cd ~/.basheditor\n" + "KILL_TEXTFILE=\"./PID_debug-terminal_port_$1.txt\"\n" + "if [ -f \"$KILL_TEXTFILE\" ]; then\n" + " while IFS='' read -r LINE || [ -n \"${LINE}\" ]; do\n" + " kill -9 ${LINE}\n" + " done < $KILL_TEXTFILE;\n" + " \n" + " rm \"$KILL_TEXTFILE\"\n" + "else \n" + " echo \"No file found :$KILL_TEXTFILE inside pwd=$PWD\"\n" + "fi\n" + ""; return code; } BashPIDSnippetSupport(BashDebugInfoProvider infoProvider); String buildKillOldTerminalsSnippet(); String buildStoreTerminalPIDSnippet(); String getAbsolutePathToEnsuredKillOldTerminalScript(); String getAbsolutePathToEnsuredStoreTerminalPIDsScript(); File ensureKillOldTerminalFileExistsInSystemUserHome(); File ensureStoreTerminalPIDFileExistsInSystemUserHome(); static final String FILENAME_STORE_TERMINAL_PIDS_SCRIPT; static final String DEBUGGER_TERMINAL_PID_FILENAME; } |
@Test public void a_double_do_string_followed_by_space_and_ESCAPE_and_do_does_result_in_NO_do_token() throws Exception { List<ParseToken> tokens = parserToTest.parse("\"do\\\" do \""); assertThat(tokens).containsNotToken("do"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void a_double_string_containing_single_string_has_token_with_singlestring_contained() throws Exception { List<ParseToken> tokens = parserToTest.parse("\" This is the 'way' it is \""); assertThat(tokens).containsOneToken("\" This is the 'way' it is \""); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void a_double_string_containing_double_ticked_string_has_token_with_singlestring_contained() throws Exception { List<ParseToken> tokens = parserToTest.parse("\" This is the `way` it is \""); assertThat(tokens).containsOneToken("\" This is the `way` it is \""); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void a_single_string_containing_double_string_has_token_with_singlestring_contained() throws Exception { List<ParseToken> tokens = parserToTest.parse("' This is the \\\"way\\\" it is '"); assertThat(tokens).containsOneToken("' This is the \\\"way\\\" it is '"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void a_single_string_containing_double_ticked_string_has_token_with_singlestring_contained() throws Exception { List<ParseToken> tokens = parserToTest.parse("' This is the `way` it is '"); assertThat(tokens).containsOneToken("' This is the `way` it is '"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void abc_def_ghji_is_parsed_as_three_tokens() throws Exception { List<ParseToken> tokens = parserToTest.parse("abc def ghji"); assertNotNull(tokens); assertEquals(3, tokens.size()); Iterator<ParseToken> it = tokens.iterator(); ParseToken token1 = it.next(); ParseToken token2 = it.next(); ParseToken token3 = it.next(); assertEquals("abc", token1.getText()); assertEquals("def", token2.getText()); assertEquals("ghji", token3.getText()); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void some_spaces_abc_def_ghji_is_parsed_as_three_tokens() throws Exception { List<ParseToken> tokens = parserToTest.parse(" abc def ghji"); assertNotNull(tokens); assertEquals(3, tokens.size()); Iterator<ParseToken> it = tokens.iterator(); ParseToken token1 = it.next(); ParseToken token2 = it.next(); ParseToken token3 = it.next(); assertEquals("abc", token1.getText()); assertEquals("def", token2.getText()); assertEquals("ghji", token3.getText()); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void abc_def_ghji_is_parsed_as_three_tokens__and_correct_positions() throws Exception { List<ParseToken> tokens = parserToTest.parse("abc def ghji"); assertThat(tokens).containsTokens("abc", "def", "ghji"); assertThat(tokens).token("abc").hasStart(0); assertThat(tokens).token("def").hasStart(4); assertThat(tokens).token("ghji").hasStart(8); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void comment1_returns_one_tokens() throws Exception { List<ParseToken> tokens = parserToTest.parse("#comment1"); assertThat(tokens).containsOneToken("#comment1"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void comment1_new_line_returns_one_tokens() throws Exception { List<ParseToken> tokens = parserToTest.parse("#comment1\n"); assertThat(tokens).containsOneToken("#comment1"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void buildPIDForPortPort1234_returns_path_as_tempfolder_debugger_terminal_pid4port_1234_$username$_txt() throws IOException { assertEquals(tmpFolder+"/.basheditor/PID_debug-terminal_port_12345.txt", OSUtil.toUnixPath(builderToTest.buildPIDFileAbsolutePath("12345"))); } | public String buildPIDFileAbsolutePath(String port) { String path = buildPIDFile(port).toPath().toAbsolutePath().toString(); return path; } | BashCallPIDStoreSnippetBuilder { public String buildPIDFileAbsolutePath(String port) { String path = buildPIDFile(port).toPath().toAbsolutePath().toString(); return path; } } | BashCallPIDStoreSnippetBuilder { public String buildPIDFileAbsolutePath(String port) { String path = buildPIDFile(port).toPath().toAbsolutePath().toString(); return path; } BashCallPIDStoreSnippetBuilder(); } | BashCallPIDStoreSnippetBuilder { public String buildPIDFileAbsolutePath(String port) { String path = buildPIDFile(port).toPath().toAbsolutePath().toString(); return path; } BashCallPIDStoreSnippetBuilder(); String buildPIDFileAbsolutePath(String port); String buildPIDParentFolderAbsolutePath(); String buildWritePIDToPortSpecificTmpFileSnippet(int port); } | BashCallPIDStoreSnippetBuilder { public String buildPIDFileAbsolutePath(String port) { String path = buildPIDFile(port).toPath().toAbsolutePath().toString(); return path; } BashCallPIDStoreSnippetBuilder(); String buildPIDFileAbsolutePath(String port); String buildPIDParentFolderAbsolutePath(); String buildWritePIDToPortSpecificTmpFileSnippet(int port); } |
@Test public void comment1_new_line_function_space_name_returns_3_tokens_comment1_function_and_name() throws Exception { List<ParseToken> tokens = parserToTest.parse("#comment1\nfunction name"); assertThat(tokens).containsTokens("#comment1", "function", "name"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void comment1_new_line_function_space_name_directly_followed_by_brackets_returns_3_tokens_comment1_function_and_name() throws Exception { List<ParseToken> tokens = parserToTest.parse("#comment1\nfunction name()"); assertThat(tokens).containsTokens("#comment1", "function", "name()"); } | public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } | TokenParser { public List<ParseToken> parse(String bashScript) throws TokenParserException { if (bashScript == null) { return new ArrayList<>(); } ParseContext context = new ParseContext(); context.chars = bashScript.toCharArray(); try { for (; context.hasValidPos(); context.moveForward()) { if (isIfHandled(context)) { continue; } if (isVariableStateHandled(context)) { continue; } if (isCommentStateHandled(context)) { continue; } if (isStringStateHandled(context)) { continue; } if (isHereStringStateHandled(context)) { continue; } if (isHereDocStateHandled(context)) { continue; } handleNotVariableNorCommentOrString(context); } context.addTokenAndResetText(); } catch (RuntimeException e) { throw new TokenParserException("Was not able to parse script because of runtime error", e); } return context.tokens; } TokenParser(); List<ParseToken> parse(String bashScript); } |
@Test public void a_colon_b_results_in_a_b() { assertEquals(expect("a","b").listExpected, builderToTest.build("a:b")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void comment_results_in_empty_result() { assertEquals(expect().listExpected, builderToTest.build("#")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void comment_alpha_is_reduced_to_alpha() { assertEquals(expect("alpha").listExpected, builderToTest.build("#alpha'")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void single_quote_single_quote_results_in_empty_result() { assertEquals(expect().listExpected, builderToTest.build("''")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void double_quote_double_quote_results_in_empty_result() { assertEquals(expect().listExpected, builderToTest.build("\"\"")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void double_quote_a_double_quote_results_in_a() { assertEquals(expect("a").listExpected, builderToTest.build("\"a\"")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void single_quote_a_single_quote_results_in_a() { assertEquals(expect("a").listExpected, builderToTest.build("'a'")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void double_quote_a_space_b_double_quote_results_in_a_b() { assertEquals(expect("a","b").listExpected, builderToTest.build("\"a b\"")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void buildWritePIDToPortSpecificTmpFileSnippet_generateds_expected_parts() throws IOException { assertEquals("cd \""+tmpFolder+"/.basheditor\";./"+BashPIDSnippetSupport.FILENAME_STORE_TERMINAL_PIDS_SCRIPT+" 12345 $$;", builderToTest.buildWritePIDToPortSpecificTmpFileSnippet(12345)); } | public String buildWritePIDToPortSpecificTmpFileSnippet(int port) { StringBuilder sb = new StringBuilder(); sb.append("cd \"").append(OSUtil.toUnixPath(buildPIDParentFolderAbsolutePath())).append("\";"); sb.append("./").append(BashPIDSnippetSupport.FILENAME_STORE_TERMINAL_PIDS_SCRIPT); sb.append(" ").append(port); sb.append(" $$"); sb.append(";"); return sb.toString(); } | BashCallPIDStoreSnippetBuilder { public String buildWritePIDToPortSpecificTmpFileSnippet(int port) { StringBuilder sb = new StringBuilder(); sb.append("cd \"").append(OSUtil.toUnixPath(buildPIDParentFolderAbsolutePath())).append("\";"); sb.append("./").append(BashPIDSnippetSupport.FILENAME_STORE_TERMINAL_PIDS_SCRIPT); sb.append(" ").append(port); sb.append(" $$"); sb.append(";"); return sb.toString(); } } | BashCallPIDStoreSnippetBuilder { public String buildWritePIDToPortSpecificTmpFileSnippet(int port) { StringBuilder sb = new StringBuilder(); sb.append("cd \"").append(OSUtil.toUnixPath(buildPIDParentFolderAbsolutePath())).append("\";"); sb.append("./").append(BashPIDSnippetSupport.FILENAME_STORE_TERMINAL_PIDS_SCRIPT); sb.append(" ").append(port); sb.append(" $$"); sb.append(";"); return sb.toString(); } BashCallPIDStoreSnippetBuilder(); } | BashCallPIDStoreSnippetBuilder { public String buildWritePIDToPortSpecificTmpFileSnippet(int port) { StringBuilder sb = new StringBuilder(); sb.append("cd \"").append(OSUtil.toUnixPath(buildPIDParentFolderAbsolutePath())).append("\";"); sb.append("./").append(BashPIDSnippetSupport.FILENAME_STORE_TERMINAL_PIDS_SCRIPT); sb.append(" ").append(port); sb.append(" $$"); sb.append(";"); return sb.toString(); } BashCallPIDStoreSnippetBuilder(); String buildPIDFileAbsolutePath(String port); String buildPIDParentFolderAbsolutePath(); String buildWritePIDToPortSpecificTmpFileSnippet(int port); } | BashCallPIDStoreSnippetBuilder { public String buildWritePIDToPortSpecificTmpFileSnippet(int port) { StringBuilder sb = new StringBuilder(); sb.append("cd \"").append(OSUtil.toUnixPath(buildPIDParentFolderAbsolutePath())).append("\";"); sb.append("./").append(BashPIDSnippetSupport.FILENAME_STORE_TERMINAL_PIDS_SCRIPT); sb.append(" ").append(port); sb.append(" $$"); sb.append(";"); return sb.toString(); } BashCallPIDStoreSnippetBuilder(); String buildPIDFileAbsolutePath(String port); String buildPIDParentFolderAbsolutePath(); String buildWritePIDToPortSpecificTmpFileSnippet(int port); } |
@Test public void single_quote_a_space_b_single_quote_results_in_a_b() { assertEquals(expect("a","b").listExpected, builderToTest.build("'a b'")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void a_space_666_results_in_a_666() { assertEquals(expect("a","666").listExpected, builderToTest.build("a 666")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void var_equals_1__results_in_var_1() { assertEquals(expect("var","1").listExpected, builderToTest.build("var=1")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void var_space_equals_1__results_in_var_1() { assertEquals(expect("var","1").listExpected, builderToTest.build("var =1")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void var_equals_space_1__results_in_var_1() { assertEquals(expect("var","1").listExpected, builderToTest.build("var= 1")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void var_space_equals_space_1__results_in_var_1() { assertEquals(expect("var","1").listExpected, builderToTest.build("var = 1")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void albert_space_sarah__results_in_albert_sarah_in_list() { assertEquals(expect("albert","sarah").listExpected, builderToTest.build("albert sarah")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void albert_qestion_sarah__results_in_albert_sarah_in_list() { assertEquals(expect("albert","sarah").listExpected, builderToTest.build("albert?sarah")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void albert_space_space_tab_space_sarah__results_in_albert_sarah_in_list() { assertEquals(expect("albert","sarah").listExpected, builderToTest.build("albert \t sarah")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void test_open_backet_close_bracket_break__results_in_test_break() { assertEquals(expect("test","break").listExpected, builderToTest.build("test() break")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void startCommandAsExpected() { assertEquals("cmd.exe /C ${BE_TERMINAL}", providerToTest.getStarterCommandString()); } | @Override public String getStarterCommandString() { return "cmd.exe /C "+TerminalCommandVariable.BE_TERMINAL.getVariableRepresentation(); } | DefaultWindowsTerminalCommandStringProvider implements DefaultTerminalCommandStringProvider { @Override public String getStarterCommandString() { return "cmd.exe /C "+TerminalCommandVariable.BE_TERMINAL.getVariableRepresentation(); } } | DefaultWindowsTerminalCommandStringProvider implements DefaultTerminalCommandStringProvider { @Override public String getStarterCommandString() { return "cmd.exe /C "+TerminalCommandVariable.BE_TERMINAL.getVariableRepresentation(); } } | DefaultWindowsTerminalCommandStringProvider implements DefaultTerminalCommandStringProvider { @Override public String getStarterCommandString() { return "cmd.exe /C "+TerminalCommandVariable.BE_TERMINAL.getVariableRepresentation(); } @Override String getStarterCommandString(); @Override String getTerminalCommandString(); } | DefaultWindowsTerminalCommandStringProvider implements DefaultTerminalCommandStringProvider { @Override public String getStarterCommandString() { return "cmd.exe /C "+TerminalCommandVariable.BE_TERMINAL.getVariableRepresentation(); } @Override String getStarterCommandString(); @Override String getTerminalCommandString(); } |
@Test public void test_open_backet_xx_close_bracket_break__results_in_test_xx_break() { assertEquals(expect("test","xx","break").listExpected, builderToTest.build("test(xx) break")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void albert_dot_sarah__results_in_albert_sarah_in_list() { assertEquals(expect("albert","sarah").listExpected, builderToTest.build("albert.sarah")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void albert_commata_sarah__results_in_albert_sarah_in_list() { assertEquals(expect("albert","sarah").listExpected, builderToTest.build("albert,sarah")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void albert_commata_space_sarah__results_in_albert_sarah_in_list() { assertEquals(expect("albert","sarah").listExpected, builderToTest.build("albert, sarah")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void albert_dot_space_sarah__results_in_albert_sarah_in_list() { assertEquals(expect("albert","sarah").listExpected, builderToTest.build("albert. sarah")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void albert_semicolon_space_sarah__results_in_albert_sarah_in_list() { assertEquals(expect("albert","sarah").listExpected, builderToTest.build("albert; sarah")); } | @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } | SimpleWordListBuilder implements WordListBuilder { @Override public List<String> build(String source) { if (source == null || source.isEmpty()) { return Collections.emptyList(); } String[] allWords = source.split("[\\s,;:.!()\\?=]"); List<String> list = new ArrayList<>(); for (String word: allWords){ String transformed = transformIfNecessary(word); if (transformed!=null && ! transformed.isEmpty()){ list.add(transformed); } } return list; } @Override List<String> build(String source); } |
@Test public void shebang_slash_bin_slash_bash_is_valid() { assertTrue(validatorToTest.isValid("#!/bin/bash")); } | public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } |
@Test public void shebang_slash_user_slash_bin_slash_bash_is_valid() { assertTrue(validatorToTest.isValid("#!/usr/bin/bash")); } | public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } |
@Test public void shebang_usr_bin_slash_env_space_bash_is_valid() { assertTrue(validatorToTest.isValid("#!/usr/bin/env bash")); } | public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } |
@Test public void shebang_slash_bin_slash_sh_is_not_valid() { assertFalse(validatorToTest.isValid("#!/bin/sh")); } | public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } |
@Test public void startTerminalCommandAsExpected() { assertEquals("start \"${BE_CMD_TITLE}\" cmd.exe /C bash --login -c '${BE_CMD_CALL}'", providerToTest.getTerminalCommandString()); } | @Override public String getTerminalCommandString() { return "start \""+TerminalCommandVariable.BE_CMD_TITLE.getVariableRepresentation()+"\" cmd.exe /C bash --login -c '"+TerminalCommandVariable.BE_CMD_CALL.getVariableRepresentation()+"'"; } | DefaultWindowsTerminalCommandStringProvider implements DefaultTerminalCommandStringProvider { @Override public String getTerminalCommandString() { return "start \""+TerminalCommandVariable.BE_CMD_TITLE.getVariableRepresentation()+"\" cmd.exe /C bash --login -c '"+TerminalCommandVariable.BE_CMD_CALL.getVariableRepresentation()+"'"; } } | DefaultWindowsTerminalCommandStringProvider implements DefaultTerminalCommandStringProvider { @Override public String getTerminalCommandString() { return "start \""+TerminalCommandVariable.BE_CMD_TITLE.getVariableRepresentation()+"\" cmd.exe /C bash --login -c '"+TerminalCommandVariable.BE_CMD_CALL.getVariableRepresentation()+"'"; } } | DefaultWindowsTerminalCommandStringProvider implements DefaultTerminalCommandStringProvider { @Override public String getTerminalCommandString() { return "start \""+TerminalCommandVariable.BE_CMD_TITLE.getVariableRepresentation()+"\" cmd.exe /C bash --login -c '"+TerminalCommandVariable.BE_CMD_CALL.getVariableRepresentation()+"'"; } @Override String getStarterCommandString(); @Override String getTerminalCommandString(); } | DefaultWindowsTerminalCommandStringProvider implements DefaultTerminalCommandStringProvider { @Override public String getTerminalCommandString() { return "start \""+TerminalCommandVariable.BE_CMD_TITLE.getVariableRepresentation()+"\" cmd.exe /C bash --login -c '"+TerminalCommandVariable.BE_CMD_CALL.getVariableRepresentation()+"'"; } @Override String getStarterCommandString(); @Override String getTerminalCommandString(); } |
@Test public void wrong_slash_bin_slash_bash_is_valid() { assertFalse(validatorToTest.isValid("!/bin/bash")); } | public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } |
@Test public void hash_slash_bin_slash_bash_is_valid() { assertFalse(validatorToTest.isValid("#/bin/bash")); } | public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } |
@Test public void shebang_slash_bin_some_where_else_slash_bash_is_valid() { assertTrue(validatorToTest.isValid("#!/bin/some_where_else/bash")); } | public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } |
@Test public void shebang_slash_bin_some_where_else_slash_bash_some_params_is_valid() { assertTrue(validatorToTest.isValid("#!/bin/some_where_else/bash -l -x")); } | public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } | LineIsBashSheBangValidator { public boolean isValid(String line) { if (line == null) { return false; } if (line.isEmpty()) { return false; } if (!line.startsWith("#!")) { return false; } if (line.indexOf("bash") != -1 ) { return true; } if (line.endsWith(" sh")) { return true; } return false; } boolean isValid(String line); } |
@Test public void test() { assertEquals(".txt",extractorToTest.extractFileExtension(new File("/tmp/file1.txt"))); assertEquals(".",extractorToTest.extractFileExtension(new File("/tmp/file1."))); assertEquals(null,extractorToTest.extractFileExtension(new File("/tmp/file1"))); assertEquals(".bash",extractorToTest.extractFileExtension(new File("/tmp/file1.bash"))); } | public String extractFileExtension(File file) { Objects.requireNonNull(file); String fileName = file.getName(); int index = fileName.lastIndexOf('.'); if (index==-1) { return null; } if (fileName.length()==index-1) { return null; } return fileName.substring(index); } | FileExtensionExtractor { public String extractFileExtension(File file) { Objects.requireNonNull(file); String fileName = file.getName(); int index = fileName.lastIndexOf('.'); if (index==-1) { return null; } if (fileName.length()==index-1) { return null; } return fileName.substring(index); } } | FileExtensionExtractor { public String extractFileExtension(File file) { Objects.requireNonNull(file); String fileName = file.getName(); int index = fileName.lastIndexOf('.'); if (index==-1) { return null; } if (fileName.length()==index-1) { return null; } return fileName.substring(index); } } | FileExtensionExtractor { public String extractFileExtension(File file) { Objects.requireNonNull(file); String fileName = file.getName(); int index = fileName.lastIndexOf('.'); if (index==-1) { return null; } if (fileName.length()==index-1) { return null; } return fileName.substring(index); } String extractFileExtension(File file); } | FileExtensionExtractor { public String extractFileExtension(File file) { Objects.requireNonNull(file); String fileName = file.getName(); int index = fileName.lastIndexOf('.'); if (index==-1) { return null; } if (fileName.length()==index-1) { return null; } return fileName.substring(index); } String extractFileExtension(File file); } |
@Test public void anExistingFile_commands_are_as_expected_and_parameter_replaced() { File editorFile = TestScriptLoader.getTestScriptFile("strings.sh"); String[] result = actionToTest.build("beautysh.py $filename", editorFile); assertEquals(2, result.length); assertEquals("beautysh.py",result[0]); if (OSUtil.isWindows()){ assertEquals(".\\..\\basheditor-other\\testscripts\\strings.sh",result[1]); }else { assertEquals("./../basheditor-other/testscripts/strings.sh",result[1]); } } | public String[] build(String externalToolCall, File editorFile) { numKeywordsReplaced = 0; String[] ret = externalToolCall.split(" "); for (int i = 0; i < ret.length; i++) if (ret[i].equalsIgnoreCase("$filename")) { ret[i] = editorFile.toPath().toString(); numKeywordsReplaced++; } return ret; } | ExternalToolCommandArrayBuilder { public String[] build(String externalToolCall, File editorFile) { numKeywordsReplaced = 0; String[] ret = externalToolCall.split(" "); for (int i = 0; i < ret.length; i++) if (ret[i].equalsIgnoreCase("$filename")) { ret[i] = editorFile.toPath().toString(); numKeywordsReplaced++; } return ret; } } | ExternalToolCommandArrayBuilder { public String[] build(String externalToolCall, File editorFile) { numKeywordsReplaced = 0; String[] ret = externalToolCall.split(" "); for (int i = 0; i < ret.length; i++) if (ret[i].equalsIgnoreCase("$filename")) { ret[i] = editorFile.toPath().toString(); numKeywordsReplaced++; } return ret; } } | ExternalToolCommandArrayBuilder { public String[] build(String externalToolCall, File editorFile) { numKeywordsReplaced = 0; String[] ret = externalToolCall.split(" "); for (int i = 0; i < ret.length; i++) if (ret[i].equalsIgnoreCase("$filename")) { ret[i] = editorFile.toPath().toString(); numKeywordsReplaced++; } return ret; } String[] build(String externalToolCall, File editorFile); int getNumKeywordsReplaced(); } | ExternalToolCommandArrayBuilder { public String[] build(String externalToolCall, File editorFile) { numKeywordsReplaced = 0; String[] ret = externalToolCall.split(" "); for (int i = 0; i < ret.length; i++) if (ret[i].equalsIgnoreCase("$filename")) { ret[i] = editorFile.toPath().toString(); numKeywordsReplaced++; } return ret; } String[] build(String externalToolCall, File editorFile); int getNumKeywordsReplaced(); } |
@Test public void source_empty__calculate_nothing_on_index_0(){ Set<String> result = completionToTest.calculate("", 0); assertResult(result).hasNoResults(); } | public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void a_space_albert_likes_automated_testing__offset_1_calculates_albert__automated_() { Set<String> result = completionToTest.calculate("a albert likes automated testing", 1); assertResult(result).hasResults("albert","automated"); } | public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void a_space_Albert_likes_automated_testing__offset_1_calculates_albert__automated__so_caseinsensitive_proposals() { Set<String> result = completionToTest.calculate("a Albert likes automated testing", 1); assertResult(result).hasResults("Albert","automated"); } | public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void getTextbefore__a_b_c__index_0_text_before_is_empty(){ assertEquals("", completionToTest.getTextbefore("a b c", 0)); } | public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void a_space_b_space_c__are_three_entries_a_b_c() { 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 getTextbefore__a_b_c__index_1_text_before_is_a(){ assertEquals("a", completionToTest.getTextbefore("a b c", 1)); } | public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void getTextbefore__a_b_c__index_2_text_before_is_empty(){ assertEquals("", completionToTest.getTextbefore("a b c", 2)); } | public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void getTextbefore__a_b_c__index_3_text_before_is_b(){ assertEquals("b", completionToTest.getTextbefore("a b c", 3)); } | public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void getTextbefore__ax_b_c__index_2_text_before_is_ax(){ assertEquals("ax", completionToTest.getTextbefore("ax b c", 2)); } | public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void getTextbefore_returns_empty_string_when_index_is_0(){ assertEquals("",completionToTest.getTextbefore("abc", 0)); } | public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void getTextbefore_returns_empty_string_when_index_is_n1(){ assertEquals("",completionToTest.getTextbefore("abc", -1)); } | public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void getTextbefore_returns_empty_string_when_source_empty(){ assertEquals("",completionToTest.getTextbefore("", 0)); assertEquals("",completionToTest.getTextbefore("", 1)); assertEquals("",completionToTest.getTextbefore("", -1)); assertEquals("",completionToTest.getTextbefore(" ", 0)); assertEquals("",completionToTest.getTextbefore(" ", 1)); assertEquals("",completionToTest.getTextbefore(" ", -1)); } | public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void getTextbefore_returns_empty_string_when_source_null(){ assertEquals("",completionToTest.getTextbefore(null, 0)); assertEquals("",completionToTest.getTextbefore(null, 1)); assertEquals("",completionToTest.getTextbefore(null, -1)); } | public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public String getTextbefore(String source, int offset) { if (source == null || source.isEmpty()) { return ""; } if (offset <= 0) { return ""; } int sourceLength = source.length(); if (offset > sourceLength) { return ""; } StringBuilder sb = new StringBuilder(); int current = offset - 1; boolean ongoing = false; do { if (current < 0) { break; } char c = source.charAt(current--); ongoing = !Character.isWhitespace(c); if (ongoing) { sb.insert(0, c); } } while (ongoing); return sb.toString(); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void newline_albert_newline_albert_newline_newline_albert__offset_0_calculates_albert() { Set<String> result = completionToTest.calculate(" albert\nalbert\nalbert", 0); assertResult(result).hasResults("albert"); } | public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void space_albert_likes_automated_testing__offset_0_calculates_albert_likes_automated_testing() { Set<String> result = completionToTest.calculate(" albert likes automated testing", 0); assertResult(result).hasResults("albert","likes","automated","testing"); } | public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void three_spaces_only_are_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 space_albert_space_albert_space_space_albert__offset_0_calculates_albert() { Set<String> result = completionToTest.calculate(" albert albert albert", 0); assertResult(result).hasResults("albert"); } | public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } | SimpleWordCodeCompletion { public Set<String> calculate(String source, int offset) { rebuildCacheIfNecessary(source); if (offset == 0) { return unmodifiableSet(allWordsCache); } String wanted = getTextbefore(source, offset); return filter(allWordsCache, wanted); } void add(String word); Set<String> calculate(String source, int offset); String getTextbefore(String source, int offset); SimpleWordCodeCompletion reset(); WordListBuilder getWordListBuilder(); void setWordListBuilder(WordListBuilder wordListBuilder); } |
@Test public void nextReducedVariable_from_string_alpha_beta_gamma_offset_0_is_alpha() { assertEquals("alpha", SimpleStringUtils.nextReducedVariableWord("alpha beta gamma", 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 nextReducedVariable_from_string_alpha_beta_gamma_offset_n1_is_empty() { assertEquals("", SimpleStringUtils.nextReducedVariableWord("alpha beta gamma",-1)); } | 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_null_is_empty() { assertEquals("", SimpleStringUtils.nextReducedVariableWord(null,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 nextReducedVariable_from_string_alpha_beta_gamma_offset_1_is_alpha() { assertEquals("alpha", SimpleStringUtils.nextReducedVariableWord("alpha beta gamma", 1)); } | 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); } |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.