Class DynamicViewHandlerExpressionParser

java.lang.Object
io.jmix.dynmodelflowui.impl.DynamicViewHandlerExpressionParser

@Component("dynmod_DynamicViewHandlerExpressionParser") public class DynamicViewHandlerExpressionParser extends Object
Works out what the cursor stands in the middle of in a behavior handler expression, so the Admin UI can decide what to offer as code completion. Pure text analysis: it knows nothing about the sandbox API or the edited model.

The text is scanned once from the beginning to the cursor. Only what a completion decision needs is tracked: whether the cursor sits inside a single-quoted literal, and which call the literal is an argument of. This is not a SpEL parser — the text is normally incomplete while being typed, which no real parser would accept.

  • Field Details

  • Constructor Details

    • DynamicViewHandlerExpressionParser

      public DynamicViewHandlerExpressionParser()
  • Method Details

    • parse

      public DynamicViewHandlerExpressionParser.Position parse(String text, int cursorPosition)
      Parameters:
      text - the editor text, which may be incomplete
      cursorPosition - the cursor position within the text
    • literalPosition

      protected DynamicViewHandlerExpressionParser.Position literalPosition(String head, int literalStart, Deque<DynamicViewHandlerExpressionParser.Call> calls)
      The literal is only an argument slot when it starts an argument — right after the opening parenthesis or a comma. A literal built into a larger argument, as in 'a' + 'b', has no known set of valid values.
    • startsArgument

      protected boolean startsArgument(String head, int literalStart)
    • memberPosition

      protected DynamicViewHandlerExpressionParser.Position memberPosition(String head)
      Classifies a cursor that is not inside a literal: after a dot the receiver decides what applies, otherwise the expression is at its root. A receiver that is not a plain dotted path — a call result, an indexed value — cannot be resolved, so nothing is offered.
    • readCall

      protected DynamicViewHandlerExpressionParser.Call readCall(String head, int parenthesis)
      Reads the name of the call whose opening parenthesis is at parenthesis, together with its receiver. Both are empty when the parenthesis only groups a sub-expression.
    • readPath

      protected String readPath(String head, int dot)
      Reads the dotted path that ends at the dot at dot, walking backwards segment by segment.
      Returns:
      the path, or null when a segment is not a plain name
    • skipWhitespaceBack

      protected int skipWhitespaceBack(String head, int from)
    • isIdentifierPart

      protected boolean isIdentifierPart(char c)