Fixes various tab completion problems
This commit is contained in:
@ -15,10 +15,21 @@ public final class Tokenizer {
|
||||
/**
|
||||
* Tokenizes a string
|
||||
*
|
||||
* @param input <p>A string.</p>
|
||||
* @return <p>A list of tokens.</p>
|
||||
* @param input <p>A string</p>
|
||||
* @return <p>A list of tokens</p>
|
||||
*/
|
||||
public static List<String> tokenize(String input) {
|
||||
return tokenize(input, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tokenizes a string
|
||||
*
|
||||
* @param input <p>A string</p>
|
||||
* @param allowEmptyQuotes <p>Whether to treat "" as a token</p>
|
||||
* @return <p>A list of tokens</p>
|
||||
*/
|
||||
public static List<String> tokenize(String input, boolean allowEmptyQuotes) {
|
||||
List<String> tokens = new ArrayList<>();
|
||||
boolean startedQuote = false;
|
||||
StringBuilder currentToken = new StringBuilder();
|
||||
@ -33,7 +44,7 @@ public final class Tokenizer {
|
||||
case '"':
|
||||
if (startedQuote) {
|
||||
//This quote signifies the end of the argument
|
||||
if (isNotEmpty(currentToken)) {
|
||||
if (allowEmptyQuotes || isNotEmpty(currentToken)) {
|
||||
tokens.add(currentToken.toString());
|
||||
currentToken = new StringBuilder();
|
||||
}
|
||||
|
Reference in New Issue
Block a user