You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@iotdb.apache.org by qi...@apache.org on 2021/11/28 05:25:32 UTC

[iotdb] branch master updated: [IOTDB-2070] fix CLI doesn't accept statements with unclosed brackets (#4487)

This is an automated email from the ASF dual-hosted git repository.

qiaojialin pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/iotdb.git


The following commit(s) were added to refs/heads/master by this push:
     new 521f562  [IOTDB-2070] fix CLI doesn't accept statements with unclosed brackets (#4487)
521f562 is described below

commit 521f5626297e834049e8f8af94bac09ede3b8143
Author: Zhong Wang <wa...@alibaba-inc.com>
AuthorDate: Sun Nov 28 13:25:05 2021 +0800

    [IOTDB-2070] fix CLI doesn't accept statements with unclosed brackets (#4487)
---
 .../main/java/org/apache/iotdb/cli/utils/JlineUtils.java   | 14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

diff --git a/cli/src/main/java/org/apache/iotdb/cli/utils/JlineUtils.java b/cli/src/main/java/org/apache/iotdb/cli/utils/JlineUtils.java
index e2f5c7d..0ea7005 100644
--- a/cli/src/main/java/org/apache/iotdb/cli/utils/JlineUtils.java
+++ b/cli/src/main/java/org/apache/iotdb/cli/utils/JlineUtils.java
@@ -19,20 +19,17 @@
 
 package org.apache.iotdb.cli.utils;
 
-import org.apache.iotdb.cli.IoTDBSyntaxHighlighter;
 import org.apache.iotdb.db.qp.sql.IoTDBSqlLexer;
 
 import org.jline.reader.LineReader;
 import org.jline.reader.LineReader.Option;
 import org.jline.reader.LineReaderBuilder;
-import org.jline.reader.impl.DefaultParser.Bracket;
 import org.jline.reader.impl.completer.StringsCompleter;
 import org.jline.terminal.Size;
 import org.jline.terminal.Terminal;
 import org.jline.terminal.Terminal.Signal;
 import org.jline.terminal.TerminalBuilder;
 import org.jline.utils.OSUtils;
-import org.jline.widget.AutopairWidgets;
 import org.jline.widget.AutosuggestionWidgets;
 
 import java.io.File;
@@ -74,7 +71,9 @@ public class JlineUtils {
     String historyFilePath = System.getProperty("user.home") + File.separator + historyFile;
     builder.variable(LineReader.HISTORY_FILE, new File(historyFilePath));
 
-    builder.highlighter(new IoTDBSyntaxHighlighter());
+    // TODO: since the lexer doesn't produce tokens for quotation marks, disable the highlighter to
+    // avoid incorrect inputs.
+    //    builder.highlighter(new IoTDBSyntaxHighlighter());
 
     builder.completer(new StringsCompleter(SQL_KEYWORDS));
 
@@ -84,9 +83,6 @@ public class JlineUtils {
     builder.option(Option.DISABLE_EVENT_EXPANSION, true);
 
     org.jline.reader.impl.DefaultParser parser = new org.jline.reader.impl.DefaultParser();
-    // Make multi-line edition be triggered by unclosed brackets and unclosed quotes.
-    parser.setEofOnUnclosedBracket(Bracket.CURLY, Bracket.SQUARE, Bracket.ROUND);
-    parser.setEofOnUnclosedQuote(true);
     builder.parser(parser);
     LineReader lineReader = builder.build();
     if (OSUtils.IS_WINDOWS) {
@@ -94,10 +90,6 @@ public class JlineUtils {
       lineReader.setVariable(LineReader.BLINK_MATCHING_PAREN, 0);
     }
 
-    // Create auto-pair widgets
-    AutopairWidgets autopairWidgets = new AutopairWidgets(lineReader);
-    // Enable auto-pair
-    autopairWidgets.enable();
     // Create autosuggestion widgets
     AutosuggestionWidgets autosuggestionWidgets = new AutosuggestionWidgets(lineReader);
     // Enable autosuggestions