Touring Plugins – String Manipulation

The String Manipulation plugin allows us to perform a variety of tasks on strings, from capitalizing, converting to camel case, to escaping strings in Java, JavaScript, XML or HTML amongst others.

The plugin itself is pretty straightforward. Once installed, it creates a new entry under the Edit menu as well as a contextual popup.


Operating on it is merely a matter of selecting the string (defaults to current line if no text is selected) and choosing the operation.

Escaping HTMl

Important: The default key binding for the popup is Shift+Alt+M which doesn’t work well with MacOS, but it can be mapped to some other keyboard binding, such as Ctrl+Alt+M, easily via Preferences | Keymaps . Using the context menu is key to efficiency with this plugin so it’s highly recommended to make this change.

Posted in Tips & Tricks | 3 Comments

IntelliJ IDEA 14 EAP 139.69 is Out

If you haven’t noticed yet, a freshly-baked IntelliJ IDEA 14 EAP build is already here with new portion of bugfixes and enhancements.

Hurry and give IntelliJ IDEA 14 EAP a try before its official release. Then share your feedback with us via our discussion forum or the issue tracker!

Develop with Pleasure!

Posted in EAP Releases | 1 Comment

IntelliJ IDEA 14 Will Detect Code Styles on the Fly

If you’ve already tried the latest IntellIJ IDEA 14 EAP build, you might’ve noticed that the Code Style settings offers a new option: Detect and use existing file indents for editing (enabled by default.)

This new option lets IntelliJ IDEA detect certain Code Style settings (such as Use Tab character and Indent size) in the currently edited file on the fly. It means that even if a file has a code style different from your current settings, they will still be preserved.

So now you don’t need to worry about losing the formatting in files that are specific to certain files in your project that differ from the others.

We hope you’ll find these improvements useful. Your feedback as always is welcome, so don’t hesitate to share it in our discussion forum as well as report any bugs directly to the issue tracker.

Develop with Pleasure!

Posted in New Features | Tagged , , | 12 Comments

Live Webinar: IntelliJ IDEA and Vaadin, October 21st

We are pleased to invite you to join Breandan Considine from JetBrains and Matti Tahvonen from Vaadin on how to use the full power of Vaadin and IDEA together. Learn all the tips and tricks and get started with your new IDE in no time!

Sign up and we’ll email you instructions on how to join the webinar closer to the event – all you need is your web browser. Yes, it’s completely free to join.

Matti TahvonenMatti Tahvonen is a Vaadin “R&D veteran” who has been working with our products for over 6 years. His current responsibility is to keep you up to date with latest and greatest Vaadin related technologies. You can follow him on Twitter – @MattiTahvonen
Breandan ConsidineAs a Java developer and technical evangelist at JetBrains, Breandan Considine is interested in human computer interaction, natural language processing, particularly in low-power applications such as mobile phones and wearable devices. You can follow him on Twitter – @breandan

Develop with Pleasure!

Posted in Webinars | Tagged | Leave a comment

Touring Plugins – GitIgnore

I always have a .gitignore file in my Dropbox folder that I copy over for new projects, knowing that any subsequent update to the copy isn’t always synced with the original. Of course, it’s not always necessary either, but it’s something that’s always bugged me.

Recently I ran across a plugin for IntelliJ IDEA (and family) that solves my issue with ignore files.

It’s called GitIgnore Support and as its name suggests it provides support for .gitignore files, but it goes way beyond what you’d imagine at first. Let’s take a look. Continue reading

Posted in Featured Plugins, Tips & Tricks | Tagged | Leave a comment

IntelliJ IDEA 14 EAP 139.1 available, from a release branch already

A fresh update to IntelliJ IDEA 14 EAP is released and you may note we’ve switched to a “release” branch (139) already, so the release is not far away already and we’re in a “stabilization phase” mostly.

We urge you to check the full release notes to compare this build to the previous one.

A number of not so big but important features for everyone was added recently to the editor, including “Go to Next Edit” command, which is the opposite to a very useful “Go to Last Edit”, an additional options to show white-spaces only in front and/or behind and a number of other changes.

