Archive for the ‘How-To's’ Category

Refactoring in IntelliJ IDEA, Live by Robert C. Martin (Uncle Bob)

Monday, September 12th, 2011

It’s still over 3 months before the holiday season, but we just got a great present from our long time friend Robert C. Martin (Uncle Bob) — a live refactoring demo performed by the legendary software expert himself. He’s, of course, using IntelliJ IDEA!

Check out this video where Uncle Bob shows some refactoring techniques transforming a “large and ugly” function into a clean and readable piece of Java code, using such refactorings as Rename, Extract Method, Inline Variable, and others. We learn something new every time we watch experts like Uncle Bob.


You can also watch this video on JetBrains TV.

The video is part of the highly recommended “Clean Code” series of educational “code-casts.” More Clean Code videos are available at cleancoders.com.
Robert C. Martin (Uncle Bob) is the Master Craftsman at 8th Light Inc., 8thlight.com.

As a separate note, Robert C. Martin has recently released a new book “The Clean Coder: A Code of Conduct for Professional Programmers” which we think is a must read for every professional software developer.

Enjoy the demo and develop with pleasure!
-The JetBrains Team

Want more effective IntelliJ IDEA screen estate?

Friday, July 8th, 2011

Have you noticed a small new button in the bottom left corner of IntelliJ IDEA window since version 10.5?
It lets you have more space in the main frame and give more prominence to the editor by hiding the tool window bars.

With the tool buttons hidden you, of course, still can access the tool windows using their numeric hotkeys, e.g. Alt+1 for Project view, Alt+9 for Changes, etc.

But if you need to refresh them in your mind, or want to open one with the mouse, you can show the tool window buttons just for a moment. To do that, hit the Alt key twice (Command key on Mac), and keep it down — while the key is pressed, the tool window buttons are visible. Release the key — and they disappear again, leaving your main frame large and spacious.

Give it a try if you have not yet!

Control your Perforce connection

Wednesday, June 1st, 2011

In IntelliJ IDEA 10.5 we’ve improved setting up your Perforce server connection and connection state diagnostics.

Configuring connections

If you are using P4CONFIG files for configuration, IntelliJ IDEA shows what config files it has found and what other default settings are used. This way you can be sure that your P4CONFIG files are found and taken into account.

Use the ‘Test Connection’ button in ‘Settings | Version Control | VCSs | Perforce’ to see this information.

Moreover, in case you specified a wrong client workspace and your project roots do not match with the workspace roots, you are also clearly prompted:

Perforce connection parameters dialog

If you are not authenticated to the server or the authentication ticket has expired, you will be notified accordingly:
Not logged to Perforce notification

Offline mode

Once Perforce server becomes unavailable, IntelliJ IDEA switches to the offline mode automatically and displays an offline notification.
"Perforce is offline" notification

In the offline mode, you can continue working locally as usual, file checkouts are remembered by IntelliJ IDEA to be further re-played. When going online IntelliJ IDEA requires that you authenticate on the server and the ticket is not expired. This is important to re-play you offline edits properly.

New in 10.5: Develop Mobile AIR Applications for Android

Wednesday, April 27th, 2011

Latest EAP of IntelliJ IDEA 10.5 supports full cycle of Mobile AIR applications development: write code, compile, package, install, run and debug on emulator or Android device! Let’s look at common development workflow. (more…)

Find Table/Column Usages Searches Database Schema

Friday, April 22nd, 2011

In IDEA 10.5 “Find Usages” (Alt-F7) results for tables and columns include database schema usages, i.e. references in indices, primary and foreign keys, see screenshot below:

Develop with pleasure!

More flexible and configurable @Nullable/@NotNull annotations

Tuesday, March 29th, 2011

For quite a while IntelliJ IDEA can detect probable NPE’s in your code. But you have to annotate it with JetBrains’ @Nullable/@NotNull. In order to leave your code free from JetBrains’ annotations you could use external annotations, but they were not so convenient to use as they were not visible in the code. With libraries and SDK code, however, there is no other way except using the external annotations.

