IntelliJ Community . BoxPlugin

 
BoxPlugin 

HOME INDEX SEARCH CHANGES GO  

Description.

Conversion intentions from one type to another. Say, you often encounter situations when you have conversions of one type to another. These two types are not assignable and probably not even castable. At the same time you have some very well-known conversion (could be either a constructor or some static factory method taking an only parameter). This plugin allows to specify such conversions/intentions.

This plugin uses non-published IDEA API.

Downloads, Bugs, RFEs:

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

ConversionExamples.java:

class ConversionExamples {

    boolean booleanP;
    Object object;
    Integer integer, integer2;
    Long longW;
    Character character;

    {
        {
            // new PrimitiveNumberConversion(project, "int", "new Integer($e)", "$e.intValue()")
            Integer i1 = 0; // -> Integer i1 = new Integer(0);
            int i2 = integer; // -> int i2 = integer.intValue();
            Object i3 = 0; // -> Object i3 = new Integer(0);
            int i4 = longW; // -> int i4 = longW.intValue();
            int i5 = (Integer) object; // -> int i5 = ((Integer) object).intValue(); // note added parentheses
            int i6 = booleanP ? integer : integer2; // int i6 = (booleanP ? integer : integer2).intValue(); // note added parentheses
        }
        {
            // new Conversion(project, "char", "Character", "$e.charValue()")
            char i1 = character; // -> char i1 = character.charValue();
            int i2 = character; // -> int i2 = character.charValue();
        }
        {
            // new Conversion(project, "Object", "boolean", new String[]{"Boolean.valueOf($e)", "$e ? Boolean.TRUE : Boolean.FALSE"})
            Boolean i1 = booleanP;
            // if Boolean.valueOf(booleanP) is available (it will be checked automagically), i.e. if you have Java 1.4:
            // -> Boolean i1 = Boolean.valueOf(booleanP);
            // if you use Java 1.3:
            // -> Boolean i1 = booleanP ? Boolean.TRUE : Boolean.FALSE;
        }
        {
            // new Conversion(project, "java.math.BigInteger", "String", "new java.math.BigInteger($e)")
            java.math.BigInteger i1 = "2";
            // -> java.math.BigInteger i1 = new BigInteger("2"); // an import declaration will be added
            // or
            // -> java.math.BigInteger i1 = new java.math.BigInteger("2");
            // depending the "Use fully qualified class names" setting
        }
    }

}

AvailabilityExamples.java:

class AvailabilityExamples {

    Integer integer;
    int i3;
    String[] strings;
    int[] ints;

    int i1 = integer;

    {
        int i2 = integer;
        System.out.println(i2);
        i3 = integer;
        strings[integer] = ""; // only for conversions to int
        ints = new int[]{integer};
        f2(integer);
    }

    int f1() {
        return integer;
    }

    void f2(int i) {
    }

}

Current conversions (see Box/src/main/tzambalayev/ideaplugins/box/ConversionSuite.java):

new PrimitiveNumberConversion(project, "byte", "new Byte($e)", "$e.byteValue()"),
new PrimitiveNumberConversion(project, "short", "new Short($e)", "$e.shortValue()"),
new PrimitiveNumberConversion(project, "int", "new Integer($e)", "$e.intValue()"),
new PrimitiveNumberConversion(project, "long", "new Long($e)", "$e.longValue()"),
new PrimitiveNumberConversion(project, "float", "new Float($e)", "$e.floatValue()"),
new PrimitiveNumberConversion(project, "double", "new Double($e)", "$e.doubleValue()"),

new Conversion(project, "char", "Character", "$e.charValue()"),
new Conversion(project, "Object", "char", "new Character($e)"),

new Conversion(project, "Object", "boolean", new String[]{"Boolean.valueOf($e)", "$e ? Boolean.TRUE : Boolean.FALSE"}),
new Conversion(project, "boolean", "Boolean", "$e.booleanValue()"),

new Conversion(project, "double", "String", "Double.parseDouble($e)"),
new Conversion(project, "float", "String", "Float.parseFloat($e)"),
new Conversion(project, "long", "String", "Long.parseLong($e)"),
new Conversion(project, "int", "String", "Integer.parseInt($e)"),
new Conversion(project, "short", "String", "Short.parseShort($e)"),
new Conversion(project, "byte", "String", "Byte.parseByte($e)"),
new Conversion(project, "boolean", "String",
        new String[]{"Boolean.parseBoolean($e)", "Boolean.valueOf($e).booleanValue()"}),

new Conversion(project, "Double", "String", "Double.valueOf($e)"),
new Conversion(project, "Float", "String", "Float.valueOf($e)"),
new Conversion(project, "Long", "String", "Long.valueOf($e)"),
new Conversion(project, "Integer", "String", "Integer.valueOf($e)"),
new Conversion(project, "Short", "String", "Short.valueOf($e)"),
new Conversion(project, "Byte", "String", "Byte.valueOf($e)"),
new Conversion(project, "Boolean", "String", "Boolean.valueOf($e)"),

new Conversion(project, "String", "double", "String.valueOf($e)"),
new Conversion(project, "String", "boolean", "String.valueOf($e)"),

new Conversion(project, "String", "Object", "String.valueOf($e)"),

new Conversion(project, "StringBuffer", "String", "new StringBuffer($e)"),
new Conversion(project, "Class", "String", "Class.forName($e)"),
new Conversion(project, "Thread", "Runnable", "new Thread($e)"),

new Conversion(project, "java.math.BigInteger", "long", "java.math.BigInteger.valueOf($e)"),
new Conversion(project, "java.math.BigInteger", "String", "new java.math.BigInteger($e)"),

new Conversion(project, "java.util.Collection", "Object[]", "java.util.Arrays.asList($e)"),
new Conversion(project, "Object[]", "java.util.Collection", "$e.toArray()"),

How to deploy.

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

How to build

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

History.

0.1.1 (#908) - Aug 27, 2003

  • Recompiled for #908.

0.1 (#896) - Aug 16, 2003

  • Initial release.

-- TimurZambalayev - Aug 16, 2003

IntelliJPluginWebForm
IntelliJPluginName: BoxPlugin
IntelliJPluginVersion: 0.1.1
IntelliJPluginVendor: TimurZambalayev
IntelliJPluginBinary: http://sourceforge.net/projects/tz-ip/
IntelliJPluginSource: http://sourceforge.net/projects/tz-ip/
IntelliJPluginClassification: CodeHelper?
TopicClassification: IntelliJPluginPackage
TopicShortDescription: Conversion intentions from one type to another.
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.