We need your feedback now even more than before. It is very welcome in our discussion forum or directly in the issue tracker.

Develop with Pleasure!

Posted in Beta Releases | Tagged , | 13 Comments

The Inspection Connection – Issue #4, Duplication Detection

One of the core principles of computer programming is eliminating manual repetition. Not only is repeated code time-consuming to read and review, it is disproportionately complex to maintain and provides a ready source of bugs when one copy changes. Yet in spite of this, duplicating some code in a large project may be inevitable. IntelliJ IDEA offers a powerful inspection for detecting and deduplicating repetitive code. You can activate this inspection by navigating to the menu entry Analyze|Locate Duplicates, or by pressing Ctrl/⌘+Alt/⌥+Shift+I then typing, “Duplicated Code.”

As it turns out, “Don’t Repeat Yourself” has some notable exceptions, especially when writing unit tests, and occasionally in some rare cases when attempting to outsmart the compiler. IntelliJ IDEA gives you the opportunity to exclude test sources, since many prefer a little duplication in their tests to improve overall readability. Nevertheless, the choice is yours.

duplicates_scopeWhen analyzing a large set of files, you should carefully consider the scope of the inspection you are going to apply. There are a number of algorithms for detecting duplicate code – this one will scan for duplicates by comparing AST fragments. On an Intel i7-2640M with 8GB of RAM, scanning a codebase with 53,000 LOC will take about 3 minutes, or ~300 LOC/second. However your mileage may vary depending on the minimum duplicates length, line density and other factors. When searching for exact matches, the time complexity is effectively linear w.r.t. the number of nodes in your AST.

duplication_analysis_settingsWhen searching for duplicate code, we may want to discard duplicates shorter than some minimum threshold or add a similarity metric in order to detect fuzzy-matches. IntelliJ IDEA lets us define these values, but keep in mind they do not correspond to characters or lines, but rather arbitrary weights. If “Visible from outside of the current scope only” is selected, only subexpressions which are valid outside of their parent construct are anonymized. If you would like to learn more how all of this works, head over to the source.

duplicates_viewAfter scanning, the Duplicates Tool Window is a convenient area to browse through duplicate regions and view a side-by-side diff at each location. From here you can clearly see which sections are structurally similar and flag them for review or refactor them immediately. The highlighter will help you quickly identify which blocks are different.


When you have found a duplicate block of code, it can be easily simplified by pressing Ctrl/⌘+Alt/⌥+M to apply the Extract → Method refactoring. IntelliJ IDEA will transform all inbound variables inside the selected region with parameters and provide a helpful dialog to extract the method, which you can use to replace any other duplicates inside the analysis scope.

extract_method_windowThis inspection is also available in TeamCity, where you can assign a dedicated build runner to periodically scan your project for duplicate code. This may be an even better option if your organization needs regular assurance audits for clean-room engineering. Plagiarism detection is another important use case for the academic community, and if you are a student or teacher, IntelliJ IDEA is now completely free.

Posted in Tips & Tricks | Tagged , , | Leave a comment

The Inspection Connection – Issue #3, Annotation Validation

Android developers will be familiar with the concept of resource IDs, which are unique integers generated by the Android Asset Packaging Tool (aapt) for accessing resources within your application through the static class, R. Resource IDs are assigned to all resources defined inside your project’s /res directory.

In the past, it was common to inadvertently pass one resource type into a parameter that expected another, since they are both integers. IntelliJ IDEA now offers improved support for detecting mismatched resource types, thanks to some resourceful developers on the Android Tools Team. Tor Norbye explains.

Not only is it possible to detect mismatched resource types in Android’s APIs, now you too can leverage resource type checking in your own libraries and APIs on Android 19+, with resource type annotations. Like type annotations in Java 8+, these annotations will help validate parameter values at compile time:

This inspection will detect two forms of resource type mismatches. The first is when you pass one type of resource into a parameter that expects another type, like above. The second will notify you when you have passed a constant into a type that only accepts a specific set of values. Let us consider the following example:

IntelliJ IDEA will detect both of these cases with the inspection Constant and Resource Type Mismatches, enabled by default under Inspections|Android. In order to use support annotations on Android 19+, you can add the following dependency to the dependencies section of your build.gradle file.

