Menu

Preferences

Ernest

How to use

There are several commands, represented by toolbar items

  • Format Flex code - If there is a selection, then the lines in the selection are formatted. Otherwise, the entire document is formatted. This applies to both ActionScript and MXML documents. By default, the command sequence Ctrl+F is mapped to this command in the Flex editing context.
  • Indent Flex code - If there is a selection, then the lines in the selection are indented. Otherwise, the current line is indented.
  • Generate ASDoc comments for file - Add ASDoc comments for all classes/functions/properties in an ActionScript file, based on your preference settings. This only works on .as files. The preferences determine whether this operation will skip over, for example, private functions.
  • Generate ASDoc comment for current element - Add an ASDoc comment for the current class/function/property. This operation will add a comment regardless of your preference settings. By default, this operation is mapped to Alt+Shift+J.
  • Rearrange AS code - Reorder the elements in the current ActionScript file based on the preferences. This operation now (as of 0.7.1) works on .mxml files.

Any of these commands can be mapped to different keys using the Eclipse General->Keys dialog. Search for "MXML" in the keys dialog to find the format/indent commands.

FlexFormatter AutoFormat

Format on save

The FlexFormatter allows you to cause a Format or Indent operation to occur when an editor is saved. Operation for ActionScript and MXML files can be controlled separately. Check the appropriate box and decide whether you want Format or Indent to occur. Operations of either kind can be performed manually as needed.

Excluding files from Format on Save

You can exclude files from auto (or batch) formatting by adding a regular expression to match the workspace-relative path in the table on the preference page. For example, to exclude items in package com.mycompany.adobePatches, you could add .*/com/mycompany/adobePatches/.* to the table. Note that you are filtering based on a path (not a package), and that I canonicalize the paths to use forward slashes for convenience, regardless of Operation System.

The rules are:

  • Use a forward slash '/' as the path separator, regardless of operating system</li>
  • Use Java regular expression syntax to specify the mask. See http://java.sun.com/javase/6/docs/api/java/util/regex/Pattern.html
    • Example 1 - all paths containing a package segment of "adobe"
    • ./adobe/.
    • Example 2 - Actionscript files that come from a third party with "org" package (notice the escaped period before the file extension)</h3>
    • ./src/org/.\.as

Formatting other file extensions as xml

You can also use the formatter as a helper for formatting xml-style files. In the extensions table, add other extension (ex. 'xml') that should be formatted/indented using the mxml pretty printer. CData sections are not formatted.

Update Checker

This page allows you to adjust some updating options.

  • FlexFormatter updates - both of the options below require access to the internet.
    • Check for updates - click this button to find out if you have the most up-to-date version of the plugin installed.
    • Or mark the checkbox Check for updates at startup. The check will be made each time you startup Eclipse and you will be notified via a dialog box if there is a newer version.
  • Settings updates - This option is for groups of developers who want to keep their FlexFormatter settings in sync.
    • The idea here is that you push a file to source control that is in a project that all the developers pull. Then they will automatically pull the file when it changes.
    • Mark the checkbox to turn this feature on.
    • Click the browse button to point to an item in the Eclipse workspace.
    • an example path is /MainProject/myCompany.FF.properties
    • If you are the person who makes changes to the FlexFormatter settings, then you can check the Save to sync file checkbox. This will write to your local copy of the properties file when you make changes via the Preferences page. Then, the changes will be ready to push.

Flex Formatter General Options

These options are common to both MXML and ActionScript formatting. Right now, the only such option is whether to use tabs or spaces. You should set this option to match what is in the standard FlexBuilder options at Window-&gt;Preferences-&gt;Flex-&gt;Editors-&gt;Indent Using

Actionscript blank line and spacing settings

Blank lines/Spaces

