feat: give column data types a dedicated syntax-highlight colour
Both Node::Ident and Word carried a highlight_override field, and both were dead — the walker driver discarded the Ident's and walk_word hardcoded Keyword. So column types (int, serial, …) rendered identically to table/column names. Wire both overrides through, and add a dedicated HighlightClass::Type with its own theme colour (tok_type), distinct from keyword-purple and identifier-teal. The three type Ident slots opt in, so canonical types and the advanced-mode single-word SQL aliases (float, varchar, …) render as types; the two-word `double precision` alias opts in via a new Word::type_keyword constructor. ADR-0022 Amendment 4.
This commit is contained in:
@@ -24,7 +24,9 @@
|
||||
//! `sql_insert::SQL_INSERT_SHAPE`, which starts at `INTO`).
|
||||
|
||||
use crate::dsl::grammar::sql_select::reject_internal_table;
|
||||
use crate::dsl::grammar::{IdentSource, Node, ValidationError, Word, shared, sql_expr};
|
||||
use crate::dsl::grammar::{
|
||||
HighlightClass, IdentSource, Node, ValidationError, Word, shared, sql_expr,
|
||||
};
|
||||
use crate::dsl::types::Type;
|
||||
|
||||
static COMMA: Node = Node::Punct(',');
|
||||
@@ -60,7 +62,7 @@ const SQL_TYPE_NAME: Node = Node::Ident {
|
||||
source: IdentSource::Types,
|
||||
role: "col_type",
|
||||
validator: Some(validate_sql_type_name),
|
||||
highlight_override: None,
|
||||
highlight_override: Some(HighlightClass::Type),
|
||||
writes_table: false,
|
||||
writes_column: false,
|
||||
writes_user_listed_column: false,
|
||||
@@ -86,8 +88,8 @@ const LENGTH_OPT: Node = Node::Optional(&Node::Seq(LENGTH_NODES));
|
||||
// on its own (ADR-0035 §6.3). The builder maps the pair to
|
||||
// `Type::Real`.
|
||||
static DOUBLE_PRECISION_NODES: &[Node] = &[
|
||||
Node::Word(Word::keyword("double")),
|
||||
Node::Word(Word::keyword("precision")),
|
||||
Node::Word(Word::type_keyword("double")),
|
||||
Node::Word(Word::type_keyword("precision")),
|
||||
];
|
||||
static TYPE_WITH_LENGTH_NODES: &[Node] = &[SQL_TYPE_NAME, LENGTH_OPT];
|
||||
static SQL_TYPE_CHOICES: &[Node] = &[
|
||||
|
||||
Reference in New Issue
Block a user