Comments (10)
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.
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.
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.
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.
@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.
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.
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.
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.
The link is broken @filp
from boris.
@tejasmanohar It's here now: https://github.com/pry/pry/blob/master/lib/pry/input_completer.rb.
from boris.
Related Issues (20)
- Feature request: add dependencies to the readme HOT 1
- Broken backwards compatibility HOT 11
- Previous and next command with up and down arrow not working HOT 7
- Segmentation Fault HOT 11
- Bug: "use" and "::class" doesn't return the same class. HOT 2
- Undefined variable: boris in .borisrc HOT 1
- CTRL+U incorrect behaviour HOT 4
- Delete key produces tilde HOT 4
- Unicode characters were not accepted HOT 2
- Curly braces used for object property dereferencing cause parse error
- Demo URL is broken in readme file HOT 1
- Can not echo global variable HOT 1
- Packagist no longer has different version based of tags HOT 3
- HTTP Clients may fail silently
- SemVer breakage. HOT 1
- do/while loop doesn't work. HOT 1
- Composer >1.3.0 compatibility
- Support strict types.
- Redefine class/functions
- Demo link returns "Not Found"
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from boris.