Skip to content

Add parseForComplete method to Parser interface and use it. - #2

Closed
PerBothner wants to merge 1 commit into
jline:masterfrom
PerBothner:completer
Closed

PerBothner wants to merge 1 commit into
jline:masterfrom
PerBothner:completer

Conversation

@PerBothner

Copy link
Copy Markdown
Contributor

We provide a default implementation of parseForComplete (just call parse),
but an override allows clients more flexibility with less overhead.

I was having problems getting tab-completion working with Kawa. One reason is that Kawa's parser is fairly complex, and I want completion to be context dependent - which means it also needs to parse and analyze the partial line. So you're getting two parses (which is wasteful), plus the first parse doesn't know it's in completion context (and thus shouldn't throw EOFError).

Creating and using a new parseForComplete method seemed like a simple and clean solution. Kawa command completion now works again with jline3.

An alternative is to add a flag to the parse method (perhaps an enum, since there are a multiple different contexts that parse is called).

We provide a default implementation of parseForComplete (just call parse),
but an override allows clients more flexibility with less overhead.
@PerBothner

Copy link
Copy Markdown
Contributor Author

Ping? Is this a acceptable solution to the problem mentioned in the pull request?

@gnodet

gnodet commented Jun 15, 2016

Copy link
Copy Markdown
Member

Sorry, I missed the PR. I'd rather having an enum, that would be more explicit, as I'm not really sure there's a "default" context really.
Do you mind introducing such an enum in the Parser interface and update the PR ?

@PerBothner

Copy link
Copy Markdown
Contributor Author

Ok - I created pull request #4.

hyee added a commit to hyee/jline3.29 that referenced this pull request Apr 29, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants