Modern development with JetBrains IDEs

Are you taking advantage of all the cool features your IDE has to offer? Trisha Gee and Florin Pățan explore some of the features available in two popular JetBrains IDEs, IntelliJ IDEA and GoLand. Make developing easier with these cool features.
IDEs are familiar territory for Java Developers, for years our tools have been evolving along with the language to make it as easy as possible to read and write code, and to stay in the flow while doing so. In this article we’re going to show some of features Java developers use to get the most out of IntelliJ IDEA, and then we’ll look at GoLand, the IntelliJ-based IDE for the Go programming language.
Note: in this article keyboard shortcuts will be displayed as Ctrl+E / ⌘E, i.e. Windows/Linux first, MacOS X 10.5+ second.
Code completion
As developers, we know the bottleneck in application development is not typing code but understanding the problem and working out a solution. However, a tool which helps us to write code and explore the solution does make our lives easier.
IntelliJ IDEA has smart code completion that offers the most relevant suggestions. For example, when working with Java 8 streams, when we type the dot after the stream() call, IntelliJ IDEA will automatically pop up the following suggestions, no need to press any shortcut keys:

Figure 1: Auto-complete in action
SEE ALSO: Fresh out of the JetBrains oven: IntelliJ IDEA 2018.2 & GoLand 2018.2 are here
As we type we’ll see the suggestions narrow down.

Figure 2: Autocomplete suggestions narrow after typing
When we’ve selected an operation, we’re going to want to pass some value into the method. We could use the shortcut Ctrl+P/ ⌘P to check the parameters that we need to pass in, or we could just get IntelliJ IDEA to suggest the right thing – pressing Shift+Ctrl+Space / ^ ⇧ Space (smart completion) gives suggestions of the correct type from within the context of the code.

Figure 3: Smart completion for correct type
These suggestions help reduce cognitive load, there’s usually a limited list that corresponds exactly to the correct types, and the ones we use most often are sorted towards the top of the list. This feature is also useful for Java developers getting to grips with lambda parameters, since these are not only fairly new to the language, but are also not straightforward to understand from a method signature.
SEE ALSO: Highlights from the 2018 JetBrains’ State of Developer Ecosystem survey
Generating common code with live templates
Often we find ourselves writing the same shaped code under different circumstances many times. IntelliJ IDEA makes this easier with Live Templates. There are plenty of built in templates, for example those for iterating. Typing it shows the list of available options:

Figure 4: Built-in templates for iterating
If we select an option with the arrow keys (or type the abbreviation in full) and press tab, IntelliJ IDEA will automatically create a loop, and select one of the iterable types in scope to iterate over. For example, typing iter and tab gives:

Figure 5: Narrowing the options
SEE ALSO: The Java of your heart: Trends and preferences from JetBrains’ survey
Refactoring to a better design
Code doesn’t stay set in stone once it’s been written. More mental energy probably goes into processing it afterwards – reading it, altering it, adding to it. IntelliJ IDEA has the ability to automatically refactor code in a number of ways, including many of the refactorings from Martin Fowler’s catalog. We can extract method or extract variable in one move without causing compiler errors or changing the meaning of the code. More complex refactorings like replace inheritance with delegation are also available, so we can change the design of the application without causing errors.
Improving the code with inspections
IntelliJ IDEA helps teams to create consistent code by highlighting, as we type, potential problems, and suggesting alternative code styles. For example, IntelliJ IDEA can go beyond compiler errors and show warnings for things like duplicate Map entries:

Figure 6: Warnings in IntelliJ IDEA
Or suggest using newer language features where they are available:

Figure 7: IntelliJ IDEA is suggesting another option
These inspections are completely customizable and can be shared amongst the team.
SEE ALSO: One month until due date: JetBrains’ Go IDE becomes GoLand
More than a code editor
Staying in the flow is an important part of being productive as a developer. For this reason, IntelliJ IDEA and all the JetBrains IDEs are more than just code editors and compilers. They have advanced features for debugging applications.

Figure 8: Advanced features for debugging
They have full integration with version control systems like Git so we don’t need additional software for visualizing the status of the code history:

Figure 9: Full integration with Git
If there’s a feature that isn’t built in, there’s probably a plugin for it. IntelliJ IDEA has plugins for things like performing code reviews inside the IDE, and also to support almost any language or framework a polyglot programmer may be using.
Sometimes we don’t want an all-singing, all-dancing IDE to do everything for us, but one that will do just exactly what we need for our programming language or framework. For that reason, JetBrains has a number of language-specific IDEs built on the IntelliJ platform, so they inherit all of the common tools like the debugger and version control system integration, but provide an experience that’s customized to a developer using that language. These IDEs include PhpStorm, PyCharm, Rider (for .NET), RubyMine, WebStorm, DataGrip , CLion, and our newest, GoLand.
SEE ALSO: IntelliJ IDEA 2018 progress report: 2018.3 Early Access Program is open!
Go development
Go is growing every day and is now a mainstream programming language. It is used to build everything from micro-service applications, websites, to IoT devices. Building GoLand on the IntelliJ platform allows us to deliver an experience that feels right at home for existing users so they can focus on programming in Go rather than learning a new tool. And for users trying out a JetBrains IDE for the first time, we offer a seamless experience with zero configuration needed out of the box.
Go is a statically typed language and this allows our completion engine to assist the user even in complex scenarios. We try to stay out of the user’s ways in multiple scenarios, one of the best examples for this being managing the imports for them and making sure that they don’t need to worry about having missing or extra import statements, which would cause compilation errors in Go.

Figure 10: Debugging for Go
Thanks to Delve, the open source Go debugger, we have a debugging experience that expands from localhost to Docker-based containers running in remote Kubernetes clusters.
SEE ALSO: Top 5 IDEs for Go
DevOps tools support: Docker, Terraform and Kubernetes
GoLand developers regularly use active open source Go code bases like Docker, Terraform or Kubernetes to test the performance and any new features of the IDE.
We can use GoLand to work with these tools as well. Docker and Kubernetes integration allows us to build and deploy containers without leaving the IDE, and write complex Dockerfile or Kubernetes manifests with assistance and functionality similar to any other programming language. With the Terraform plugin, we can build a whole company’s infrastructure, manage it and optimize it, straight from the IDE.

Figure 11: Docker integration

Figure 12: Kubernetes integration

Figure 12: Terraform integration
SEE ALSO: Which are better for developers, IDEs or text editors?
Not only that…
Like other IntelliJ platform IDEs, GoLand borrows the powerful features of DataGrip, our database focused IDE, to allow users to write, run, and visualize the SQL databases. Together with the support for web technologies from WebStorm like JavaScript, Node.JS, TypeScript and Angular support, we can create full stack modern web services.
All these tools are also available in IntelliJ IDEA Ultimate using the Go plugin, so we can either use a specific, focused IDE like GoLand, or the powerful polyglot programming environment that is IntelliJ IDEA Ultimate. JetBrains IDEs help you with your drive to develop.