In addition to Nullness Annotations available in Android, IntelliJ IDEA 14 now offers a brand new, fully automatic nullity inference inspection based on bytecode analysis, to help you identify sites that may cause NPEs. Together, these features will help you identify bugs much sooner and develop with pleasure!

Posted in Tips & Tricks | Tagged , , | Leave a comment

Touring Plugins – Floobits

Software has become an increasingly cooperative process, both for applications themselves and for those who build them. With today’s developer teams spanning classrooms and continents, good interprocess communication is critical, and Floobits can help.

Floobits is a real-time collaborative editor, a sort of “shared memory” for developers around the corner, or around the globe. We can imagine a few activities where this type of communication is especially useful: interviewing, reviewing and pair programming.

First you will need a Floobits account in order to get started, which is available through Floobits’ website or via your on-premises provider. Next, add a configuration file in your home directory, then install the Floobits’ plugin, as described below.

Once you have configured your development environment and shared a project with the Floobits server, go ahead and add a contributor via your Floobits account. Take some time to explore the browser features. When you’re ready for a real IDE, fire up IntelliJ IDEA.

Here at JetBrains, we have been happily using Floobits for a while and thought we would share an example of how you can use Floobits to collaborate on IntelliJ IDEA or any of the platforms which Floobits supports. Maarten and I take Floobits for a spin.

In SICP, Abelson and Sussman write, “Programs must be written for people to read, and only incidentally for machines to execute.” IntelliJ IDEA gives us the tools to help build and maintain code. Together, with best practices like pairing and regular reviews, we can achieve both.

Special thanks to Geoff Greer, Matt Kaniaris, and Bjorn Tipling for helping fix the bugs.

Posted in Demos, Tips & Tricks | Tagged | Leave a comment

Automatic @NotNull/@Nullable/@Contract inference in IntelliJ IDEA 14

Java annotations are awesome and helpful, but you need to add them by hand. Well, not anymore, because IntelliJ IDEA will do that for you in some quite important cases.

Jars in your dependencies are stuffed with methods and sometimes it may be difficult to tell whether you can pass null there without blowing things up, or whether you should be ready to get null as a method result.

If you’re lucky, the documentation will specify that, if not, you have to read the source code, or even the decompiled output, which is not always as easy as you’d like it to be. There are, of course, NotNull/Nullable annotations available in various frameworks, but not everybody uses them. JDK doesn’t, for example. IntelliJ IDEA supports external annotations, but they also don’t cover most of existing jars.

Well, this is what happens now. IntelliJ IDEA will look carefully at SDK and libraries bytecode and will infer these annotations automatically so that they can later be used to analyze source code to spot places where you overlooked null. You can see these inferred annotations in italic in the editor gutter.

Screenshot from 2014-09-01 17:49:04

Contrary to the already available Infer Nullity feature, this one works with bytecode and is completely automatic: the results are just there in the editor, and you don’t have to do anything to make that happen.

Of course, the logic behind this feature is not as simple as “if a parameter is immediately dereferenced, then it’s @NotNull”. There’s science at work behind the curtains that does a lot more, for example, recursively processes delegating method calls.

Screenshot from 2014-09-02 14:25:29

For methods with a more complex behavior, as you probably know, we have the method contracts. These are now inferred, too. Why is this important? Well, suppose you’re using Apache Commons StringUtils and have such warnings in your code:

Screenshot from 2014-09-02 12:14:58

Earlier IntelliJ IDEA had no clue that code execution wouldn’t even reach the “startsWith” call if the url is null because it didn’t look inside StringUtils.isEmpty. You could of course remove those yellow warnings in extractPrefix by looking inside isEmpty yourself and adding a contract “null -> true”, but that’s so boring! That’s exactly a job for computer, not you, and now IntelliJ IDEA does it automatically, looking at byte and source code.

Screenshot from 2014-09-02 12:25:32

Get the latest preview build and see how this works for you. We are eager to hear your feedback, be it bugs, usability issues or suggestions about more annotations to infer.

Posted in New Features | Tagged , , , | 20 Comments