r/programming • u/tangerines95 • May 10 '21
Inliner: Pull blocks of code into a single file
https://youtu.be/EenznqbW5w8127
u/F4R3LL04 May 10 '21
Cool stuff. Can it be done also for Intellij?
109
u/tangerines95 May 10 '21
If there's enough interest I'd love to build a plugin for Intellij as well
50
u/mpinnegar May 10 '21
I would be happy to donate/crowdfund.
20
u/tangerines95 May 10 '21
Thank you so much for all your support!
11
7
u/Kah-Neth May 10 '21
I would happily pay for a plug-in like this that works for python and c++ in Jetbrains products.
4
7
2
1
14
2
2
-2
u/gnuban May 10 '21
IntelliJ already has built-in inlining, ctrl+alt+N
2
u/andrei9669 May 10 '21
How are you supposed to use it tho? I see the shortcut but can't seem to figure out how to use it.
Edit, found out. yeah, that is totally different thing. This inline shortcut just reverses the extraction, not just displays it.
1
40
u/kakamiokatsu May 10 '21
Will you consider supporting intellij too? I would gladly pay for such a plugin..
19
u/LeCrushinator May 10 '21 edited May 10 '21
Does IntelliJ not having something like this? I'm using Rider (also from JetBrains) and you can open up code like this (albeit in a popup above your code instead of inline), and make changes to it. In Rider it's called "Quick Definition".
EDIT: It seems that IntelliJ has this as well: https://www.jetbrains.com/help/idea/viewing-reference-information.html
13
u/tangerines95 May 10 '21
Hi and thanks for the reply! I wanted to make something that would allow you to inline multiple levels deep, as well as multiple branches.
I’ve personally used the preview feature on VSCode, but it only allows you to preview one function at a time one level deep.
2
u/LeCrushinator May 10 '21
Yea I think that it will be quite useful, and other IDEs should allow for preview windows to be opened within preview windows.
2
u/kakamiokatsu May 10 '21
That's new to me, are you sure it's not some plugin or a specific feature of Rider? You can easily jump to a file but I never saw the ability to inline view and edit a subset of a file. Super duper that it's recursive and you can open up another definition inside the same preview!
3
u/LeCrushinator May 10 '21
I just added some links for Rider and IntelliJ to my original comment, those may help. It doesn't appear to work recursively though.
3
2
u/Kah-Neth May 10 '21
This is a pretty big point, recursive and navigable with keyboard only.
1
u/LeCrushinator May 10 '21
Rider does have a shortcut for it, which can be changed. But yea, not recursive.
1
4
u/tangerines95 May 10 '21
Thank you so much, I'd love to work on something similar for Intellij! If you have some time I'd love to talk to you and learn more :)
2
72
u/habitue May 10 '21
This is really cool. I can't tell you how rare it is to see somebody doing original thinking like this in the IDE. We need a lot more of this!
9
5
u/CJKay93 May 10 '21
Doesn't VS Code already do this? I swear I do this all the time.
12
2
u/willstealyourpillow May 10 '21
It does, yes, though as far as I know you cannot do nested references like this.
2
u/AyrA_ch May 10 '21
Have you maybe used visual studio? Because there it definitely does expand over multiple levels, although it's not as pretty.
2
10
11
u/vattenpuss May 10 '21
Cool stuff!
As a grumpy old Smalltalker it’s always fun to see other IDEs play catch-up.
Have you checked out Code Bubbles? http://www.andrewbragdon.com/codebubbles_site.asp
5
u/PPatBoyd May 10 '21
Does the "go to" link hover the file path? For the cases where generated or copied files are not the source files you need to edit. May even be better to just have the file path and line #s as the "go to" link? Since you already have the function name in the peek
5
u/Leprecon May 10 '21
Gut reaction: oh yeah, lets just put all the code in one file to make it easier...
Thought for more than a second: I want this
2
May 11 '21
It's cool visually, but I'm unsure value is gained over an IDE that has a "click to open location" "go to previous location" buttons/shortcuts.
1
u/bwaxxlo May 16 '21
You clearly dont have ADHD :P. I open files and suddenly 30mins later I've forgotten what I was trying to do with 20 tabs open.
4
u/B_M_Wilson May 10 '21
That’s really cool! I don’t use VS Code but it’s something that I would definitely use if I did
14
u/AttackOfTheThumbs May 10 '21
I guess I don't understand the use case when I can just jump to the definition?
36
7
u/Dimasdanz May 10 '21
faster lookup, i can tell that those who read over engineered DRYed code base would helped a lot. i.e one function call other 3-5 function
2
0
6
u/brulerieelixir May 10 '21
This is pretty cool. I wonder if I'll ever ditch emacs. My friend told me the other day that "Nobody uses emacs anymore"... Are the days of console-based editors numbered?
4
u/eyal0 May 10 '21
I'm still using emacs and I don't find it lacking but maybe there are features that I didn't even know that I need!
If anything, I've been using emacs more lately, and not less, because my code is rarely on my own computer anymore. The storage is in the cloud and the compiler is there, too. I'm not sure how well the visual IDEs work with remote code but it's critical to me. emacs+tramp+lsp is my solution so far.
2
u/Devian50 May 10 '21
VSCode at least supports editing over ssh, and it creates a headless editor "server" on the host and does all the actual work there with its own extensions and such. You could do everything you would on the command line inside VSCode, including the integrated terminal. It even supports ssh port forwarding. Idk how well it'd fit in with your workflow, but it's quite expandable.
-1
u/_tskj_ May 10 '21
What kind of programming do you do where your code isn't local? Hope latency isn't too bad!
2
u/eyal0 May 11 '21
It's pretty common. I write code that needs to run in the cloud or on multiple GPUs. It's faster to compile it on that beefy server. So since I'm already doing everything there, might as well code there. However, I don't want to run emacs on that remote server because there will be more lag and it won't have all my coding configuration.
So I tell emacs to load a file like /ssh:eyal0@server:/tmp/foo and it fetches it for work and then saves it back when I save.
I haven't tried it with LSP yet but it ought to work. This is what LSP was made for!
1
u/_tskj_ May 11 '21
Oh okay I was imagining some kind of ssh-send-every-key-press kind of scheme, that doesn't sound so bad! That seems pretty cool actually, and I'm kind of surprised no other editor can support this, like VS Code?
1
2
u/Aminumbra May 10 '21
Depends on what you do and why. It is simply wrong to say that "nobody uses Emacs anymore". However, you cannot use Emacs the same way as any other text editor/IDE. That being said, if you are willing to spend time learning it, Emacs can definitely be as powerful as any other IDE for programming, while being infinitely more customizable and extensible (and do a lot of things waaaaay better than IDE when it is not purely programming stuff: note-taking, Git, doing things over SSH, not taking 3 minutes to start up and use 2GB or RAM to load an empty file ...)
1
u/tester346 May 11 '21
not taking 3 minutes to start up and use 2GB or RAM to load an empty file ...)
HDD, 2GB RAM and Windows XP?
3
u/dedededede May 10 '21
Really cool idea! I think it comes especially handy when you know the code base already a little and you want to fiddle around.
I guess it's also really nice when you debug. Is it possible to set breakpoints in the expanded snippets?
3
2
u/Kah-Neth May 10 '21
That is so cool!!! I hope you can do the same in JetBrains products like Pycharm.
2
2
u/FormalWolf5 May 10 '21
I've been wondering for some time when someone would finally do something like this. Cool stuff 👀😎
2
2
2
2
2
u/reifactor May 11 '21
I like this in visual studio--you can pop up an inline "peek" window and if you do it again in the window it basically makes tabs that you can move back and forth in.
2
1
u/Sevni May 10 '21
I think this has a potential of getting merged into the main editor, have you ever considered making a pull request?
1
May 10 '21
If this isn't open source/popular then I won't be able to use it at work. Security on things that read the code and all that..
Though I would love to try it for personal project use, this would really help me as I often get lost in tabs upon tabs
1
1
u/TryingT0Wr1t3 May 10 '21
One more vote for Intellij (and CLion).
I am curious if there's a way to work around the linecount but my guess is the line count cannot hold arbitrary line numbers.
1
1
1
u/tester346 May 11 '21
In visual studio you can jump to class/method implementation and then to another, another
and then use "go backward" to jump to the previous cursor position (iirc), so basically you perform deep dive, and then go back to the original place, very handy.
1
0
0
-1
u/Accomplished_End_138 May 11 '21
So I never have seen the purpose of this. I write functionally and I do that just so I don't have this code. And instead I have nicely named functions telling me what they are doing.
-5
u/obvithrowaway34434 May 11 '21 edited May 11 '21
Nope. This basically encourages people to blindly edit code without understanding how a function or class fits with the overall program structure. One of the many reasons for so much shitty and buggy code out there.
-38
u/futlapperl May 10 '21
Neat! Consider implementing it for a programming language next.
4
-64
u/Curmudgeon1836 May 10 '21
You invented #include?
M4, C & C++ compilers, & a host of other tools already do this.
Help me understand what's new here ...
https://www.gnu.org/software/m4/manual/m4-1.4.15/html_node/Include.html
https://gcc.gnu.org/onlinedocs/gcc/Preprocessor-Options.html
37
u/Substantial-Career12 May 10 '21
What are you talking about? Clearly, the innovation here is the user experience?
-47
u/Curmudgeon1836 May 10 '21
Ok, then that should be the focus, not "including files inline" which most editors & many command line tools already do.
25
u/random_runner May 10 '21
I suspect you didn't actually watch the video but went by title alone? It's more of a sneak view rather than pulling the code in. To be fair, I thought something similar until I saw it.
15
u/deja-roo May 10 '21
What are you talking about?
Are you criticizing what he's done here without having a single clue what he did? Did you watch the video? Even the first ten seconds?
-15
u/Curmudgeon1836 May 10 '21
I didn't criticize although everyone else seems quite quick to jump on criticizing me.
I asked a question: Help me understand what's new here.
It's not really that complicated. What he's done is not novel or unique. Tons of editors support what he's doing here. For example, here's the documentation for this feature in Atom:
https://atom.io/packages/goto-definition
So please, Mr. Pot, tell Mr. Kettle more about what he did wrong ...
3
u/deja-roo May 10 '21
I asked a question: Help me understand what's new here.
Yeah, the thing here is that the question should have been really obvious if you had watched the video. It has literally nothing to do with compiling or pre-processor or library includes.
If you don't understand that, then I guess that leads to the question: have you still not watched the video?
-3
u/Curmudgeon1836 May 10 '21
I've watched it. There's nothing new here. Many editors support this functionality. See link above for Atom for example.
6
u/deja-roo May 10 '21
If you watched it, how did you get to this:
You invented #include?
M4, C & C++ compilers, & a host of other tools already do this.
16
u/abc_wtf May 10 '21
It's just a visual thing to help editing a function (which might be in some other file) that a piece of code is calling.
-7
1
May 10 '21
[removed] — view removed comment
1
u/Kimbernator May 11 '21
Yes, but nested and it allows editing the source of the functions you peek at
2
May 11 '21
[removed] — view removed comment
2
u/Kimbernator May 11 '21
I am seeing that it indeed does allow editing like you said (good to know) but nesting doesn't appear to be working for me; peeking at a method call in an inline window fully opens the source file of that method.
In any case you're not wrong about this new plugin not being a groundbreaking addition, but at least it looks a bit prettier.
-20
May 10 '21
[removed] — view removed comment
8
May 10 '21
I'm sorry, what? What large projects don't call functions that call functions that call functions (and so on)? I literally don't think it's possible to avoid this.
-13
May 10 '21
[removed] — view removed comment
5
May 10 '21
You're misunderstanding the tool then, because what I said is the scenario it's used for
-8
192
u/tangerines95 May 10 '21
Link here: https://inliner.io
I’m currently working on a VSCode extension that inlines blocks of code so that you can navigate, understand, and write code more easily than with just definition jumping.
It’s currently only on VSCode with Python and JavaScript supported, but with more languages and editors to come. I’ve added a form that you can use to sign up to be notified if/when I add support for an editor/language.
I’m currently a CS student and I’ve been working on this outside of school. If you guys have any feedback or advice, including what I should work on next, please let me know!