Skip to main content

Tabifier

Posted by davekriewall on March 16, 2010 at 1:13 AM PDT
Project URL

Go see Project Homepage

Summary

Tabifier is an IDEA plugin that respaces or tabs Java source code so that certain syntactic items are vertically aligned. Tabifier provides extensive control over alignment.

Community: 

IncubatingThe tabifier plugin retabs Java code so that syntactic elements are aligned vertically. Extensive control over alignment is provided.
(This HTML parser does not support pre-formatted code, and runs the examples together. See http://web.archive.org/web/20071003121646/http://www.intellij.org/twiki/... for examples of the actual fomatting that the tabifier provides.)
For example, I like to align variable declarations and assignment statements like this: int v1; // loop variable String s2; // second string public static PrintWriter p; private static boolean debugging = true; // initialize private static OutputStream outputstream = null; outputstream = new FileOutputStream(f, true); p = new DebuggingPrintWriter(outputstream, true); IDEA likes to format them with single spaces separating the syntactic elements, like this: int v1; // loop variable String s2; // second string public static PrintWriter p; private static boolean debugging = true; // initialize private static OutputStream outputstream = null; outputstream = new FileOutputStream(f, true); p = new DebuggingPrintWriter(outputstream, true); The tabifier plugin automatically reformats the text into the first version, or any variation of it you choose. The Tabifier is able to right justify integer literals, for example: public static final int ONE = 1; public static final int TWO = 2; public static final int TEN = 10; public static final int ELEVEN = 11; It can align method declaration and method call parameters, even with multiple parameters per line: public ExpressionListParser(TokenColumn openParend, ColumnChoice params, TokenColumn closeParend, CodeStyleSettings codeStyleSettings, TabifierSettings settings, NestedParser parser, int nestingLevel) And its expression alignment is recursive, e.g. if ((psiExpressionList.getExpressions().length > expressionListIndex && psiExpressionList.getExpressions()[expressionListIndex] == child ) || (sawNoParameters == false && expressionListIndex > 0 ) ) It is capable of reformatting "if" statements as follows: if (param1 == p3 && j > 5 ) p3 = 7; .... if (param1 == p3) p3 = 6; else if (param1 == 2 ) method1(param1, true, 3); else param1 = 7; Method calls can be reformatted to align parentheses, commas, or parameters: align_params = (ColumnSetting ) find(ALIGN_PARAMS ); align_semicolon = (ColumnSetting ) find(ALIGN_SEMICOLON ); align_semicolon_with_comma = (BooleanSetting) find(ALIGN_SEMICOLON_WITH_COMMA); Typecast parentheses and types as well as many other expression components can also be aligned.

License: 

Berkeley Software Distribution (BSD) License
Related Topics >>