Skip to content

IntelliJ User Guide

Amir Sagiv edited this page Jul 1, 2017 · 4 revisions

User Guide

Whenever a tip is suggested to your code it will be marked blue:

image

  • Enable tips by pressing Alt + Enter (for Windows / Linux users) or Cmd + Enter (for OSX users) or by clicking the yellow light bulb

    Leonidas Menu

    image

by selecting the Leonidas menu, you can optimize your use :

  • Disable / Enable Spartanization on current file
  • Disable / Enable Nano patterns - information about them can be found Nano patterns can be found Here
  • Spartanize current file
  • Playground - An environment you can test the spartanization rules without affecting your project files! upon clicking this option, a window similar to this will open:

image

Using this feature you can test the plugin behavior on code examples. Let's see one! Say you want to test the Leonidas plugin behavior on this code: if(!(!(true))){ s.equals("hello"); } Paste the code in the Input window:

image

By pressing Spartanize Once, the plugin will spartanize the first later of the code, giving this result:

image

If you want to see the code after all Spartanization phases, press the Recursive Spartanization. your result will be:

image

You can also use the Step button to see each and every step of spartanization process on your code example!

  • Toolbox Controller - Here you can customize your plugin by choosing the tippers you want to be notified on and those you rather not to apply. Also, you can customize some of our tippers to your own style! Using this feature you can check / uncheck the tippers you want to get notified about:

image

when moving your cursor over a tipper in the list, an example of the tipper's behavior will be presented on the right side of the window, as seen in the above image.

By pressing Apply or OK, the changes will be saved and the plugin will be updated according to your choices.

Also, the controller allows you to change the behavior of some of the tippers. Double clicking the "MethodDeclarationChangeSingleParameterToCent" a new window will be opened:

image

Here you can play with the tipper's properties, to make it work in your own style. For example:

image

For these changes, the tip will change the parameter of a method with a single parameter to "banana" if and only if:

  1. the method isn't "main" method
  2. the method parameter name isn't already "banana" or "apple"
  3. the method is a private and a static method.
  4. the method's body doesn't contain any "banana".

Notice, that currently this is the only tipper available for edditing, developers can easily add this feature to more tipper!

  • Spartanize entire project
  • Add SpartanizerUtils file - by adding this file to your project, you can use our Nano-patterns tippers (information about them can be found Here)
  • Add New Tipper - Add your own tippers to the plugin using Leonidas language. (information about the language can be found Here)

image

Using the Add Tipper window you are able to create new tippers and specify their:

  • Name - The name of the tipper which will be displayed in the Controller.
  • Description - A description of the tipper which will be displayed when spartanazying a piece of code.
  • Matcher and Replacer templates - Templates written in the Leonidas language (see here) that specify the structure a piece of code needs to meet in order to be spartanized by this tipper, and the result of the spartanization process.
  • Constraints - Constraints written in the Leonidas language (see here) that need to be met in order for the code to be spartanized by this tipper.

After you finish writing the tipper, click the on the Save button to add the tipper to the system. If there were any errors parsing the tipper, an error message will be displayed and you will have an option to fix the tipper.

The following example shows the completed form of a tipper that replaces any assignment of the form x = 5; with x = 50; for any variables that start with xxx:

image

  • Analyze File - find out what tippers are available for the current file your'e working on and jump right to them!

Using this feature you can see all available tippers in the file your'e working on. For example:

image

You can see every tipper available in your file. Double click one of the tippers to jump right to the line where the tipper can be applied!

Clone this wiki locally