Giter Club home page Giter Club logo

Comments (10)

d11wtq avatar d11wtq commented on September 25, 2024

I'm also a ruby user who uses Pry. I have thought about building more features into Boris, but it hasn't been a priority, since the main thing I was aiming for was something that would not exit when I mistype something, or try something experimental that causes an error. Boris solves that, but I agree it's lacking in features that other REPLs provide. I often find myself hitting tab and getting caught out in boris. If you feel like picking through that readline competion code and bringing it to Boris (in a OO style), I'll gladly merge it ;)

With regards to the reflection/docblock parsing, I'm not as bothered about this, but that's probably just because I don't use those features in other REPLs. I prefer to poke around in the source.

from boris.

michaelwills avatar michaelwills commented on September 25, 2024

Understood. I'm just spoiled by popup documentation in my IDE (IntelliJ) or being able to jump to source there in the IDE. :)

Adding readline wasn't bad. Adding the reflection methods isn't bad but nothing like a full on repl of course. It's just hacked code at the moment. Thanks for sharing the tool.

[edit] I'll have to dig in more later and hopefully I can figure out scope and such. but it's quite a helpful tool as is.

from boris.

d11wtq avatar d11wtq commented on September 25, 2024

Re-thinking this, I think what I'd like to do is have a separate project that does the tab completion in a smart way, then if that works well, the two can get merged together, or that project can grow wings of its own and provide it's own executable (that just loads boris internally). One thing I like about Boris' codebase is that it's really succinct. Adding tab completion "correctly" will bloat the codebase a considerable amount. I'd really like the tab completion to be context-aware (so it knows you're invoking a method, or completing a variable name, or extending a class etc).

from boris.

kleiram avatar kleiram commented on September 25, 2024

How about this function with a nice regex? Shouldn't be too hard to implement right (going to dig into the code now to see how it works!).

from boris.

d11wtq avatar d11wtq commented on September 25, 2024

@kleiram yeah that's the easy part, but what about method name completion instead of function completion, and variable name completion? If I've just typed -> and hit tab, I don't want PHP functions to be auto-completed, I want methods on properties on the current object. That's where it starts to get tricky ;)

from boris.

kleiram avatar kleiram commented on September 25, 2024

I guess you're keeping track of the type of a certain object right? Then, when someone presses tab you can do the following (see ReflectionClass):

$reflection = new \ReflectionClass($type);
$methods    = $reflection->getMethods();
$properties = $reflection->getProperties();

But I'm guessing you already thought of something like that :)

Edit: The ReflectionMethod class has support for getting the doc comment too (but I think there's a better library for that actually).

Edit 2: Another thing that I think is possible is to hook into the autoloading mechanism and watch for classes that are being loaded and parse those only when needed.

from boris.

d11wtq avatar d11wtq commented on September 25, 2024

I'm not keeping track of anything at the moment, so this is another place where it gets bloated ;) readline() provides the last "token" the user typed, so you'd have to grab that string, then ask the EvalWorker (who is the only component that knows what variables exist in the user's REPL session) to find that variable's methods, if it can. I also have a feeling readline only returns the string 'object' if you type '$object' and hit tab. Perhaps that's configurable though. I looked at all this briefly on the first day I wrote Boris, but haven't given any serious amount of time to explore in reality.

from boris.

filp avatar filp commented on September 25, 2024

Sorry for the necro-bump, but someone looking into tackling this, and who can read ruby, may find some interest in pry's fairly simple completion module:

https://github.com/pry/pry/blob/master/lib/pry/completion.rb

I was recently looking at it for another project and it reminded me of this issue 🐱

from boris.

tejasmanohar avatar tejasmanohar commented on September 25, 2024

The link is broken @filp

from boris.

Bilge avatar Bilge commented on September 25, 2024

@tejasmanohar It's here now: https://github.com/pry/pry/blob/master/lib/pry/input_completer.rb.

from boris.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.