Skip to content

Commit

Permalink
Small code cleanup, #364
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Mar 15, 2019
1 parent 514c516 commit b3e6ed2
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions reader/src/main/java/org/jline/reader/impl/DefaultParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,18 +209,20 @@ public ParsedLine parse(final String line, final int cursor, ParseContext contex
rawWordLength = rawWordCursor;
}

if (eofOnEscapedNewLine && isEscapeChar(line, line.length() - 1) && context != ParseContext.COMPLETE) {
throw new EOFError(-1, -1, "Escaped new line", "newline");
}
if (eofOnUnclosedQuote && quoteStart >= 0 && context != ParseContext.COMPLETE) {
throw new EOFError(-1, -1, "Missing closing quote", line.charAt(quoteStart) == '\''
? "quote" : "dquote");
}
if (bracketChecker.isOpeningBracketMissing() && context != ParseContext.COMPLETE) {
throw new EOFError(-1, -1, "Missing opening bracket", "missing: " + bracketChecker.getMissingOpeningBracket());
}
if (bracketChecker.isClosingBracketMissing() && context != ParseContext.COMPLETE) {
throw new EOFError(-1, -1, "Missing closing brackets", "add: " + bracketChecker.getMissingClosingBrackets());
if (context != ParseContext.COMPLETE) {
if (eofOnEscapedNewLine && isEscapeChar(line, line.length() - 1)) {
throw new EOFError(-1, -1, "Escaped new line", "newline");
}
if (eofOnUnclosedQuote && quoteStart >= 0) {
throw new EOFError(-1, -1, "Missing closing quote", line.charAt(quoteStart) == '\''
? "quote" : "dquote");
}
if (bracketChecker.isOpeningBracketMissing()) {
throw new EOFError(-1, -1, "Missing opening bracket", "missing: " + bracketChecker.getMissingOpeningBracket());
}
if (bracketChecker.isClosingBracketMissing()) {
throw new EOFError(-1, -1, "Missing closing brackets", "add: " + bracketChecker.getMissingClosingBrackets());
}
}

String openingQuote = quotedWord ? line.substring(quoteStart, quoteStart + 1) : null;
Expand Down

0 comments on commit b3e6ed2

Please sign in to comment.