Skip to content
Permalink
Browse files
8273682: Upgrade Jline to 3.20.0
Backport-of: b8cb76ad210cb3e7524c7f5b13cfe57746ac05d4
  • Loading branch information
zhengyu123 committed Jan 11, 2022
1 parent d716c2b commit 7f684c31a2cf39bc4f94b773ceb6640befcdd057
Showing 47 changed files with 2,194 additions and 837 deletions.
@@ -137,4 +137,9 @@ public boolean complete() {
public int compareTo(Candidate o) {
return value.compareTo(o.value);
}

@Override
public String toString() {
return "Candidate{" + value + "}";
}
}
@@ -0,0 +1,48 @@
/*
* Copyright (c) 2002-2020, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
*
* https://opensource.org/licenses/BSD-3-Clause
*/
package jdk.internal.org.jline.reader;

import java.util.List;
import java.util.Map;

public interface CompletionMatcher {

/**
* Compiles completion matcher functions
*
* @param options LineReader options
* @param prefix invoked by complete-prefix or expand-or-complete-prefix widget
* @param line The parsed line within which completion has been requested
* @param caseInsensitive if completion is case insensitive or not
* @param errors number of errors accepted in matching
* @param originalGroupName value of JLineReader variable original-group-name
*/
void compile(Map<LineReader.Option, Boolean> options, boolean prefix, CompletingParsedLine line
, boolean caseInsensitive, int errors, String originalGroupName);

/**
*
* @param candidates list of candidates
* @return a map of candidates that completion matcher matches
*/
List<Candidate> matches(List<Candidate> candidates);

/**
*
* @return a candidate that have exact match, null if no exact match found
*/
Candidate exactMatch();

/**
*
* @return a common prefix of matched candidates
*/
String getCommonPrefix();

}

