Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Apache Druid Hjson Ace Mode

From Leeroopedia
Revision as of 14:14, 16 February 2026 by Admin (talk | contribs) (Auto-imported from implementations/Apache_Druid_Hjson_Ace_Mode.md)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Knowledge Sources
Domains Web Console, Syntax Highlighting
Last Updated 2026-02-10 10:00 GMT

Overview

Registers a custom HJSON syntax highlighting mode for the Ace editor used in the Apache Druid web console.

Description

This module defines and registers an HJSON (Human JSON) language mode with the Ace editor framework. It provides tokenization rules for HJSON syntax elements including comments (single-line, multi-line, and hash-style), strings (quoted and unquoted), multiline strings (triple-quoted), numbers, constants (true, false, null), key names, arrays, objects, and root objects. The module is a modified version of the brace library's HJSON mode, with folding functionality removed to avoid conflicts when loaded alongside the SQL mode.

Usage

Call initAceHjsonMode() during application initialization before any Ace editor instance needs to use HJSON syntax highlighting. This is typically invoked once at startup so that ace/mode/hjson becomes available as an editor mode.

Code Reference

Source Location

Signature

export function initAceHjsonMode(): void

Import

import { initAceHjsonMode } from './ace-modes/hjson';

I/O Contract

Inputs

Name Type Required Description
(none) - - This function takes no parameters. It uses the global ace instance from ace-builds to register the mode.

Outputs

Name Type Description
(void) void Registers ace/mode/hjson_highlight_rules and ace/mode/hjson as Ace modules as a side effect. No return value.

Usage Examples

Initializing HJSON Mode at Application Startup

import { initAceHjsonMode } from './ace-modes/hjson';

// Call once during app initialization
initAceHjsonMode();

// Then set the editor mode
editor.getSession().setMode('ace/mode/hjson');

Internals

Highlight Rules

The HjsonHighlightRules class defines tokenization rules for these HJSON constructs:

Rule Group Token Type Description
#comments comment Hash (#), single-line (//), and block (/* */) comments
#constant constant Boolean literals true, false, and null
#keyname keyword Object key names (quoted or unquoted) followed by a colon
#string string Double-quoted strings with escape sequence support
#mstring string Triple-single-quoted multiline strings
#ustring string Unquoted string values (HJSON extension)
#number constant.numeric Integer and decimal number literals
#object paren Curly-brace-delimited objects
#array paren Square-bracket-delimited arrays
#rootObject paren Root-level key-value pairs without braces

Mode Configuration

The HJSON mode supports:

  • Line comments: //
  • Block comments: /* */
  • Mode ID: ace/mode/hjson
  • File types: .hjson
  • Scope name: source.hjson

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment