4 ms·
> Well, the debate is now over. In order to get IntelliSense to work correctly, bottom-up programming is best. IntelliSense wants every class, every method, eve
by ninkendo 5y ago
> Well, the debate is now over. In order to get IntelliSense to work correctly, bottom-up programming is best. IntelliSense wants every class, every method, every property, every field, every method parameter, every local variable properly defined before you refer to it. If that’s not the case, then IntelliSense will try to correct what you’re typing by using something that has been defined, and which is probably just plain wrong.
This gives me an idea: somebody should make an inverse intellisense that lets you type as if a function exists that you haven’t created yet, and instead of using a bunch of red squigglies and making you feel like a fool for typing broken code, offers you a shortcut to create the code that doesn’t exist yet.
Bonus points if it uses the language’s type inference to inform what to create, like:
String s = foo.bar(someInt);
Would offer a quick way to make the stub:
// (class of foo)
String bar(int someInt) {
// TODO
}
There’s probably tons of ways to make this super ergonomic too, maybe with an easy keyboard shortcut (maybe if ctrl+space triggers intellisense, ctrl+enter could trigger the “make stub” functionality) and could work quickly and with no fuss. The method just gets added in the background, you don’t even see it, you just get to keep typing out your train of thought.
This could be extended to more than just methods, but whole classes/structs/etc.
I know IDE’s have lots of affordances for creating new code from templates/quick actions, but there would be something magical about being able to just type out your mental model at the current abstraction layer, all at once without distraction, and have the IDE better help you “make real” the code you just referenced.
- gregors 5y agoThere's a code first approach that's pretty common in VS - but it's at the class level - Just write the code inline and click on it and it generates the class/method stub. So What you are suggesting already exists in standard VS. The tweaking of allowing possible results in the dropdown is a very very interesting idea - imagine if you let copilot suggest possible methods based on the domain context of the current project.
- ninkendo 5y ago> pretty common in VS - but it's at the class level I haven’t used VS in over 10 years - what does “at the class level” mean? Does it only create stubs for the current class, or any class that’s in the current project? It is interesting that VS has this at all though, as a daily Xcode user I’m jealous. Especially because ObjC and Swift have first class (and popular) ways to add methods to classes you don’t own via extensions… the concept of adding new methods automatically as you type is even more attractive in this ecosystem.
- gregors 5y agoSorry I said "class level" since that is what I remember specifically but I think it's actually everything. Classes, methods, types - also I mis-remembered that this was built in. It's actually resharper which I always used. https://www.jetbrains.com/help/resharper/Code_Generation__Generating_Code_from_Usage.html https://www.jetbrains.com/help/resharper/Code_Generation__Ge... It's been a hot minute since I used it, but it really is exceptional.
- bradrn 5y ago> instead of using a bunch of red squigglies and making you feel like a fool for typing broken code, offers you a shortcut to create the code that doesn’t exist yet. The Haskell Language Server allows this. On the other hand, its autocomplete doesn’t seem to work so well yet (at least on Emacs), so I guess it’s not really comparable.
- deleted 5y ago[deleted]
- syastrov 5y agoJetBrains IDEs can generate methods for undefined names if you use an intention activated by ctrl+enter (or alt, I can’t remember)
- daigoba66 5y agoNot sure about other IDEs, but Visual Studio pretty much does exactly this and more (for C# anyway). You can pretty much design an entire class by first _using_ it and then use Intellisense to generate the class/method/property stubs all with the correct types.