• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

apache / iotdb / #10006

06 Sep 2023 05:15AM CUT coverage: 47.697% (+0.006%) from 47.691%
#10006

push

travis_ci

web-flow
[RatisConsensus] retry cache expiration time should be longer than retriable-client wait duration (#11045) (#11052)

13 of 13 new or added lines in 1 file covered. (100.0%)

80213 of 168172 relevant lines covered (47.7%)

0.48 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/iotdb-client/cli/src/main/java/org/apache/iotdb/cli/IoTDBSyntaxHighlighter.java
1
/*
2
 * Licensed to the Apache Software Foundation (ASF) under one
3
 * or more contributor license agreements.  See the NOTICE file
4
 * distributed with this work for additional information
5
 * regarding copyright ownership.  The ASF licenses this file
6
 * to you under the Apache License, Version 2.0 (the
7
 * "License"); you may not use this file except in compliance
8
 * with the License.  You may obtain a copy of the License at
9
 *
10
 *     http://www.apache.org/licenses/LICENSE-2.0
11
 *
12
 * Unless required by applicable law or agreed to in writing,
13
 * software distributed under the License is distributed on an
14
 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15
 * KIND, either express or implied.  See the License for the
16
 * specific language governing permissions and limitations
17
 * under the License.
18
 */
19

20
package org.apache.iotdb.cli;
21

22
import org.apache.iotdb.cli.utils.IoTPrinter;
23
import org.apache.iotdb.cli.utils.JlineUtils;
24
import org.apache.iotdb.db.qp.sql.SqlLexer;
25

26
import org.antlr.v4.runtime.CharStream;
27
import org.antlr.v4.runtime.CharStreams;
28
import org.antlr.v4.runtime.Token;
29
import org.jline.reader.Highlighter;
30
import org.jline.reader.LineReader;
31
import org.jline.utils.AttributedString;
32
import org.jline.utils.AttributedStringBuilder;
33
import org.jline.utils.AttributedStyle;
34

35
import java.util.regex.Pattern;
36

37
import static org.jline.utils.AttributedStyle.DEFAULT;
38
import static org.jline.utils.AttributedStyle.GREEN;
39

40
public class IoTDBSyntaxHighlighter implements Highlighter {
×
41

42
  private static final AttributedStyle KEYWORD_STYLE = DEFAULT.foreground(GREEN);
×
43

44
  @Override
45
  public AttributedString highlight(LineReader reader, String buffer) {
46
    CharStream stream = CharStreams.fromString(buffer);
×
47
    SqlLexer tokenSource = new SqlLexer(stream);
×
48
    tokenSource.removeErrorListeners();
×
49
    AttributedStringBuilder builder = new AttributedStringBuilder();
×
50
    while (true) {
51
      Token token = tokenSource.nextToken();
×
52
      int type = token.getType();
×
53
      if (type == Token.EOF) {
×
54
        break;
×
55
      }
56
      String text = token.getText();
×
57

58
      if (isKeyword(text)) {
×
59
        builder.styled(KEYWORD_STYLE, text);
×
60
      } else {
61
        builder.append(text);
×
62
      }
63
    }
×
64

65
    return builder.toAttributedString();
×
66
  }
67

68
  @Override
69
  public void setErrorPattern(Pattern errorPattern) {
70
    IoTPrinter.print("");
×
71
  }
×
72

73
  @Override
74
  public void setErrorIndex(int errorIndex) {
75
    IoTPrinter.print("");
×
76
  }
×
77

78
  private boolean isKeyword(String token) {
79
    return JlineUtils.SQL_KEYWORDS.contains(token.toUpperCase());
×
80
  }
81
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc