![]() ![]() ![]() ![]() The spacing object specifies the minimum and maximum number of spaces that must be placed between the specified child blocks, the minimum number of line breaks to put there, and whether the existing line breaks and blank lines should be preserved. The spacing ( Spacing) specifies what spaces or line breaks are inserted between the specified children of the block. Rather, only blocks for the text range covered by the formatting operation and their parents are built.įor every block, the plugin specifies the following properties: If the formatting operation does not affect the entire file (for example, if the formatter is called to format the pasted block of text), a complete tree of blocks is not built. To change the default "block name" taken from class name, return custom Block.getDebugName(). or Tools | View PSI Structure of Current File.: To invoke PsiViewer with the possibility of inspecting Block Structure, use Tools | View PSI Structure. To better understand how to build the block structure, use PsiViewer and inspect formatting blocks built for an existing language. Otherwise, the formatter may delete the characters between blocks. The formatter modifies only the characters between blocks, and the tree of blocks must be built so that the bottom-level blocks cover all non-whitespace characters in the file. Its children cover individual classes in the file, blocks on the next level cover methods inside classes, etc. The structure of blocks is usually built so that it mirrors the PSI structure of the file – for example, in Java code, the top-level formatting block covers the entire file. The formatting model is requested to insert the calculated whitespace characters at necessary positions in the file. The formatting engine calculates the sequence of whitespace characters (spaces, tabs, and/or line breaks) that needs to be placed at every block boundary, based on the plugin's formatting model. The formatting model is requested to build the structure of the file as applies to formatting, as a tree of blocks ( Block) with an associated indent, wrap, alignment, and spacing settings. The formatting model builder ( FormattingModelBuilder), implemented by the plugin, provides a formatting model ( FormattingModel) for the document to be formatted. The process of formatting a file or a file fragment consists of the following main steps: The formatting engine, provided by the IDE, calculates the smallest number of whitespace modifications that need to be performed on the file to make it match the constraints. In this framework, the plugin specifies the constraints on the whitespaces between different syntax elements. Alignment of: array initializer expressions, arguments in method declarations and calls, field declarations, extends list, assignments, binary expressions, ‘throws’ clause, resources in ‘try’.The IntelliJ Platform includes a powerful framework for implementing custom language formatters.Special ‘else if’ treatment (compact ‘else if’) New line after: opening brace in array initializer.New line before: closing brace in array initializer, ‘else’ in ‘if’ statement, ‘finally’ and ‘catch’ in ‘try’ statement, binary operator (if wrapped).Keep blank lines in code (number of empty lines to preserve).Space around binary operators (a single Eclipse setting is mapped to multiple IntelliJ IDEA’s settings).Space before/after ‘:’ in conditional expression.Before opening brace of: array initializer, ‘switch’.Around unary, assignment operators (if it’s set for ‘before’ and ‘after’ in Eclipse).Before parentheses of: ‘try’, ‘for’, ’while’, ‘switch’, method, ’if’, ‘catch’, method, method call, ‘synchronized’.Within parentheses of: annotation, ‘for’, ‘if’, ‘catch’ ’while’, ’switch’, method, empty method, parenthesized expression, method call, type cast, ‘synchronized’.Before/after comma (as set for Eclipse method declaration parameters).Usage of Tab only for leading indentation (Smart Tabs).prefs files directly.Įdit: IntelliJ can import the following Eclipse properties: ![]() Then open IntelliJ IDEA Settings → Code Style → Java, click Manage, and import that XML file by simply clicking Import.Īs of IntelliJ IDEA 13, there is no possibility to import. Go to Eclipse's Preferences → Java → Code Style → Formatter and export the settings to an XML file via the Export All button ( or Edit and then Export in dialog that opens up). ![]()
0 Comments
Leave a Reply. |