Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ ThisBuild / organization := "app.softnetwork"

name := "softclient4es"

ThisBuild / version := "0.20.1"
ThisBuild / version := "0.20.2-SNAPSHOT"

ThisBuild / scalaVersion := scala213

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,112 +23,28 @@ import java.util

class ReplCompleter extends Completer {

private val simpleKeywords = Set(
// DQL
"SELECT",
"FROM",
"WHERE",
"GROUP",
"ORDER",
"HAVING",
"LIMIT",
"OFFSET",
"JOIN",
"LEFT",
"RIGHT",
"INNER",
"OUTER",
"UNION",
"INTERSECT",
"EXCEPT",
// Single source of truth for SQL keywords (#161): parser-derived registry + REPL extras.
private val simpleKeywords: Set[String] = ReplKeywords.all

// DML
"INSERT",
"INTO",
"VALUES",
"UPDATE",
"SET",
"DELETE",
"COPY",
"BULK",

// DDL
"CREATE",
"ALTER",
"DROP",
"TRUNCATE",
"RENAME",
"TABLE",
"INDEX",
"VIEW",
"PIPELINE",
"WATCHER",
"ENRICH",
"POLICY",
"TRANSFORM",

// Functions
"COUNT",
"SUM",
"AVG",
"MIN",
"MAX",
"DISTINCT",
"CAST",
"COALESCE",
"NULLIF",
"CASE",
"WHEN",
"THEN",
"ELSE",
"END",

// Operators
"AND",
"OR",
"NOT",
"IN",
"LIKE",
"BETWEEN",
"IS",
"NULL",
"TRUE",
"FALSE",

// Enrich/Watcher
"TYPE",
"MATCH",
"GEO_MATCH",
"RANGE",
"ON",
"EXECUTE",
"SCHEDULE",
"EVERY",
"CONDITION",
"ACTION",
"WEBHOOK",
"LOG",

// Meta
"SHOW",
"DESCRIBE",
"EXPLAIN",
"BY",
"ALL",
"AS"
)

// Context-aware compound keywords
// Context-aware compound keywords (continuations offered after the trigger word).
// Hand-curated UX map; the underlying registry phrases (ORDER BY, PARTITION BY,
// UNION ALL, NULLS FIRST/LAST, ...) are pinned in SQLKeywords.compoundPhrases by
// ReplKeywordsSpec. GEO -> MATCH is a REPL-only convenience (extraWords).
private val compoundKeywords = Map(
"GROUP" -> List("BY"),
"ORDER" -> List("BY"),
"LEFT" -> List("JOIN", "OUTER JOIN"),
"RIGHT" -> List("JOIN", "OUTER JOIN"),
"INNER" -> List("JOIN"),
"OUTER" -> List("JOIN"),
"UNION" -> List("ALL"),
"ENRICH" -> List("POLICY"),
"GEO" -> List("MATCH")
"GROUP" -> List("BY"),
"ORDER" -> List("BY"),
"PARTITION" -> List("BY"),
"LEFT" -> List("JOIN", "OUTER JOIN"),
"RIGHT" -> List("JOIN", "OUTER JOIN"),
"FULL" -> List("JOIN", "OUTER JOIN"),
"CROSS" -> List("JOIN"),
"INNER" -> List("JOIN"),
"OUTER" -> List("JOIN"),
"UNION" -> List("ALL"),
"NULLS" -> List("FIRST", "LAST"),
"IS" -> List("NULL", "NOT NULL"),
"ENRICH" -> List("POLICY"),
"GEO" -> List("MATCH")
)

private val metaCommands = Set(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,36 +21,8 @@ import org.jline.utils.{AttributedString, AttributedStringBuilder, AttributedSty

class ReplHighlighter extends Highlighter {

private val keywords = Set(
"SELECT",
"FROM",
"WHERE",
"INSERT",
"UPDATE",
"DELETE",
"CREATE",
"ALTER",
"DROP",
"TABLE",
"INDEX",
"VIEW",
"AND",
"OR",
"NOT",
"IN",
"LIKE",
"BETWEEN",
"JOIN",
"LEFT",
"RIGHT",
"INNER",
"OUTER",
"ENRICH",
"POLICY",
"WATCHER",
"TRANSFORM",
"PIPELINE"
)
// Single source of truth for SQL keywords (#161): parser-derived registry + REPL extras.
private val keywords: Set[String] = ReplKeywords.all

override def highlight(reader: LineReader, buffer: String): AttributedString = {
val builder = new AttributedStringBuilder()
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright 2025 SOFTNETWORK
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package app.softnetwork.elastic.client.repl

import app.softnetwork.elastic.sql.SQLKeywords

/** The single keyword set both REPL components (highlighter + completer) consume (#161).
*
* `sqlWords` is the parser-derived truth (SQLKeywords registry, sql module). `extraWords` are
* REPL-only entries the parser does NOT accept today (legacy/roadmap completer entries kept for
* continuity - PD-2). A word the parser actually accepts must live in SQLKeywords, never here
* (guarded by ReplKeywordsSpec).
*/
object ReplKeywords {

/** Parser-backed keywords (single uppercase words). */
val sqlWords: Set[String] = SQLKeywords.highlightedWords

/** REPL-only entries — NOT parser keywords at this baseline:
* INTERSECT/EXPLAIN/BULK/CONDITION/ACTION/TRANSFORM were advertised by the pre-#161
* completer/highlighter; GEO is the compound trigger for "GEO MATCH".
*/
val extraWords: Set[String] =
Set("ACTION", "BULK", "CONDITION", "EXPLAIN", "GEO", "INTERSECT", "TRANSFORM")

/** Everything the REPL highlights and completes. */
val all: Set[String] = sqlWords ++ extraWords
}
Loading
Loading