IntelliJ Community . SmartIntroducePlugin

 
SmartIntroducePlugin 

HOME INDEX SEARCH CHANGES GO  

SmartIntroducePlugin

Purpose

This plugin was born out of the discussion about more reasonable default-selections for the various Introduce-X refactorings. For more info about the discussion, see here: http://www.intellij.net/tracker/idea/viewSCR?publicId=14308

Description

The plugin tries to make a more reasonable selection than selecting the whole line if an Introduce-X refactoring is invoked without any selection. Currently, it intercepts the Introduce {Variable, Constant, Field} refactorings of which each one can be disabled.

The plugin traverses the expression-hierarchy up from where the editor-caret is and rates those expression by different criteria. If there is more than one possible expression, a selection dialog is shown where the user can select the one that is desired.

The ratings for each criterion are configurable for the different intercepted refactorings. The configuration can also be set to a Google-like "I'm feeling lucky" mode, in which the plugin will use the highest rated expression without user-interaction.

Usage

Just invoke the refactoring as usual. If the plugin determines that there's only one reasonable expression to be refactored, it selects this expression and shows the usual dialog. If there are several expressions, a selection dialog is shown where you can select the appropriate expression first.

Configuration

The plugin's "master switch" can be found at "Options -> Smart Introduce Plugin" which completely disables the plugin. Other options, such as selectively enabling the plugin for special refactorings, the "I'm feeling lucky" switch and fine-tuning for the expression-rating can be found at "Options -> IDE Settings -> Smart Introduce"

Important Notes:

  • This plugin makes heavy use of the unofficial PSI-API. For PSI usage-terms please see ProgramStructureInterface.
  • The plugin intercepts core functionality of IDEA. If you experience errors/crashes while using any of the intercepted Introduce-refactorings, please check the strack trace to see whether it contains code associated with this plugin before posting SCRs in the tracker.
  • The plugin was developed and tested with IDEA build #873

Plugin Development

Please see the topic SmartIntroducePluginDev?, any feedback is welcome smile

Plugin Installation

  • Download the binary JAR file (see below)
  • Place this file in your <IDEA-HOME>/plugins directory.
  • Restart IDEA

History

Version 0.1 (2003-07-24)

  • Very first version. Only intercepts Introduce Variable, no user-selection of expressions

Version 0.9 (2003-07-26)

  • Works for Introduce Variable, Constant and Field
  • User-selection of possible expressions to refactor
  • Configurable expression rating

Version 1.0 (2003-11-24)

  • Added support for Introduce Parameter
  • Small bugfixes
  • Internal refactorings

Version 1.0.1 (2003-12-09)

  • IDEA build #992 compatibility
  • Removed all usages of Generics code

Version 1.0.2 (2003-12-23)

  • IDEA build #1024 compatibility: Moved master switch to Tools menu

Version 1.0.3 (2004-01-17)

Version 1.1.0 (2004-01-28)

Version 1.1.9 (2004-01-30)

  • Bugfix: Extract Method was excluding trailing semicolons, causing it to fail
  • Extract Substring: Possibility to extract as 'native' type for boolean & numeric literals

Version 1.3.0 (2004-07-04)

Version 1.4.2 (2004-11-07)

  • Added support for "Surround With" selection
  • Support for Irida-EAP builds

Acknowledgements

  • Stephen Kelvin for the original idea in his SCR
  • Amnon I. Govrin for the idea about the ability to select an expression
  • TimurZambalayev for his TabSwitchPlugin and CamelPlugin which I borrowed some ideas from.
  • Others, in no particular order: Bas Leijdekkers, Gordon Tyler, Alain Ravet

-- SaschaWeinreuter - 13 Jul 2004

IntelliJPluginWebForm
IntelliJPluginName: SmartIntroducePlugin
IntelliJPluginVersion: 1.4.2
IntelliJPluginVendor: SaschaWeinreuter
IntelliJPluginBinary: http://plugins.intellij.net/pluginManager?action=download&id=SmartIntroduce&build=2165
IntelliJPluginSource: http://www.intellij.org/twiki/pub/Main/SmartIntroducePlugin/SmartIntroduce.zip
IntelliJPluginClassification: CodeHelper?
TopicClassification: IntelliJPluginPackage
TopicShortDescription: Smart selection for Introduce-Refactorings
TestedOnOS: OsWin2K, OsWinXP
ShouldRunOnOS: AnyOS

Attachment: sort Action: Size: Date: Who: Comment:
smarterIntroduceVariable.jar action 7292 26 Jul 2003 - 14:07 SaschaWeinreuter The original, very very simple plugin
SmartIntroduce.zip action 39693 07 Nov 2004 - 15:27 SaschaWeinreuter Version 1.4.2 source

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.