Posts Tagged ‘Refactoring’

WSDL improvements in IDEA X

Wednesday, September 15th, 2010

If you work a lot with WSDL, you will find new IntelliJ IDEA X refactorings, code completions and validations very handy. Be it schema or WSDL, import inside a WSDL document is not a problem anymore.

Also, we are looking forward to your feedback regarding WSDL.

Smarter Introduce Variable in JavaScript

Wednesday, August 18th, 2010

Introduce variable is a very useful refactoring and is probably used quite often and for many languages IntelliJ IDEA supports. JavaScript is one of them (along with ActionScript).

IntelliJ IDEA 10 makes this refactoring even easier and more pleasant to use. Below is a simple example with highlights for the enhancements. (more…)

Maven refactorings: Introduce Property

Tuesday, April 20th, 2010

Sometimes while editing pom.xml one needs to define a property and replace the occurrences of some value - artifact version, for example, - with this property. Now you can use the new IDEA  Introduce Property refactoring for these purposes.

To invoke refactoring, select the string that should be replaced and press Ctrl-Alt-V (alternatively, you can use Maven/IntroduceProperty action in the editor context menu). In dialog enter the property name and select the pom to create the property in:

Introduce Property dialog

Introduce Property dialog

Refactoring finds all the occurrences of the selected string in the poms hierarchy and replaces them.

More refactorings will be added soon.

Any comments are appreciated.

New ActionScript/Flex Refactoring: Push Members Down

Wednesday, November 25th, 2009

In addition to other refactorings, Maia also has this useful refactoring: push members down the classes hierarchy.

Again, let’s try it on a simple example.

(more…)

New ActionScript/Flex Refactoring: Pull Members Up

Wednesday, November 11th, 2009

Today we’re continuing our series of posts about new ActionScript/Flex refactorings that you can find in the latest Maia EAP, with presentation of this new aid: pull class members up the classes hierarchy.

Let’s have look at this simple example. (more…)

New ActionScript/Flex Refactoring: Move Static Members

Thursday, November 5th, 2009

Next Maia’s EAP will bring you new refactoring that helps to be more productive when coding ActionScript or Flex.

Now you can easily move static methods, properties, fields and constants between AS classes and Mxml components: just place caret on a member (or a reference to it) and hit F6 (Move action).

(more…)

Inline Variable Refactoring for JavaScript / ActionScript

Monday, September 21st, 2009

Next version of IntelliJ IDEA, code named Maia, brings you several new JavaScript and ActionScript refactorings. In this post we showcase one of them — Inline Variable, which works with local variables and ActionScript class fields.

Before Inline Variable

Pressing Control+Alt+N (default Windows keymap) replaces variable occurrences with an initializing expression.

After Inline Variable

During the inline process, IntelliJ IDEA checks if a variable can be safely replaced and warns if, for example, there are its usages inside a functional expression.

Problem detected when inlining variable

By the way, the Inline Variable refactoring also works in the left part of local variable assignment.

Enjoy developing with pleasure!

Structural search and replace

Friday, March 31st, 2006

Searching through a large project is always tiresome. Changing a large project is usually more tiresome even with all cool IDE features such as search by regular expressions, find usages, or automated refactoring.
For example, you may need to find all the classes that implement exactly two interfaces or find all methods that accept a parameter with a specific name and/or type. Finding usages or simple search may produce too long lists of results, especially if your project is really large.
The solution suggested by IntelliJ IDEA is Structural Search and Replace (SSR) where you can define the code pattern to narrow the search scope.

Let’s consider an example when you need to find all inner classes in your project. The search template will look as follows:

class $Class${
   class $InnerClass${}
}

Here $Class$ and $InnerClass$ can be any class names.
If you need to find an inner class that implements, let’s say, Runnable interface you can write the following:

class $Class$ {
   class $InnerClass$ implements Runnable{}
}

To find all the inner classes that implement any interface, it is enough to write this:

class $Class$ {
   class $InnerClass$ implements $Interface${}
}

If “any interface” is not what you need, it is possible to apply powerful constraints to the variable.
Of course, you can also use the templates for replacing the found code. For example, you may wish to convert all the found classes to become final. The screenshot shows how it looks in IntelliJ IDEA user interface.

”Screenshot”/

Once created, a template can be saved and then reused. And of course, IntelliJ IDEA provides a lot of predefined templates.
Get interested? Learn more about SSR in Structural Search and Replace: What, Why, and How-to written by Maxim Mossienko, one of the JetBrains developers and originator of the Structural Search and Replace feature.

Note   This tip was originally posted at www.javalobby.org.


Technorati tags: ,