java.lang.Object
com.darkcollective.relix.ast.internal.Identifiers

public final class Identifiers extends Object
Delimited-identifier rendering for round-trippable pretty-printing.

Relix reserves a fixed set of operator and keyword words (SELECT, SORT, ORDER, GROUP, JOIN, …). A relation, column, or alias whose name collides with one of them — or that is otherwise not identifier-shaped — cannot be written bare: it must be wrapped in backticks so the lexer reads it as a plain name rather than the operator, e.g. `order` references a relation named order. render(String) applies that wrapping only when needed and leaves ordinary names untouched, so canonical pretty-printer output is byte-for-byte unchanged for the overwhelmingly common case.

The reserved-word set is intentionally duplicated here because relix-ast is the base module and cannot depend on relix-parser (which owns the lexer). A guard test in relix-parser (DelimitedIdentifierLexerTest) asserts this set stays a superset of the lexer's live keyword table (Lexer.reservedWords()), so a newly added keyword can never silently start printing un-delimited.

A qualified name (Users.id) is delimited per dotted segment (`Users`.id only if Users needs it) — the common case. The one ambiguity this cannot recover is a single delimited name that itself contains a literal dot (`weird.name`): the AST stores it as the bare string weird.name, indistinguishable from a qualified reference, so it re-renders as two segments. Such names are vanishingly rare.

  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean
    Whether word is a reserved operator/keyword (case-insensitive).
    static boolean
    Whether a single name segment cannot appear bare and must be backtick- delimited: it is empty, not identifier-shaped, or a reserved word.
    static String
    render(String name)
    Renders a (possibly dotted) name for pretty-printing, delimiting each segment that needs it and leaving ordinary names unchanged.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • isReserved

      public static boolean isReserved(String word)
      Whether word is a reserved operator/keyword (case-insensitive).
    • needsDelimiting

      public static boolean needsDelimiting(String segment)
      Whether a single name segment cannot appear bare and must be backtick- delimited: it is empty, not identifier-shaped, or a reserved word.
    • render

      public static String render(String name)
      Renders a (possibly dotted) name for pretty-printing, delimiting each segment that needs it and leaving ordinary names unchanged.
      Parameters:
      name - the stored name (bare or dotted); null renders as ``
      Returns:
      the name, ready to parse back to the identical name