r/programming • u/brunocborges • Jun 15 '19
Announcing the Visual Studio Code Installer for Java
https://devblogs.microsoft.com/visualstudio/announcing-visual-studio-code-java-installer/
840
Upvotes
r/programming • u/brunocborges • Jun 15 '19
12
u/vqrs Jun 15 '19 edited Jun 15 '19
I'll try to list a few things that others haven't mentioned yet.
VSCode has very very limited refactoring support, I'm sure more's to come because it's JDT (Eclipse) based, but currently it doesn't do a whole lot.
It can rename a symbol, extract a method and then that's about it very very soon.
IntelliJ for instance can migrate types and propagate type changes across entire call chains, fields, local variables, generic types etc where you get to choose where you want that propagation to stop and it'll tell you in advance where there will be compile errors after you run that refactoring. That's just one of the more advanced examples.
Or you'd like to extract out a certain part of a method not merely as a parameter, but use some functional interface instead and pass that bit of code as a lambda at the call site so you can invoke it differently somewhere else? IntelliJ can do that.
You are doing some heavy duty code changes and you wish you could define your own code transformation rules? IntelliJ can do that (structural search and replace, basically AST based pattern matching)
Of course, there are many more refactoring tricks it's got up its sleeves.
You are writing SQL inside your Java program and would like syntax checks? IntelliJ ultimate can do that. You would also like it to tell you when you've used a column that doesn't exist in your SQL? Tell IntelliJ where your databases are and it can do that. Did you split the SQL over several lines and used concatenation? Still works and much more.
Want to search your entire code base and get matching results as you type? IntelliJ can do that. VSCode uses ripgrep for that which is very fast, but it's different from indexing your source files such that most of the time, IntelliJ doesn't need to scan every file if you want to see all results.
And while we're at it, why not full text search all the library sources inside JARs with the same speed while we're at it? It does that, too.
Want to know where a variable's value can come from through an arbitrary chain of calls, field accesses from "unrelated" methods etc etc? It can do that. (use with care, it doesn't always find everything), but it's great to get an overview immediately without doing any work,especially in large code bases where you can't keep everything in your head.
You want to see only code completions that actually make sense? Or be recommended to use a sensible static method you haven't even imported yet or forgot existed? IntelliJ does that. You need to pass a functional interface and would like your IDE to recommend you which method references on objects or other stuff that's in scope you could pass? IntelliJ does that. You don't even need to choose what object's method references you want. As long as you have an inkling of what the method might be called, just start typing that, hit the smart completion shortcut once or twice and you'll get what you want. Unless you use Strings everywhere and all your methods return strings... Of course. Then you still end up with many possibilities.
Want instant warnings for code that probably doesn't make sense but compiles as you're typing even while the code is not syntactically correct? IntelliJ does that.
You can even easily define your own warnings for your project specific patterns that are known to be problematic.
Too lazy to fill in all other missing switch branches on an enum? IntelliJ does that.
Want to remove the surrounding try block two levels up because you don't need it? IntelliJ does that.
Want to flip around your if and else breaches while preserving semantics because you decide it would read better? IntelliJ does that.
There's tons of things IntelliJ can do. The last few I've mentioned are minor things, but once you get used to them, you'll end up using them all the time.
It gets to the point where you feel like the IDE can write most of the code for you. Using VSCode will then feel like work because you don't have access to all the code transformations.
If you have a question, feel free to ask.