Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto-completion feature #205

Merged
merged 5 commits into from
Jul 18, 2016

Conversation

sh19910711
Copy link

@sh19910711 sh19910711 commented Jun 21, 2016

Auto Completion on Web Console

This pull request is to add the "Auto-Completion" feature to help typing commands on Web Console. For example, if people type the TAB key when typing the prefix of some commands, then it shows the list of possible commands from the prefix.

Demo

Demo

Things have not been done yet

  • Testing
  • To support methods
    • >> some.foo<TAB>
  • To support arguments of methods
    • >> somemethod(foo<TAB>
  • To support constant variables
    • >> Some<TAB>
    • >> Some::Thing<TAB>
  • To incrementally refine the list of keywords

Let me know if you have another feature idea of the auto-completion feature.

r? @gsamokovarov # Could you please review the current changes? 馃檱

Thanks.

def eval(input)
"=> #{@binding.eval(input).inspect}\n"
def eval(input, rawdata = nil)
rawdata ? @binding.eval(input) : "=> #{@binding.eval(input).inspect}\n"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of introducing a condition here, can we save the current selected binding in the session object? That way, we can evaluate code in an evaluator object and inspect the variables with the binding itself.

@sh19910711
Copy link
Author

Updated (it's still working in progress).

Currently supported input cases

For now, I have supported below input cases. Any other input case?

>> foo<TAB>
foobar foobaz
>> foo bar<TAB>
barbaz
>> foo.<TAB>
foo.bar foo.baz
>> foo.bar<TAB>
foo.barbaz
>> Foo::<TAB>
Foo::Bar Foo::Baz
>> @foo<TAB>
@foobar @foobaz
>> $foo<TAB>
$foobar $foobaz

r? @gsamokovarov Could you please review the code again? 馃檱

Thank you.

s.is_a?(String) && !s.empty? && !s.match(/[^a-zA-Z0-9\@\$\.\:]/)
end

def context_eval(cmd)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that a Context object is emerging here. Do you wanna move all this code to lib/web_console/context.rb in a WebConsole::Context class. We can feed it the command and have the current global context as state.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you wanna move all this code to lib/web_console/context.rb in a WebConsole::Context class.

Yeah, I wanna do that. 馃憤 Could you show some interface you think?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking about WebConsole::Context as follows:

>> c = Context.new(@current_binding)
>> c.global
>> c.of(obj)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Something similar, yeah.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I will try it

@sh19910711 sh19910711 changed the title WIP: Add auto-completion feature Add auto-completion feature Jul 16, 2016
@sh19910711
Copy link
Author

Updated:

  • Remove "WIP: " from the title of this pull request
  • Add the WebConsole::Context class (ref: d42d509)
  • Simplify interface of the Autocomplete class (ref: 7356115)

I will enhance around template testing 馃檱

@gsamokovarov
Copy link
Collaborator

Great! Thanks for the awesome feature, Hiroyuki. 馃檱

@@ -0,0 +1,46 @@
module WebConsole
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We need a unit-test for that class before release. :-)

@gsamokovarov
Copy link
Collaborator

Thank you so much @sh19910711! I'll straight on merge this one now and we can work on the remaining features in separate smaller PRs.

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.

None yet

2 participants