Package io.jmix.dynmodelflowui.impl
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprotected static classOne open call while scanning: its receiver, its name, and how many arguments were closed by a comma.static final recordstatic enum -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final DynamicViewHandlerExpressionParser.Positionprotected static final DynamicViewHandlerExpressionParser.Position -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanisIdentifierPart(char c) 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.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.protected DynamicViewHandlerExpressionParser.CallReads the name of the call whose opening parenthesis is atparenthesis, together with its receiver.protected StringReads the dotted path that ends at the dot atdot, walking backwards segment by segment.protected intskipWhitespaceBack(String head, int from) protected booleanstartsArgument(String head, int literalStart)
-
Field Details
-
NONE
-
ROOT
-
-
Constructor Details
-
DynamicViewHandlerExpressionParser
public DynamicViewHandlerExpressionParser()
-
-
Method Details
-
parse
- Parameters:
text- the editor text, which may be incompletecursorPosition- 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
-
memberPosition
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
Reads the name of the call whose opening parenthesis is atparenthesis, together with its receiver. Both are empty when the parenthesis only groups a sub-expression. -
readPath
Reads the dotted path that ends at the dot atdot, walking backwards segment by segment.- Returns:
- the path, or
nullwhen a segment is not a plain name
-
skipWhitespaceBack
-
isIdentifierPart
protected boolean isIdentifierPart(char c)
-