Wraps ExtendedArgumentList into CompletingParsedLine prevent WARNING during startup.
- Idea/hack copied from jline LineReaderImpl - Backport #526 - Fixes #594
This commit is contained in:
committed by
Janne Valkealahti
parent
14aa6f1703
commit
7a6d457e71
@@ -142,7 +142,7 @@ public class ExtendedDefaultParser implements Parser {
|
||||
}
|
||||
|
||||
String openingQuote = quoteStart >= 0 ? line.substring(quoteStart, quoteStart + 1) : null;
|
||||
return new ExtendedArgumentList(line, words, wordIndex, wordCursor, cursor, openingQuote);
|
||||
return wrap(new ExtendedArgumentList(line, words, wordIndex, wordCursor, cursor, openingQuote));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -321,4 +321,46 @@ public class ExtendedDefaultParser implements Parser {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Another copy from JLine's {@link org.jline.reader.impl.LineReaderImpl}
|
||||
*
|
||||
* Used to wrap {@link org.jline.reader.ParsedLine} into {@link org.jline.reader.CompletingParsedLine}
|
||||
*/
|
||||
private static org.jline.reader.CompletingParsedLine wrap(ParsedLine line) {
|
||||
if (line instanceof org.jline.reader.CompletingParsedLine) {
|
||||
return (org.jline.reader.CompletingParsedLine) line;
|
||||
}
|
||||
else {
|
||||
return new org.jline.reader.CompletingParsedLine() {
|
||||
public String word() {
|
||||
return line.word();
|
||||
}
|
||||
public int wordCursor() {
|
||||
return line.wordCursor();
|
||||
}
|
||||
public int wordIndex() {
|
||||
return line.wordIndex();
|
||||
}
|
||||
public List<String> words() {
|
||||
return line.words();
|
||||
}
|
||||
public String line() {
|
||||
return line.line();
|
||||
}
|
||||
public int cursor() {
|
||||
return line.cursor();
|
||||
}
|
||||
public CharSequence escape(CharSequence candidate, boolean complete) {
|
||||
return candidate;
|
||||
}
|
||||
public int rawWordCursor() {
|
||||
return wordCursor();
|
||||
}
|
||||
public int rawWordLength() {
|
||||
return word().length();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user