This file was deleted.

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2016, the original author or authors.
* Copyright (c) 2002-2020, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
@@ -15,6 +15,7 @@
public class EndOfFileException extends RuntimeException {

private static final long serialVersionUID = 528485360925144689L;
private String partialLine;

public EndOfFileException() {
}
@@ -34,4 +35,13 @@ public EndOfFileException(Throwable cause) {
public EndOfFileException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) {
super(message, cause, enableSuppression, writableStackTrace);
}

public EndOfFileException partialLine(String partialLine) {
this.partialLine = partialLine;
return this;
}

public String getPartialLine() {
return partialLine;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2019, the original author or authors.
* Copyright (c) 2002-2021, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
@@ -294,7 +294,13 @@ public interface LineReader {
String COMMENT_BEGIN = "comment-begin";
String BELL_STYLE = "bell-style";
String PREFER_VISIBLE_BELL = "prefer-visible-bell";
/** tab completion: if candidates are more than list-max a question will be asked before displaying them */
String LIST_MAX = "list-max";
/**
* tab completion: if candidates are less than menu-list-max
* they are displayed in a list below the field to be completed
*/
String MENU_LIST_MAX = "menu-list-max";
String DISABLE_HISTORY = "disable-history";
String DISABLE_COMPLETION = "disable-completion";
String EDITING_MODE = "editing-mode";
@@ -303,19 +309,27 @@ public interface LineReader {
String WORDCHARS = "WORDCHARS";
String REMOVE_SUFFIX_CHARS = "REMOVE_SUFFIX_CHARS";
String SEARCH_TERMINATORS = "search-terminators";
/** Number of matching errors that are accepted by the completion matcher */
String ERRORS = "errors";
/** Property for the "others" group name */
String OTHERS_GROUP_NAME = "OTHERS_GROUP_NAME";
/** Property for the "original" group name */
String ORIGINAL_GROUP_NAME = "ORIGINAL_GROUP_NAME";
/** Completion style for displaying groups name */
String COMPLETION_STYLE_GROUP = "COMPLETION_STYLE_GROUP";
String COMPLETION_STYLE_LIST_GROUP = "COMPLETION_STYLE_LIST_GROUP";
/** Completion style for displaying the current selected item */
String COMPLETION_STYLE_SELECTION = "COMPLETION_STYLE_SELECTION";
String COMPLETION_STYLE_LIST_SELECTION = "COMPLETION_STYLE_LIST_SELECTION";
/** Completion style for displaying the candidate description */
String COMPLETION_STYLE_DESCRIPTION = "COMPLETION_STYLE_DESCRIPTION";
String COMPLETION_STYLE_LIST_DESCRIPTION = "COMPLETION_STYLE_LIST_DESCRIPTION";
/** Completion style for displaying the matching part of candidates */
String COMPLETION_STYLE_STARTING = "COMPLETION_STYLE_STARTING";
String COMPLETION_STYLE_LIST_STARTING = "COMPLETION_STYLE_LIST_STARTING";
/** Completion style for displaying the list */
String COMPLETION_STYLE_BACKGROUND = "COMPLETION_STYLE_BACKGROUND";
String COMPLETION_STYLE_LIST_BACKGROUND = "COMPLETION_STYLE_LIST_BACKGROUND";
/**
* Set the template for prompts for secondary (continuation) lines.
* This is a prompt template as described in the class header.
@@ -370,10 +384,20 @@ public interface LineReader {
*/
String FEATURES_MAX_BUFFER_SIZE = "features-max-buffer-size";

/**
* Min buffer size for tab auto-suggestions.
* For shorter buffer sizes auto-suggestions are not resolved.
*/
String SUGGESTIONS_MIN_BUFFER_SIZE = "suggestions-min-buffer-size";

Map<String, KeyMap<Binding>> defaultKeyMaps();

enum Option {
COMPLETE_IN_WORD,
/** use camel case completion matcher */
COMPLETE_MATCHER_CAMELCASE,
/** use type completion matcher */
COMPLETE_MATCHER_TYPO(true),
DISABLE_EVENT_EXPANSION,
HISTORY_VERIFY,
HISTORY_IGNORE_SPACE(true),
@@ -386,9 +410,13 @@ enum Option {
AUTO_GROUP(true),
AUTO_MENU(true),
AUTO_LIST(true),
/** list candidates below the field to be completed */
AUTO_MENU_LIST,
RECOGNIZE_EXACT,
/** display group name before each group (else display all group names first) */
GROUP(true),
/** when double tab to select candidate keep candidates grouped (else loose grouping) */
GROUP_PERSIST,
/** if completion is case insensitive or not */
CASE_INSENSITIVE,
LIST_AMBIGUOUS,
@@ -414,7 +442,8 @@ enum Option {
DELAY_LINE_WRAP,
AUTO_PARAM_SLASH(true),
AUTO_REMOVE_SLASH(true),
USE_FORWARD_SLASH(false),
/** FileNameCompleter: Use '/' character as a file directory separator */
USE_FORWARD_SLASH,
/** When hitting the <code>&lt;tab&gt;</code> key at the beginning of the line, insert a tabulation
* instead of completing. This is mainly useful when {@link #BRACKETED_PASTE} is
* disabled, so that copy/paste of indented text does not trigger completion.
@@ -450,6 +479,11 @@ enum Option {
this.def = def;
}

public final boolean isSet(Map<Option, Boolean> options) {
Boolean b = options.get(this);
return b != null ? b : this.isDef();
}

public boolean isDef() {
return def;
}
@@ -489,8 +523,9 @@ enum SuggestionType {
* Equivalent to <code>readLine(null, null, null)</code>.
*
* @return the line read
* @throws UserInterruptException If the call was interrupted by the user.
* @throws EndOfFileException If the end of the input stream was reached.
* @throws UserInterruptException if readLine was interrupted (using Ctrl-C for example)
* @throws EndOfFileException if an EOF has been found (using Ctrl-D for example)
* @throws java.io.IOError in case of other i/o errors
*/
String readLine() throws UserInterruptException, EndOfFileException;

@@ -502,8 +537,9 @@ enum SuggestionType {
*
* @param mask The mask character, <code>null</code> or <code>0</code>.
* @return A line that is read from the terminal, can never be null.
* @throws UserInterruptException If the call was interrupted by the user.
* @throws EndOfFileException If the end of the input stream was reached.
* @throws UserInterruptException if readLine was interrupted (using Ctrl-C for example)
* @throws EndOfFileException if an EOF has been found (using Ctrl-D for example)
* @throws java.io.IOError in case of other i/o errors
*/
String readLine(Character mask) throws UserInterruptException, EndOfFileException;

@@ -515,8 +551,9 @@ enum SuggestionType {
*
* @param prompt The prompt to issue to the terminal, may be null.
* @return A line that is read from the terminal, can never be null.
* @throws UserInterruptException If the call was interrupted by the user.
* @throws EndOfFileException If the end of the input stream was reached.
* @throws UserInterruptException if readLine was interrupted (using Ctrl-C for example)
* @throws EndOfFileException if an EOF has been found (using Ctrl-D for example)
* @throws java.io.IOError in case of other i/o errors
*/
String readLine(String prompt) throws UserInterruptException, EndOfFileException;

@@ -529,8 +566,9 @@ enum SuggestionType {
* @param prompt The prompt to issue to the terminal, may be null.
* @param mask The mask character, <code>null</code> or <code>0</code>.
* @return A line that is read from the terminal, can never be null.
* @throws UserInterruptException If the call was interrupted by the user.
* @throws EndOfFileException If the end of the input stream was reached.
* @throws UserInterruptException if readLine was interrupted (using Ctrl-C for example)
* @throws EndOfFileException if an EOF has been found (using Ctrl-D for example)
* @throws java.io.IOError in case of other i/o errors
*/
String readLine(String prompt, Character mask) throws UserInterruptException, EndOfFileException;

@@ -546,8 +584,9 @@ enum SuggestionType {
* @param mask The character mask, may be null.
* @param buffer The default value presented to the user to edit, may be null.
* @return A line that is read from the terminal, can never be null.
* @throws UserInterruptException If the call was interrupted by the user.
* @throws EndOfFileException If the end of the input stream was reached.
* @throws UserInterruptException if readLine was interrupted (using Ctrl-C for example)
* @throws EndOfFileException if an EOF has been found (using Ctrl-D for example)
* @throws java.io.IOError in case of other i/o errors
*/
String readLine(String prompt, Character mask, String buffer) throws UserInterruptException, EndOfFileException;

@@ -568,8 +607,6 @@ enum SuggestionType {
* @throws UserInterruptException if readLine was interrupted (using Ctrl-C for example)
* @throws EndOfFileException if an EOF has been found (using Ctrl-D for example)
* @throws java.io.IOError in case of other i/o errors
* @throws UserInterruptException If the call was interrupted by the user.
* @throws EndOfFileException If the end of the input stream was reached.
*/
String readLine(String prompt, String rightPrompt, Character mask, String buffer) throws UserInterruptException, EndOfFileException;

@@ -590,8 +627,6 @@ enum SuggestionType {
* @throws UserInterruptException if readLine was interrupted (using Ctrl-C for example)
* @throws EndOfFileException if an EOF has been found (using Ctrl-D for example)
* @throws java.io.IOError in case of other i/o errors
* @throws UserInterruptException If the call was interrupted by the user.
* @throws EndOfFileException If the end of the input stream was reached.
*/
String readLine(String prompt, String rightPrompt, MaskingCallback maskingCallback, String buffer) throws UserInterruptException, EndOfFileException;

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2002-2018, the original author or authors.
* Copyright (c) 2002-2020, the original author or authors.
*
* This software is distributable under the BSD license. See the terms of the
* BSD license in the documentation provided with this software.
@@ -36,6 +36,7 @@ public static LineReaderBuilder builder() {
Highlighter highlighter;
Parser parser;
Expander expander;
CompletionMatcher completionMatcher;

private LineReaderBuilder() {
}
@@ -103,6 +104,11 @@ public LineReaderBuilder expander(Expander expander) {
return this;
}

public LineReaderBuilder completionMatcher(CompletionMatcher completionMatcher) {
this.completionMatcher = completionMatcher;
return this;
}

public LineReader build() {
Terminal terminal = this.terminal;
if (terminal == null) {
@@ -133,6 +139,9 @@ public LineReader build() {
if (expander != null) {
reader.setExpander(expander);
}
if (completionMatcher != null) {
reader.setCompletionMatcher(completionMatcher);
}
for (Map.Entry<LineReader.Option, Boolean> e : options.entrySet()) {
reader.option(e.getKey(), e.getValue());
}

1 comment on commit 7f684c3

@openjdk-notifier
Copy link

@openjdk-notifier openjdk-notifier bot commented on 7f684c3 Jan 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.