So, to make things better, 10.5 IntelliJ IDEA will be able to recognize the most common annotations, such as javax @Nullable/@Nonnull, FindBugs @Nullable/@NonNull, as well as your own annotations with the same semantics.

You just need to configure which annotations are allowed in you code and which should be used by quick fixes to annotate the code.

Try it in IntelliJ IDEA 10.5 EAP and let us know what you think.

Smarter and Faster Introduce Parameter in Java

Thursday, March 24th, 2011

As a logical next step after inplace introduce variable refactoring we did in IntelliJ IDEA 10, version 10.5 will offer inplace introduce parameter.

Here is a brief overview of what we’re working on.

Once called, it will gently ask you to choose a method you want to add parameter to

Note, that you can introduce parameter in hierarchy by selecting the “Use super method of” option.

Then you’ll get a familiar template-like editor with a possibility to change parameter type and name. The refactoring settings you’ve got used to have in the dialog, are now available during template editing. You can make the parameter final, and generate method delegate, to remove unused parameters and replace field usages with getters. When multiple occurrences found you will be able to replace all of them or decide to replace only one right in place. No need to rerun the refactoring to see the results — they are already in the editor.

All method usages are already processed once you finish typing.

Just make sure you have inplace refactoring enabled in ‘IDE Settings | Editor | Enable in place refactorings‘.

The feature will be available in IntelliJ IDEA 10.5 EAP.

Watch our progress on inplace refactorings and let us know what you think!

Advanced GitHub Integration: Rebase My GitHub Fork

Tuesday, February 1st, 2011

Hello guys,

We’ve already described the basic GitHub integration features on IntelliJ IDEA before. Here comes more advanced stuff.

We’ve made lots of improvements since then, but the main new thing to talk about is GitHub rebase support. GitHub provides an easy way of forking someone’s repository, however it is pretty natural for the development to keep your sources up-to-date. In the latest version of the IntelliJ GitHub plugin you can rebase your own fork onto the origin in several clicks.

Here is a small howto:

  • Let us consider that we had forked someone’s repository on the github.com, and have checked out your own fork using Checkout From the GitHub action. In this case you’ll notice a new menu item: Version Control | Git | Rebase my GitHub fork
  • In order to rebase onto the origin repository it is necessary to add it as new remote. But you’ll be prompted to add it automatically.
  • After having your origin successfully configured you’ll be able to rebase your own fork.

And yet another small but useful feature is the ability to quickly browse your code on the Internet. Open in browser is available from the context menu.

All GitHub features are available even if you have your own GitHub installation (http://fi.github.com), just configure the GitHub host in IDE settings and voila, everything works out of the box!

The next major feature scheduled is the support for github pull requests and full roadmap is available here. Do not hesitate to let us know what you think about and if you’d like any other GitHub specific functionality to be added. Enjoy using GitHub with IntelliJ GitHub integration!


And watch this short screencast demoing creating a new GitHub repository from IntelliJ IDEA project and cloning an existing one as a new project (also available at JetBrains.TV).

-Develop with pleasure!
JetBrains Team

Change Method Signature Refactoring for ActionScript and Flex

Thursday, December 9th, 2010

Hi all ActionScript/Flex devs! I hope you enjoy using IntelliJ IDEA and I’m sure you’ll like it even more after you try Change Method Signature refactoring! It’s amazing how it allows you to quickly restyle your methods not only by renaming them, but also by adding, reordering, renaming, and deleting parameters, changing their types and default values.

All usages and overriding method declarations will be updated automagically, so your application compiles and works the same way as before with no extra care from your side!

Let me show you how it all works.

(more…)

How to Run a Single Inspection in IDEA X?

Saturday, November 20th, 2010

To run a single inspection in previous versions of IntelliJ IDEA you had to create a dedicated inspection profile for that or use “Run inspection on…” from inspection’s quick fix list. In IntelliJ IDEA X you can find and run inspection by its name on any scope without creating an inspection profile. Use Run Inspection by Name (Ctrl+Alt+Shift+I) action anywhere to choose a desired inspection from hundreds of available,

then select a scope to run inspection on,

and get results.

This action is available since version 98.402 in Main Menu-> Analyze->Run Inspection by Name.