IntelliJ Community . ReformatPlugin

 
ReformatPlugin 

HOME INDEX SEARCH CHANGES GO  

Description.

ReformatCode (Ctrl-Alt-L) and OptimizeImports (Ctrl-Alt-O) without a dialog. ReformatPlugin.OptimizeImports - works on the current file. ReformatPlugin.ReformatCode - works on the current file or a selection (if there's a selection). Regular actions (ReformatCode and OptimizeImports; with a dialog) are replaced by the plugin's actions. You still have the access to the regular actions (Tools menu).

Plus there's an additional action: ReformatPlugin.ReformatCodeAndOptimizeImports (Ctrl-Alt-R). It does Optimize Imports and Reformat Code on the current file (even if there's a selection).

Options: blankAfterLastMember, newArraySpace, shortenFq. Config file location: ${idea.config.path}/options/plugins/Reformat.xml

Warning.

This plugin uses non-published IDEA API.

Downloads, Bugs, RFEs:

http://sourceforge.net/projects/tz-ip/

How to deploy.

  • Copy the jar file (e.g. Reformat.jar) to the plugins directory ($IDEA_HOME/plugins).
  • Restart IDEA.

Relevant posts/requests:

http://www.intellij.net/tracker/idea/viewSCR?publicId=2389 ("Ability to Reformat Code (Ctrl-Alt-L) and Optimize Imports (Ctrl-Alt-O) with one command") http://www.intellij.net/forums/thread.jsp?forum=3&thread=4680&message=164804 ("Layout Code with option for Optimize Imports?") http://www.intellij.net/forums/thread.jsp?forum=3&thread=4329&message=141644 ("Splitted Reformat Code/Optimize Imports :(") http://www.intellij.net/forums/thread.jsp?forum=3&thread=237&message=3035 ("Layout Code and Optimize Imports")

Key Mapping.

regular action id                   regular keystroke   plugin action id

ReformatCode                        Ctrl-Alt-L          ReformatPlugin.ReformatCode
OptimizeImports                     Ctrl-Alt-O          ReformatPlugin.OptimizeImports
                                    Ctrl-Alt-R          ReformatPlugin.ReformatCodeAndOptimizeImports

blankAfterLastMember option.

Blank line at the end of the class. By default it's disabled (set to false). See also HowToSetAnOption.

http://www.intellij.net/tracker/idea/viewSCR?publicId=249 ("Formatter. Provide "Blank lines after last member" setting") http://www.intellij.net/tracker/idea/viewSCR?publicId=2393 ("Blank lines around method not honored at the end of the class")

class A { // Before

    void f() {
    }
}

class A { // After

    void f() {
    }

}

newArraySpace option.

Space before brace in array initializer. By default it's disabled (set to false). See also HowToSetAnOption.

http://www.intellij.net/tracker/idea/viewSCR?publicId=3228 ("Code Style: support formatting array literals")

new int[]{0, 1} // Before

new int[] {0, 1} // After

shortenFq option.

Shorten fully qualified class references. By default it's disabled (set to false). See also HowToSetAnOption.

http://www.intellij.net/tracker/idea/viewSCR?publicId=9553 ("New code layout action: optimize (shorten) FQCN")

class A { // Before
    java.util.Set set;
}

import java.util.Set;
class A { // After (actually, it depends on your code style settings)
    Set set;
}

How to build.

  1. Specify locations in build-home.properties
  2. ant clean main.

History.

0.6.1 (#896) - Aug 26, 2003

  • Fixed FileNotFoundException bug (reported by Dani).

0.6 (#896) - Aug 19, 2003

  • Works only with Aurora builds (tested with #896).
  • New option: shorten fully qualified class references.
  • Removed wrap single statements option.
  • New location of the options: ${idea.config.path}/options/plugins/Reformat.xml.
  • Now the options data (if it's different from defaults) is not lost if you remove the plugin.
  • API changes (breaks TabifierPlugin).

0.5.1 (#705, #833) - Jun 20, 2003

  • Bug [ 758122 ] ReformatPlugin or TabifierPlugin error.

0.5 (#705, #823) - Jun 17, 2003

  • Bug [ 755684 ] Sometimes enabled options don't work.
  • Bug [ 756094 ] spaceBeforeBraceInArrayInitializer sometimes doesn't work.
  • RFE [ 756107 ] Wrap single statements (for, while, do while, if).

0.4 (#701, #818) - Jun 06, 2003

  • RFE [ 749836 ] BlankLineAfterLastMember, don't touch anonymous classes.
  • RFE [ 736785 ] Space before the brace in "new String[] {}".

0.3 (#701, #818) - May 31, 2003

  • RFE [ 736783 ] Blank line at the end of the class.

0.2 (#701, #813) - May 15, 2003

  • RFE [ 736800 ] Optimize then Reformat.
  • RFE [ 736834 ] Ability to hook up afterReformat listeners.
  • Bug [ 738055 ] NPE at startup for #813.

0.1 (#701, #813) - May 11, 2003

  • ReformatPlugin.ReformatCode, ReformatPlugin.OptimizeImports, ReformatPlugin.ReformatCodeAndOptimizeImports.

-- TimurZambalayev - May 11, 2003

IntelliJPluginWebForm
IntelliJPluginName: ReformatPlugin
IntelliJPluginVersion: 0.6.1
IntelliJPluginVendor: TimurZambalayev
IntelliJPluginBinary: http://sourceforge.net/projects/tz-ip/
IntelliJPluginSource: http://sourceforge.net/projects/tz-ip/
IntelliJPluginClassification:
TopicClassification: IntelliJPluginPackage
TopicShortDescription: Reformat Code (Ctrl-Alt-L) and Optimize Imports (Ctrl-Alt-O) without a dialog. An additional action: 'Reformat Code And Optimize Imports' (Ctrl-Alt-R). Options: blankAfterLastMember, newArraySpace, shortenFq.
TestedOnOS: OsWin2K
ShouldRunOnOS: AnyOS

e d i t a t t a c h r e f - b y d i f f s m o r e
Have ideas, requests, problems regarding this site? Send feedback.
Copyright © 2000-2003 by the contributing authors. All materials at intellij.org are the property of the contributing authors.