...
The main idea is to extend existing org.apache.flink.table.client.cli.SqlMultiLineParser . => No need to use Flink SQL parser
It should check the input if all quotes, comments, hints, brackets (square and round) are closed otherwise it throws new EOFError - normal behavior in jline in case input should be continued on a new line.
During parsing need to keep track of cursor states if it is a comment, keyword, quoted string.
...
This track could be used to answer a question at what state parser by the end of a query.
Also such track , if there is with recorded state for every cursor position , could be used to do highlighting.
...