Spaces inside (,[

This is the number of spaces inside parentheses, brackets, and braces (for arrays). If you uncheck the box beside the twistie, you can set the subitems separately.

No spaces between adjacent (,[

If checked, nesting characters that appear next to each other will not have spaces between them, regardless of the Spaces inside setting. Ex. [(( x + 2 ) + 3 )].

Spaces before comma, Spaces after comma

This is the number of spaces before/after commas as they appear in parameter lists, method arguments, array declarations, etc.

Spaces around assignments, Spaces around operators

This is the number of spaces on either side of an '=' or boolean/arithmetic operator. This applies to symbolic operators only. Text operators (like 'as' and 'instanceof') will always have only 1 space on either side.

Spaces around colons

This is the number of spaces on either side of a ':' character in variable declarations. You can uncheck the checkbox beside the twistie to set the number of spaces before and after the colon separately.

Spaces after labels

This is the number of spaces after the colon of a label. Labels never have any space before the colon.

Spaces before '(' after keyword

This is the number of spaces before the open parenthesis after a control keyword. For instance, between for and the control block.

Spaces before '(' in function

This is the number of spaces between the name of the function and the function's parameter list.

Blank lines

Don't delete existing blank lines

If checked, don't delete any lines in the document that only contain whitespace. This does not mean that line breaks won't be removed, only that empty lines (2 or more line breaks in a row) will be preserved. Additional blank lines may be added. If not checked, then blank lines will be removed depending on the blank lines settings. Typically you would leave this item checked so that extra blank lines used to group variable declarations or other code won't be lost.

If unchecked, then an additional setting is available to preserve some blank lines. The idea is that 'extra' blank lines will be removed, but you won't lose your existing code groupings.

Lines before functions, Lines before classes, Lines before control statements, Line before properties

This is the number of blank lines to insert before these items. The idea is to keep a consistent amount of whitespace. Note that if you have "Don't delete blank lines" turned on, then the number of blank lines will never shrink, regardless of this setting.

Always generate indent

If checked, then generate the indent whitespace on blank lines. If not checked, then blank lines will be empty. Checking this option can be useful if you want the whitespace to exist so that you can go back later and navigate to the end of line to start typing.

Don't indent // comments in first column

If checked, don't indent line comments that start in column one. Some people keep TODO comments there.

Actionscript wrapping and newline settings

Text wrapping/formatting

These options control formatting of the wrappable code elements. The goal here was to provide some reasonable wrapping, but also to allow you to skip formatting code elements that are complicated and that it's likely you have your own style for. Allowing you to selectively turn off formatting allows you to select larger parts of the document without worrying that your custom formatting will get destroyed.

Array declaration, Method arguments, Method parameters

This items are wrapped in a similar way and have the same set of options. Indentation is always affected, regardless of which option is chosen.

  • Don't format
    Don't add/remove newlines from the existing code item or change the number of spaces internal to a line. i.e. Indent
  • Format without changing newlines
    Don't add or remove line breaks, but adjust spaces on each line
  • Keep on single line
    Format and pull up the item onto a single line, ignoring the max line length setting
  • Wrap to max length
    Use the max line length hint above to decide when to wrap. Breaks on commas. Uses the setting below to decide whether to break before or after a comma.

General expression

This applies to expressions in general (arithmetic, boolean, assignment etc.). The options are the same as above, but line breaks are only added at operators. So if you don't allow wrapping of method parameters, setting the wrap option here won't wrap on commas.

Embedded XML

This option applies to XML tags embedded directly in ActionScript code. These tags are not formatted using the options for MXML, both because the semantics are different and because it looked difficult. Instead, I added options to try to not screw up formatting that you have already supplied. There is an extra option that will put each tag on a separate line with a reasonable indent.

Max line length

The max line length is a hint at where you want wrapping to occur for the wrappable elements. Wrapping occurs after the boundary has been passed, so this is not appropriate for ensuring print output. For better wrapping behavior, check the Advanced Wrapping checkbox.

Break lines before comma/operator

Add carriage returns before commas/operators, or afterward.

Indent to first item

If checked, indent 2nd and subsequent lines to the first parameter/argument/array item. This does not affect general expression wrapping. Method calls with method calls as arguments are wrapped in nested fashion. If not checked, all wrapping is indented one indent beyond the start of the first line of the wrapped item.

Hanging indent tab stops

This is the amount of indent to use for the second and subsequent lines of a wrapped statement. One tab stop is the size of a tab, whether it's actually realized as tabs or spaces. This is overridden by the Indent to first item setting if checked, for items where indent to first item is applicable.

Use Advanced Wrapping

This option turns on newer wrapping code that gives you better control of where lines are split when wrapping. The advanced wrapping checkbox is only enabled if at least one of the statement types is set to an option that wraps based on length.

Advanced wrapping table

This table contains the different types of items where a line can be broken. Check the items where you prefer breaks to occur. Other settings will also be used as applicable.

Grace Columns

This is the number of columns to allow as a buffer to allow line breaks to occur without slavish adherence to a column. The grace columns are only be used if the preferred line breaks (the ones checked in the Advanced wrapping table) all fail to break the line at an earlier point. At that point, the formatter searches forward based on the grace columns to see if using those extra columns does allow a preferred line break to occur. Of course, you can set the column size to 0 to prevent grace columns from being used.

Break on phrase boundaries

This option is the most important aspect of the advanced wrapping. If checked, possible line breaks are checked in (reverse) precedence order. The precedence order is determined in the usual way by operators, parentheses, etc. For each precedence level, possible line-break items are tested. If no line breaks are found, then the grace columns are applied to see if a line-break is allowed. So the idea is to allow the longest possible line at the lowest precedence level, so that pieces of the statement that are related are kept together.

If this option is not checked, then only one pass through the source line is made, rather than searching each precedence level. Then, the grace columns are checked. This setting is similar to the old wrapping algorithm, except for the grace columns and the ability to choose which operators can cause a break.

Enforce max length

Check this option to attempt to enforce the max line length if other wrapping strategies fail. The first attempt is to see if a line break is available if items that are not checked in the table are used. If that still doesn't find a break, then the line is searched in increasing columns (first using preferred break locations, then using any) until a break location is found. If none are found, then the line is not broken. So this is an aggressive breaking strategy.

If this option is not checked, then columns to the right are still searched, but only using the preferred line break locations. If none are found, then the line is not broken. This is a less aggressive breaking strategy.

Line Breaks

Brace Style

Check the box if you generally want braces done in Sun style or Adobe Style. Uncheck the box if you want some hybrid of the two styles or have particular exceptions for some of the subitems. Adobe style has open braces on a new line. Sun style has braces on the end of the first line of the statement.

Else on new line

If checked, else will be placed on a new line after the if statement. Typically, you set "Open brace on new line" and this option to the same checked state.

Else-if on same line

If checked, keep the 'if' in an 'else if' on the same line with the else. Otherwise, move the if to a new line.

Catch/Finally on new line

This is the same idea as 'Else on new line'

While on new line

This is a special option for do...while loops. It is different from the other brace options in that it does not control whether the brace is at the start of a line, but whether the brace is on the same line with the keyword. This option is standard in neither Sun nor Adobe styles.

Open brace on new line

If checked, open braces will be placed on the line below their control statement. If not, they will be left on the line of the control statement. You can uncheck the main checkbox to tweak this setting for particular types of statements and code blocks.

Newline between [Bindable] and functions/properties

If checked, a line break will be added after a [Bindable] metatag that occurs right before the associated element. If not, then the meta tag will appear on the same line as the associated item, with a space between them. Other metatags before the [Bindable] tag will never be on the same line with the associated item. If there is another metatag or comment after the [Bindable] tag, then the [Bindable] tag will not be put on the same line with the associated item.

Put Empty statements on new line

Put any empty statement (a single semi-colon) on a new line to help prevent errors with accidental semi-colons.

Tweaks

These are items that didn't seem to fit anywhere else and are hopefully unusual.

Spaces around optional parameters

This is a special setting to control the number of spaces around the '=' in optional parameters in function declarations. Otherwise, the normal spaces around '=' setting is used.

Don't indent package elements

For some reason, the Adobe sample code doesn't indent package contents (braces, classes, imports) at all. This option mimics that behavior.

Leave extra whitespace around variable declarations

Checking this option leaves any extra whitespace around '='. The idea is that if you have lined up your '=' across several variable declarations, then this option will prevent that from being disturbed.

Actionscript Rearranging

Rearranging allows you to modify the order of modifiers and elements of an ActionScript block/file. It works in both Actionscript files and in script blocks within mxml. However, rearranging cannot be done on an mxml file using the toolbar button, and rearranging is always performed on the entire file. Rearranging without formatting can be a little weird because it is difficult to know what to do with leading whitespace. For instance, if the first function in the file has 2 blank lines before it to separate it from the properties, rearranging may move it to later in the file. The rearranger will take the leading whitespace and comments with it, because that seems like the only sensible thing to do. However, in some cases this can lead to odd results. A subsequent 'format' often cleans up these oddities depending on the settings for adding and retaining blank lines.

  • Rearrange while formatting - This option determines whether rearranging will be done as part of formatting. If not checked, rearranging can still be performed (for Actionscript files) using the toolbar button.

Modifiers

This provides the ability to control what order element modifiers appear in. You can specify separately for functions/properties/classes or use the same for all three. The order of elements is unaffected; this only affects the order of modifiers for each element.

  • Use same modifier order for all element types - If unchecked, you can specify separately for functions/properties/classes.
  • Enable modifier reordering - If unchecked, skip reordering of modifiers. You can also reorder modifiers for only some types of elements.
  • Modifier table - Move modifiers up and down with the buttons. The special namespace value matches any namespace string.

Elements

This page provides the ability to change the order of elements in a source file. For instance, if you want all of the static properties at the top of a class, you can set that here.

Element type table

  • import - ex. import adobe.*;
  • include - includes of source files
  • namespace definition - definitions of namespaces
  • default namespace -
  • namespace use - ex. use namespace x;
  • static property
  • static function
  • constructor
  • property
  • function

Use the up and down buttons to reorder the elements.

Advanced member ordering

If you need more control over member order (that is, of functions and properties), you can use the New member selector... button. This feature allows you to create some new special sort elements that filter members based on a number of different factors.

  1. Choose whether the set of members should select functions or properties
  2. Choose whether the set of members is pre-filtered. Normally, as the elements are being ordered, they aren't moved from the master list to the ordered list until they are encountered in the ordering. This can be inconvenient, for example, if you wanted to select functions that have been overridden, but you want the non-overridden functions to occur earlier in the output. Pre-filtering selects from the list of members before any ordering is done. In other words, it gets first crack. Obviously, this brings up another problem: What if you have multiple pre-filter items?. The solution is that back in the ordering table, pre-filter items will be prefixed with a number. You can use the **Up and **Down buttons to adjust the relative ordering of the pre-filtering.
  3. Select for visibility. If you don't want visibility to affect the set, don't check the box. Otherwise, chec'k the box and then choose which visibility specifiers you care about.
  4. Select for name. If you don't want the name to affect the set, don't check the box. Type the Java-style regular expression corresponding to the names of members you want included in the set. Multiple regular expressions can be supplied, separated by commas. Lastly, you can invert the set with the Exclude checkbox.
  5. Select for type. This is the declaration type of a variable or the return type of a function. If you don't want the type to affect the set, don't check the box. Otherwise, specify a comma-separated list of Java-style regular expressions corresponding to the types of items you want to include. Note: the type name used is what is literally in the declaration. No package qualifier will be used unless it is present in the declaration. Ex. Object,int,Math.*
  6. Select for parameter name for 1-parameter functions. This only applies to functions that have exactly 1 parameter. The idea is to let you select event handlers or similar if you have a convention for the parameter name. If you don't want to use this selection mechanism, leave the checkbox unchecked. Ex. event
  7. Select for parameter type for 1-parameter functions. This only applies to functions that have exactly 1 parameter. The idea is to let you select functions where the parameter type for an event or something. If you don't want to use this selection mechanism, leave the checkbox unchecked. Ex. .*Handler
  8. Select for namespace. If you don't want the existence of a namespaces to affect the set, don't check the box. Select the No namespaces checkbox to exclude any member with a namespace from the set. Otherwise, you can supply one or more Java-style regular expressions to match namespace names and optionally invert the set with the Exclude checkbox.
  9. Select for static members. If you don't want the scope of a member to affect the set, don't check the box. Select static or non-static to filter the set.
  10. Select for final functions. If you don't want the finality of a function to affect the set, don't check the box. Select final or non-final to filter the set.
  11. Select for native functions. If you don't want the nativity of a function to affect the set, don't check the box. Select native or non-native to filter the set.
  12. Select for override functions. If you don't want the override status of a function to affect the set, don't check the box. Select override or non-override to filter the set.
  13. Select for function type. If you don't want the function type to affect the set, don't check the box. Otherwise select which types of functions are part of the set.
  14. Sorting
    • Sort members by name. Check this box to sort members in ascending order by name.
    • If sorting, you can choose whether to sort with case sensitivity using the next checkbox.
  15. The static text field at the bottom of the screen displays all the options in a compact but fairly readable format. This is the same string that will show up in the member ordering table.
  16. A newly defined member set will be added at the end of the member selection table. You MUST move the member set up in the table using the Up button because the default element types will collect all of the elements of the given type and therefore there won't be any left over to be captured by your new set.

The tab folders below the member ordering table DO NOT apply to custom member sets.

Element detail settings

These tabs correspond to the basic element types (i.e. the predefined ones) listed in the element type table. They do not apply to custom property/function sets that you have added to the table.

  • Include - Choose whether to sort includes by file path or to maintain their relative order in the file.
  • Funcs - Non-Static Functions - Choose whether to group functions by visibility. If grouping, then you can choose the order by visibility. If not, all functions will be treated as one set. Then you can choose whether all items in each visibility group should be ordered by name (case insensitive).
  • Props - Non-Static Properties - Same as Functions
  • Funcs(S) - Static functions - Same as Functions
  • Props(S) - Static Properties - Same as Functions
  • Namespaces - Choose whether to sort namespace definitions by name
  • Metatags - Controls the order of metatags that are associated with elements. Typically, there is only one metatag associated with an element, but sometimes there can be more. You can check the box to group according to the table. You can move items up and down in the table or add new items if there are other metatags not listed. Use the sort checkbox to sort the tags by name; otherwise the current relative order in the file is maintained.
  • Imports - The order of imports in the file
    • Move imports outside class - Move imports that are inside the class to the containing package or the area outside the class if there is no package.
    • Group according to table - This table allows you to specify the ordering and grouping of imports. Items in the table are prefixes corresponding to import package names. Examples are "adobe." or "adobe.mx.". Also, you can use the New separator button to add an extra carriage return in the file between import prefixes. Extra carriage returns before the first prefix or after the last one will be ignored because that is handled by other formatting options.
    • Sort by name within group - Check this box to sort the imports within each group by name.

Examples

Creating a new member set can be a little confusing, so here are a couple of examples. Note: each example lists the 'print string' of the settings that appears at the bottom of the custom member set dialog.

  • public !final/!static/!native Functions (normal) name=put.* Sort

This set grabs all public functions that are not static or final or native or getter/setting/Constructor and have names starting with "put"

  • protected/private/internal Functions namespace=<none> Sort

This set grabs all non-public functions that have no namespace specifier.

  • Functions namespace=mx_internal, private_ns Sort

This set grabs all functions that have the namespace 'mx_internal' or 'private_ns'

  • static Fields name=CONSTANT_.* namespace=Sort

This set grabs all properties that are static and have names starting with CONSTANT_

Headers/Spans

A header is a comment header placed before elements of a certain type to identify a section of code that contains the same type of elements. A span is a header that applies to more than one consecutive element type. For example, a standard header identifying functions might look like this:

////////////////////////////
//   Functions (only functions are in this header group)
////////////////////////////
public function a():int
{}

A span might look like the following:

////////////////////////////
//   Members (this is a span that occurs before any functions or properties)
////////////////////////////
public function a():int {}
public function b():int {}
public var a_prop:int;
public var b_prop:int;

FlexFormatter allows you to define headers for any or all element types, using either the Major or Minor format defined on this page.

  • Use section headers - check this box to enable the section header functionality
  • Use section headers in mxml - check this box to enable section headers in Actionscript blocks within mxml files.
  • Remove existing section headers - check this box to remove any comment blocks that 'look like' section headers. A section header is identified by:
    • a set of at least 3 lines of '//' or '/*' comments
    • the first and last lines of the comment are the same style (but not necessarily the same length)and have the same repeated character
    • The first and last lines have at leas 10 repeat characters
    • section headers can be adjusted/removed without this flag if the contents exactly match one of the currently configured headers, whether it is active or inactive.
    • For example, if you had previously defined function headers
    • Note: I can't determine anything based on the text contents of the header, because they are arbitrary. This is why this is dangerous, because there might be other comments in the file that fit this format but are not intended as headers.

Major and minor headers

Rather than have each header's style configured manually, you configure the size, width, comment style, and repeat character for the major and minor header styles. Then, when you configure a header, you pick which type of header you want and supply the text.

  • The style settings should be self-explanatory (see the preview box).
  • The text content is for sample purposes only.
  • After you have configured the header styles, go to the Elements tab and configure a header or span by selecting an element type and clicking the appropriate Header... or Span button.

This page is intended to help you generated copyright headers for Actionscript files. The styles can be set just like those for headers/spans. Paste in the appropriate copyright text and check out the preview. Notice that in the sample code the copyright header doesn't use your text unless you check the Remove Existing Copyright headers checkbox. This is intended to prevent accidental erasures.

  • Use copyright headers - if checked, then a copyright header will be added
  • Remove Existing Copyright headers - if checked, then the existing copyright will be deleted and a new one added. This is helpful to standardize the copyright statement across a project or to update the year.
  • The widget/style/character settings should be self-explanatory with the preview area.

Configuring Section Headers

  1. The first step is to turn the feature on using the Headers/Spans tab.
  2. Go to the Elements tab
  3. Select an item in the element table that needs to have a header. The Header... and Span... buttons should be enabled. Click one depending on which one you want to create.
    1. On the dialog, enable the header with the top checkbox
    2. Choose whether the header is major or minor style
    3. Type in some text.
      • Use the preview area to see the effect of your settings
    • You can use multiple lines
    • Leading or trailing blank lines will be removed. They are controlled by the style.
    1. If you chose the Span button, then there is a dropdown list at the bottom of the dialog that lets you control how many elements this header is in front of.
    2. Click OK to save the header

If you chose the Header button, then the content you typed will appear in the table beside the element type. If you chose the Span button, then the items that are part of the span will appear indented in the element table.

Any element type can have a header. An element can only belong to one span. To be clear, an element type can have both a header defined and be part of a span.

A span/header combination might be used to group members. Here's an example:

/////////////////////////////////////////
//
// Members (major header)
//
/////////////////////////////////////////

///////////////////////
// Functions (minor header)
///////////////////////
public function a():int{}

//////////////////////
// Properties (minor header)
//////////////////////
public var i:int;

MXML Options

Spaces around equals

Set the number of spaces that should be placed on either side of an attribute '='.

Spaces before />

Number of spaces before the end marker of an empty tag.

Indent to first attr

If checked, indent wrapped attributes to line up with the first attribute in the tag. If not checked, wrapped lines are indented one tab.

Configure attribute order

This button brings up a dialog lets you specify the proper ordering (reordering) of mxml attributes during a Format.

Default attribute wrap options

Wrap options

Determine how you want the attributes to be wrapped.

  • No wrap
    Don't add any additional line breaks beyond what's specified in the table.
  • Wrap to max line length
    Break lines when they get longer than the maximum line length. This is not applied to the items in the custom ordering table before the last configured newline, unless you have defined an attribute group and have specified to use the 'Default' wrapping for the group.
  • Attrs per line
    Break lines after the given number of attributes. This is not applied to the items in the custom ordering table before the last configured newline, unless you have defined an attribute group and have specified to use the 'Default' wrapping for the group.

Detail settings

  • Max line length - The column to break lines at. Applies to default wrapping, as well as the wrapping of any group that is using default max length wrapping.
  • Attributes per line - The number of attributes per line. Applies to default wrapping, as well as the wrapping of any group that is using default attributes per line wrapping.

Keep on one line below a certain number of attributes

Sometimes, you always want tags with 3 or fewer attributes to be kept on the same line, regardless of line length or number of attributes per line. Also, if you configure the 'id' attribute to be the first attribute and appear on the line after the tag name, then this setting overrides that and compresses the tag.

Obey max length

This is an override to the Keep on one line below a certain number of attributes option. So basically, if you think max line length is the most important wrapping criterion, then turn this option on so that putting a number of attributes on the same line doesn't make it unreasonably long. This option does not apply if you are wrapping based on n attributes per line.

Blank lines

Keep blank lines

If checked, blank lines between tags and inside tag data are preserved during a format. Carriage returns within a start or end tag are ignored. This option should rarely be unchecked.

Blank lines around tags

Blank lines around tag settings can be used together. If a tag matches multiple settings, only the maximum number of blank lines will be used.

  • Blank lines between sibling tags - This is the number of lines between tags that are children of the same parent tag. This does not add blank lines between the parent tag and the first child tag.
  • Blank lines after parent tags - This is the number of lines between a parent tag and the first child tag.
  • Add lines before - This is the number of lines before tags listed in the table. You can use Java regular expression syntax to specify tag names. Example: mx:.*
  • Lines after parent tag - This is the number of lines before the first child of parent tags listed in the table. You can use Java regular expression syntax to specify tag names. Example: .*:Application

Text content within tags

There are two tables here. Tags listed in neither of these tables will be formatted with the default strategy. The default strategy is to not modify the text content of a tag if it contains any non-whitespace characters. This is the normal case of no text content.

  • Tags to never format - These are tags whose text content should not have their whitespace modified at all. The default case here is the tag, where the start and end tag are typically located on the same line, and whitespace is significant. Add other tags to this list as needed.
  • Tags to always format - These are tags where whitespace is not meaningful in the text content. This is the case for the mx:List tag (AFAIK), where blank lines and leading and trailing whitespace are ignored. Add other tags to this list as needed.

Restore defaults to both tables

This button repopulates the two list boxes. This is a convenience since you may get the tables out of whack and want to restore their default contents, which might change as I add more event tags to the default list.

Actionscript Tags

  • Only format Actionscript within CData markers - Checking this option means that only ActionScript within CDATA blocks will be formatted. Actionscript code can be within mx:Script tags without an enclosing CDATA block, but some special characters have to be escaped (like the 'less than' symbol).
  • Actionscript tag table - This table contains the tags whose text contents should be formatted as Actionscript code. Note that the last item in the table by default is ".*:Script", i.e. the normal script tag. Other items in the table are event handlers. Adjust table items as appropriate

Attribute Order Dialog

This dialog lets you reorder mxml attributes during a Format.

Don't use custom attribute order and line breaks

If this box is checked, don't change the order of attributes or use any custom line wrapping configuration.

Order of attributes

In this table, add the attribute names that you want to see in a particular order. Many people would want to add 'id', perhaps others. Each row in the table is a group of attributes. It could be a single attribute, or it could be a comma-separated list of attributes with a newline at the end. The second case would mean that all the attributes in the set (that exist) should appear in the given order in any tag, and a newline should be inserted after the last existing attribute, so that following attributes will start on a new line. No newline will be added if none of the attributes exist. Creating a group with only linebreaks (no attributes) means that the linebreaks will always be added (unless there are no attributes in the tag). It makes most sense to include a linebreak in each attribute group (if you want one). A linebreak can also be included in its own group (as the first group in the list) to insert a newline before the first attribute in any tag. Extra line breaks beyond the last attribute in a tag will be trimmed.

Operations

Delete

Remove the currently selected row from the table

Move up/down

Use these buttons to reorder rows in the table.

Add line break

Adds a line break to the current row in the edit field

Add attr group

Add a reference to a group (a list of attributes) to the current row in the edit field. The available groups are listed in the combo box beside the button. Use the Edit groups... button to add/edit/delete groups of attributes.

Add

Add the current row definition to the table. This will be disabled if any element in the row already exists in the table. Update Modify the currently selected row definition in the table with the contents of the edit field. This button will be disabled if there is no row selected or if the contents of the edit field intersect the contents of another table row.

Simple Examples

  • id, \n
    The id attribute will always be listed first, if present, and subsequent attributes will start on a new line
  • id, \n on first line, x,y on second line
    The id attribute will always be listed first, if present. The second line will contain x and y, if they exist. Further attributes will appear on the same line with x and y, pursuant to the wrapping options set on the main MXML preference page.

Sort remaining attrs

If this box is checked, all left-over attributes (that are not referenced in the table above) will be sorted in ascending alphabetical order.

Add newline before tag close

If this box is checked, the end symbol for the tag (&gt; or /&gt;) will be moved to the next line. Otherwise, it will appear immediately after the last attribute in the tag. This option is the only way to have a line break after the last attribute in a tag.

Editing attribute groups

There are 5 predefined groups (properties, styles, effects, xml namespaces, and events). You can modify these groups to contain items I have missed, or create your own groups. An attribute may be listed in more than one group.

Group table

This table lists the currently defined groups.

New...

This button allows you to define a new group. Groups must have unique names.

Delete

This button allows you to delete a group. A group that is used in your custom attribute order cannot be deleted.

Rename...

This button allow you to rename a group. A group that is already being used in your custom attribute order cannot be renamed.

Update default groups

This button adds attributes to the end of existing groups based on the default group definitions in the FlexFormatter plugin. The idea is that if more attributes are added to the default groups, this is a way to update them. No attributes or groups are deleted. The normal restore defaults behavior on the main preference page does not affect the group definitions.

Editing a group

To edit a group, select it in the group table. This will cause the attributes table to be populated with the list of attributes in the group.

Attribute table operations

  • Move up
    Move the attribute up one slot in the list
  • Move to top
    Move the attribute to the first slot in the list
  • Move down
    Move the attribute down one slot in the list
  • Delete
    Remove the attribute from the list
  • Add
    Type in the text field and click this button to add a new attribute to the list
  • Replace
    Select an attribute in the list, modify it, and click this button to change the name in the list

Any legal attribute name may be typed here. Also, you can use Java regular expressions to define attributes. See this link A simple example is xmlns:.* to match all attributes starting with "xmlns:".

Sorting/Wrapping

A group by definition can contain multiple members. So it makes sense to be able to control sorting and wrapping within items matched by the group. Each group has its own setting.

Sorting

  • Leave attributes in existing order
    Attributes that are identified as part of the group keep the order they had prior to formatting, except that they are now all adjacent in the output.
  • Sort attributes in ascending order
    Attributes that are identified as part of the group are sorted and adjacent in the output.
  • Sort attributes in group order
    Attributes that are identified as part of the group are sorted according to the order in the group. For example, you might alter the default group 'properties' to have id, x, y, width, and height at the top. Those attributes would appear in that order in the output

Wrapping

  • Keep attributes on same line
    Don't add any line breaks, no matter how many attributes are in this group. This makes sense if you always keep a tag on a single line, or if the group has a small number of attributes.
  • Wrap attributes based on max line length
  • Wrap based on the max line length hint from the main MXML preference page.
  • Keep n attributes per line
    Wrap every n attributes based on the setting on the main MXML preference page, or supply a different number of attributes in the spinbox.
  • Use default wrapping scheme
    Use the wrapping scheme on the main MXML preference page as the wrapping scheme for this group. This option usually makes the most sense.

Related

Wiki: Old_Docmanager_Index

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.