Please follow this guide to upgrade Prettier Apex to this new major version.
- Support Prettier v3 (issue). You cannot use this version with Prettier v2, please plan your upgrade accordingly.
- Drop support for NodeJS < 18.11.0.
- Prettier Apex is now distributed as an ECMAScript Module. This shouldn't affect normal usage of the library, but if you are importing code from Prettier Apex you may need to change your code to adapt.
- Allow user to customize the secret used to shut down the parsing server.
- Allow user to specify the protocol (HTTP/HTTPS) that the parsing server uses.
- Add support for User Mode in Database Operations (issue).
- Support Prettier v3 (issue). You cannot use this version with Prettier v2, please plan your upgrade accordingly.
- Drop support for NodeJS < 16.19.0.
- Add a new option
apexForceCurly
that allows to force curly brackets for if-else and loop blocks issue. - Enhance the
apexFormatAnnotations
option by merging it with theapexAnnotationsArgsSpacing
option. TheapexAnnotationsArgsSpacing
option is not available separately anymore. IfapexFormatAnnotation
option is enabled it would also format annotation arguments to lower came case issue. - Make the
apexFormatStandardTypes
option less powerful, removing the ability to correct chained methods calls. Now, the option will only work for types in declarations. This was made to increase reliability and make the output more predictable since it was possible that the variable name would be misinterpreted and printed uppercase, for example. - Allow an extra line break in the beginning of the class/interface declaration issue.
- Change the formatting behaviour for
apexFormatInlineComments
. It's now a choice option. Check out how it can be used in the changelog examples issue.
- Fix the issue with the package installation that was caused by
husky
.
start-apex-server
takes optional-c
flag, which will be passed on toapex-ast-serializer
as a comma-delimited list of allowed origins that will be added to the CORS headers returned by the parsing server.start-apex-server
pipes internal logs to console, so that errors can be caught more quickly by users.
- Fix an issue with the
apexSortModifiers
option which removes a method modifier if there is an own-line comment between annotation and method (issue). - Fix an issue with the
apexExplicitAccessModifier
option when all trigger variables are treated as fields, adding non neededprivate
keyword (issue). - Fix an issue with the
apexExplicitAccessModifier
option when thewebservice
method gets an access modifier (issue). - Fix an issue with the
apexExplicitAccessModifier
option when the method parameters getprivate
modifier (issue). - Update the
apexFormatAnnotations
option to convert thetestmethod
method modifier to the@IsTest
annotation (issue). - Change the formatting of
webservice
andtestmethod
modifiers to be always printed in lowercase instead ofwebService
andtestMethod
.
- Fix an issue with the
apexExplicitAccessModifier
option. Now it won't work for the anonymous Apex files.
- Add option to format inline comments (
apexFormatInlineComments
) - Add option to format annotation names to always be upper camel case (
apexFormatAnnotations
) - Add option to add spaces between annotation arguments keys and values (
apexAnnotationsArgsSpacing
) - Add option to make closing bracket remain on the same line if the block is empty (
apexEmptyBlockBracketLine
) - Add additional space before the opening bracket for the collections initialization:
new Map<> {
- Add option to format standard Apex types references (
apexFormatStandardTypes
) - Add option to format properties so that if getter or setter has only one statement they are aligned in one line (
apexExpandOneLineProperties
) - Add option to explicitly put the
private
keyword if the access modifier was not provided (apexExplicitAccessModifier
) - Add option to place class member modifiers in the specific order. For fields:
<access> static final transient
, for methods:<access> static/override virtual/abstract
(apexSortModifiers
)
- Fix binaryish expressions having wrong indentation inside parentheses (issue).
- Keep original position for comments in between If-Else blocks and Try-Catch blocks, accordingly fix issue with unprinted comment (issue).
- Use
yarn
for internal dependency management instead ofnpm
. If you forked this repository before this change, make sure to follow CONTRIBUTING.md to set up your environment again. start-apex-server
andstop-apex-server
no longer exports any methods. This should not affect any user functionality, but if you are a developer who's relying on those methods, please importstart
andstop
from http-server instead.
- Drop support for NodeJS < 14.
- Prettier Apex has been converted to Typescript, enabling faster response time to internal jorje changes from Salesforce.
- Breaking: Locations for
start-apex-server.js
andstop-apex-server.js
are changed - they are now in thedist
directory. - Add ability to specify
host
andport
options for built-in parsing server (issue).
- Add support for SOQL Geolocation Expression (issue).
- Fix SOQL Time literals always getting printed in UTC timezone.
- Fix wrong indentations inside long SELECT functions (issue).
- Remove extraneous newline at the end of long GROUP BY and WITH DATA CATEGORY clauses (issue).
- Fix unstable leading comment formatting for ternary expressions (issue).
- Add support for prettier-ignore comments in the middle of IfElseBlock (issue).
- Use user input to improve line break heuristics in short SOQL/SOSL queries (issue).
- Fix unstable leading comments before Block Statement.
- Support trailing
prettier-ignore
comments (issue). - Fix failure to call
apex-ast-serializer
because of excessively long CLASSPATH on Windows (issue). - Fix unstable end of line comments in binaryish expressions.
- Drop support for NodeJS < 12.
- Fix last comment inside New Expression turning into trailing comment (issue).
- Fix prettier-ignore comment getting attached to modifier node instead of surrounding expressions (issue).
- Fix Enum cases using wrong separator in
switch
statements (issue).
- Drop support for Java < 11.
- Add support for Java 16.
- Fix SOQL query string getting quoted incorrectly in LIKE expressions (issue).
- Prefer list init syntax
new Object[0]
in certain situations (issue) - thanks to @brianmfear.
- Remove extraneous indentation and blank line for HAVING clauses (issue).
- Upgrade dependencies to fix security issues.
- Move CI/CD pipeline from Travis to Github Actions.
- Add support for Safe Navigation Operator (doc).
- Always break up TYPEOF SOQL queries (issue).
- Remove extraneous grouping in certain binary-ish expressions (issue).
- Handle new jorje structure for types in enhanced for loops.
- Clearer error message when failing to connect to standalone Apex parser server (issue).
- Handle SOQL Select Distance Expression (issue).
- Use alignment instead of indentation to provide clarity for ternary expressions (issue).
- Use uppercase TRUE, FALSE, NULL in SOQL expressions (issue).
- Fix incorrect formatting of for loop inits without initialization (issue).
- Support Prettier 2.0 (issue).
- NodeJS support limited to version >= 10.13.0 - driven by Prettier 2.0.
- Remove extraneous leading empty line in anonymous code blocks.
- Sync parser name with Visual Studio Code language Id for Anonymous Apex (issue).
- Remove extraneous whitespaces between Enum modifiers (issue).
- Preserve code points from original source code (issue).
- Prettier >= 1.19 is now required to be used with this plugin,
in order to support new option type
string
.
- Add option
apexStandaloneHost
, default tolocalhost
.
- Fix last comment in Annotations being put in wrong location (issue).
- Fix Name Value Parameters using more newlines than necessary (issue).
- Remove
--apex-anonymous
option, useapex-anonymous
parser instead (issue).
- By default, add curly bracket spacing for maps, lists and sets (issue).
- Fix extraneous linebreaks being added after
this
variable expression (issue). - Fix wrong comment position in a long method/variable chain (issue).
- Fix extraneous linebreaks for empty parameter list in long method declarations (issue).
- Fix SOQL query numbers losing negative value (issue).
- Fix method call expressions containing
this
andsuper
having an extra indentation level. - Fix trailing comment wrong location after last element in list/set/map init literals (issue).
- Fix incorrect format for decimals/doubles (issue).
- Add support for Number Expression in SOQL Geolocation Literal (issue).
- Fix duplicated trailing empty lines for multiple expressions on the same line (issue).
- Fix expressions in Name Value Parameters not being indented (issue).
- Fix SOQL queries in binaryish expressions having extraneous indentations (issue).
- Fix SOQL query number being printed as different types (
big-decimal
toint
) in certain situations.
- CLI/Option change:
- Add
apex-insert-final-newline
option (issue).
- Add
- Remove newline before SOQL expression in ForInit (issue).
- Add space before colon in ForEnhancedControl (issue).
- Add support for AnnotationString (issue).
- Update dependency requirement for Prettier.
- Fix incorrect format for SOQL query with multiple types in FROM clause (issue).
- Fix incorrect order of expressions in SOSL query (issue).
- Add support for class and interface generics (issue).
- Remove references to deleted vendor file
apex-ast-serializer-ng
.
- CLI/Option change:
- Remove
apex-verify-ast
option. Please use--debug-check
instead.
- Remove
- Implement comments using Prettier's API.
- Add support for
prettier-ignore
directive (issue). - Add support for
--require-pragma
and--insert-pragma
CLI directives. - Use internal HTTP server instead of Nailgun for built in parser.
- Fix unstable comments in between If/Else blocks.
- Fix unstable comments in between Try/Catch/Finally blocks.
- Fix unstable comments in WhereCompoundExpr.
- Fix unstable comments for NestedExpr.
- Fix unstable formatting for Method Declaration with no body.
- Fix unstable comments for Annotations.
- Fix unstable leading comments to ValueWhen and ElseWhen blocks.
- Throw errors when encountering unknown node types.
- Fix long static method calls producing undeployable code (issue).
- Add support for Anonymous Code block with
--apex-anonymous
option. - CLI/Option change:
use-standalone-server
option is nowapex-standalone-parser
, and it is now a choice betweennone
andbuilt-in
.server-port
option is nowapex-standalone-port
.- Add
apex-verify-ast
option.
- Fix dangling comments being printed incorrectly for Triggers (issue). Thanks to @praksb, @ntotten and @vazexqi for their help on getting jorje fixed.
- Fix SOQL unary expression not generating space before next expression.
- Add support for SOQL WHERE Calculation Expression (issue).
- Add support for parameter modifiers (issue).
- Add support for
while
loop without body (issue). - Add support for
for
loop without body (issue). - Add support for Java expressions/typerefs (issue).
- Fix Package Version Expression.
- Fix Unicode characters being printed incorrectly (issue).
- Workaround for certain cases of AST verification failing (issue).
- Fix overlapping node with comment when comment contains special characters.
- Fix awkward breaks for long method call chain (issue),
- Remove breaks in Map types (issue).
- Fix binary/boolean expressions breaking after operation despite available space (issue).
- Fix leading comment to SOQL inner query being misindentified as trailing comment to previous column clause (issue).
- Fix awkward breaks for multiline binaryish expressions (issue).
- Fix formatting for Apex types containing expressions but do not add groups and/or breaks.
- Fix SOQL/SOSL boolean expressions having extra parentheses (issue).
- Fix ternary expressions not breaking correctly (issue).
- Fix comments not being indented in binaryish expressions (issue).
- Fix array index indentation surrounding variable expressions and method call expressions.
- Fix unstable IfBlock trailing comments.
- Fix unstable NameValueParameter trailing comments.
- Fix unstable WhereOpExpr trailing comments.
- Fix trailing comments after class names not being printed (issue).
- Add new lines in empty blocks for Enum.
- Add new lines to long list of annotation parameters.
- Add new lines to long list of method declaration parameters.
- Add new line after last usage parameter in long list for triggers.
- Add new lines to long list of conditions in loops.
- Fix missing alias in FROM expression (issue).
- Fix double quotes being escaped unnecessarily (issue).
- Fix inline comments in blocks being attached to wrong node (issue).
- Fix comments being pushed to next lines because of node's trailing empty line (issue).
- Fix comments not being printed if they appear before the root node (issue).
- Fix dangling comments not being printed for Class, Interface, Enum and Block Statement (issue).
- Add new lines in empty blocks (issue).
- Fix trailing comment being mistaken as leading comment in certain situations,
because
jorje
provides wrong start and end indexes for some node types (issue).
- Fix Annotated Declaration being indented too far (issue).
- Getter and setter will no longer break if they can fit on the same line.
- Add documentation for configuration options.
- Fix formatting for trailing comments at the end of block statements (issue).
- Fix issue in which comments right before semi colon are not printed (issue).
- Assert that all comments have been printed out in the formatted code.
- Fix long expressions not breaking into multi lines (issue).
- Fix
apex-ast-serializer
executables not having their execute bits set on *nix (issue).
- Support
WITH SECURITY_ENFORCED
in SOQL (issue). - Fix
npm scripts
pointing to old files.
- Fix DML operation having double indents (issue).
- Rename scripts to start and stop Apex Parser Server.
- Use Prettier's default options for
tabWidth
andprintWidth
. - Invoke
apex-ast-serializer
directly by default, with option to use Nailgun server.
- Initial release.