Package org.ek9lang.compiler.repair.expressions


package org.ek9lang.compiler.repair.expressions
THE string-expression primitives the selection- and cursor-driven editors share (was the one grab-bag StringExpressionClassifier): the + chain (IsAddExpression, WholeAddChain), the single String literal (StringLiteralOf, IsSingleStringLiteral), and the finders - by selection (ExpressionSpanningSelection) or by cursor (ExpressionAtCursor, ConcatAtCursor, StringLiteralAtCursor, TextMethodAtCursor), all over SmallestExpression. Used by the string-concat rewrite, the E11068 repair, the MCP literal extractor and the IDE's right-click menu. Each is stateless: hold one.
  • Class
    Description
    THE whole + chain (WholeAddChain) round the cursor: the smallest binary + expression containing it, then its chain (was StringExpressionClassifier.findEnclosingConcatExpression).
    Does a rule's token range contain the cursor (line, col)? Both 1-based, the end inclusive.
    THE smallest EK9Parser.ExpressionContext whose token range CONTAINS the cursor (line, col), 1-based - "what expression is the cursor inside" without an explicit selection (was StringExpressionClassifier.findExpressionAtCursor; ExpressionSpanningSelection is the exact-range form).
    THE smallest EK9Parser.ExpressionContext whose token range exactly matches a selection - its TokenRangeOf is [startLine, startCol, endLine, endCol], all 1-based (was StringExpressionClassifier.findSmallestEnclosingExpression).
    Is this expression's outer operator a binary + with two operand expressions? THE "this is a concat chain" gate of the string-expression editors (was StringExpressionClassifier.isAddExpression).
    Is this expression a single string-literal primary - double-quoted or backtick interpolation? The rewriter's idempotency check and the extractor's admission gate (was StringExpressionClassifier.isSingleStringLiteral).
    Does the first rule's character span lie within the second's and differ from it - is it strictly smaller? (Was two identical private copies in StringExpressionClassifier.) By character index, not by tree ancestry - that is IsWithin.
    THE walk every string-expression finder shares: the smallest EK9Parser.ExpressionContext under a root that passes a test, or null.
    THE smallest expression that both contains the cursor and is a single string literal (IsSingleStringLiteral; was StringExpressionClassifier.findEnclosingStringLiteralExpression).
    THE stringLit of an expression that is a single string literal (double-quoted or backtick), or null when the expression is not one (was StringExpressionClassifier.extractStringLit).
    THE text method round the cursor: the smallest EK9Parser.TextBodyDeclarationContext containing it, with the name of its enclosing EK9Parser.TextDeclarationContext (was StringExpressionClassifier.findEnclosingTextMethodDeclaration).
    The resolved text-type and method names, ready to feed straight into ek9_edit_localized_text as textTypeName / methodName.
    THE token-range bounds of an expression as 1-based (line, col) coordinates, [startLine, startCol, endLine, endCol], inclusive on both ends - the shape MCP-tool selection parameters expect; null when the expression has missing token data (was StringExpressionClassifier.tokenRange).
    THE whole + chain a + expression is part of - use it, never a private climb: + groups left to right, so "Hello " + name + "!" is ("Hello " + name) + "!", and the chain is the outermost + reached by climbing while the parent is still one.