Releases: integrated-application-development/pasfmt
Releases · integrated-application-development/pasfmt
v0.7.0
Added
- Added formatting for multiline string interior whitespace. Enabled by default with new setting
format_multiline_strings.- Indentation is normalised to align the trailing quote with the leading quote. Lines in the
middle are adjusted to retain their original significant leading whitespace. - Internal line endings are normalised to match the configured line ending.
- Invalid multiline strings are left untouched.
- Indentation is normalised to align the trailing quote with the leading quote. Lines in the
- All keywords are now set to lowercase. This includes reserved words (like
beginandconst) but also includes
non-reserved words (likeabsoluteandoverride) when used in the context that makes them special. - Added formatting for the interior of inline comments
- If no whitespace exists after the
//(or///), one space is added.- "separator" lines are exempt, defined as a comment containing only 10 or more repetitions of a
non-alphanumeric character.
- "separator" lines are exempt, defined as a comment containing only 10 or more repetitions of a
- Trailing whitespace at the end of the comment is trimmed.
- If no whitespace exists after the
- All compiler directives are now set to uppercase. This includes switch directives (e.g.
{$O+}), parameter directives
(e.g.{$HINTS on}), and conditional directives (e.g.{$IFDEF Foo}).
v0.6.0
Fixed
- Fixed indentation of comments around statements outside of statement lists.
- Fixed performance issues with heavily nested conditional directives.
- Fixed formatting of anonymous routines containing subroutines.
Changed
- Unterminated string literals will never be merged with other tokens.
- Improved support for multiline strings.
- A break will be inserted before each multiline string to ensure stylistic consistency.
- Surrounding code will be appropriately wrapped.
- String contents currently can not be re-indented. Including the closing quotes.
- Anonymous routines are now wrapped onto multiple lines whenever they contain declaration sections
(e.g.var,const,type).
v0.5.1
Fixed
- Fixed formatting of
resourcestringsections. - Fixed indentation inside
initialization/finalizationsections.
v0.5.0
Changed
- Never break in the middle of
reference to functionandreference to procedure. - Improved consistency across procedural types and anonymous routine headers.
- Improved line wrapping layout heuristics for lines that exceed the
wrap_column. - Allow
set ofanonymous enum to be on same line as=.
Fixed
- Fixed formatting of structures after a label.
- Visibility specifiers (e.g.
private,public) are no longer treated like section headers when
used outside type declarations. - Fixed formatting of comments before the first item in import and exports clauses.
- Stopped consuming directive-like declarations following procedural types.
v0.4.0
This release most notably introduces:
- Line wrapping for all structures and lines
- Cursor tracking for IDE support
NB: This changelog combines the entries from v0.4.0-rc1 and v0.4.0-rc2
Fixed
- Fixed spacing around generics with composite type parameters (e.g.
array of,set of,string[10]). - Fixed fields being merged with comments in variant records.
A safety check has been added to prevent bugs of this kind in the future. - Fixed end of line comment placement after compiler directives.
- Fixed infinite loop on unterminated parameter list.
- Fixed lexing of conditional directive expressions containing compiler directives, comments, or strings.
- Fixed lexing of compiler directives similar to conditional directives (e.g.
{$if_}). - Fixed lexing of unterminated asm text literals at EOF.
- Fixed lexing of sequential conditionally-compiled asm keywords.
--config-fileno longer erroneously accepts a path to a directory and searches from it for a
pasfmt.tomlfile. It is now an error to provide a path to a directory.- Fixed detection of decoding errors when reading from stdin.
- Stopped ignoring non-existent paths (they were being treated as globs matching no files).
- Fixed errors when writing non-ASCII data in an ANSI encoding to a Windows Console. Now written as Unicode.
Changed
- Uses, contains, and requires clauses in
program,package, andlibraryfiles are no longer ignored.
Previously there were concerns over breaking IDE features by formatting these sections, but after some
testing and reconsideration we have decided that this is a non-issue and it's better to consistently
format all import clauses. - Compiler directives in
packagefiles are now flush with the margin, matching the style in
the code generated by RAD Studio. - Changed error message when
--mode=checkfails on stdin, now reads'<stdin>' has incorrect formatting. - Started using simple struct-level debug formatting for logging of the current configuration.
Previously it was in TOML format. - Started wrapping CLI help at the smallest of the terminal width and 120 characters.
- Changed whitespace configuration
line_endingnow controls the end-of-line sequence (previouslyreconstruction.eol). Default "native".use_tabsnow controls the character used for indentation. Default false.tab_widthnow controls the number of spaces per indentation. Default 2.continuation_indentsnow controls the number of indentations per continuation. Default 2.
- Changed indentation level of comments in various edge cases.
Added
- Added line wrapping to reflow all kinds of logical lines.
- Configuration option
wrap_columncontrols the line length. - Configuration option
begin_stylecontrols the location ofbeginin control flow statements.
- Configuration option
- Added cursor tracking, via the
--cursorCLI option.- Expects a comma-separated list of UTF-8 byte offsets into the file. After formatting, a line
with the structureCURSOR=1,2,3,4is printed to stderr, indicating the new locations of the
provided cursors.
- Expects a comma-separated list of UTF-8 byte offsets into the file. After formatting, a line
- Added debug logging for time taken to format each file.
- Added name for platform-dependent encoding configuration option, "native".
This has the behaviour of the previous implicit default.
Removed
- Stopped formatting inline assembly instructions. The lines are ignored.
v0.4.0-rc2
Fixed
- Fixed spacing around generics with composite type parameters (e.g.
array of,set of,string[10]). - Fixed fields being merged with comments in variant records.
A safety check has been added to prevent bugs of this kind in the future. - Fixed end of line comment placement after compiler directives.
- Fixed infinite loop on unterminated parameter list.
Changed
- Allow case arm statements to be formatted inline.
- Allow simple conditionally compiled code to be formatted inline.
v0.4.0-rc1
This is a release candidate. The styling of line wrapping is subject to change on feedback from the community.
This release most notably introduces:
- Line wrapping for all structures and lines
- Cursor tracking for IDE support
Fixed
- Fixed lexing of conditional directive expressions containing compiler directives, comments, or strings.
- Fixed lexing of compiler directives similar to conditional directives (e.g.
{$if_}). - Fixed lexing of unterminated asm text literals at EOF.
- Fixed lexing of sequential conditionally-compiled asm keywords.
--config-fileno longer erroneously accepts a path to a directory and searches from it for a
pasfmt.tomlfile. It is now an error to provide a path to a directory.- Fixed detection of decoding errors when reading from stdin.
- Stopped ignoring non-existent paths (they were being treated as globs matching no files).
- Fixed errors when writing non-ASCII data in an ANSI encoding to a Windows Console. Now written as Unicode.
Changed
- Changed error message when
--mode=checkfails on stdin, now reads'<stdin>' has incorrect formatting. - Started using simple struct-level debug formatting for logging of the current configuration.
Previously it was in TOML format. - Started wrapping CLI help at the smallest of the terminal width and 120 characters.
- Changed whitespace configuration
line_endingnow controls the end-of-line sequence (previouslyreconstruction.eol). Default "native".use_tabsnow controls the character used for indentation. Default false.tab_widthnow controls the number of spaces per indentation. Default 2.continuation_indentsnow controls the number of indentations per continuation. Default 2.
- Changed indentation level of comments in various edge cases.
Added
- Added line wrapping to reflow all kinds of logical lines.
- Configuration option
wrap_columncontrols the line length. - Configuration option
begin_stylecontrols the location ofbeginin control flow statements.
- Configuration option
- Added cursor tracking, via the
--cursorCLI option.- Expects a comma-separated list of UTF-8 byte offsets into the file. After formatting, a line
with the structureCURSOR=1,2,3,4is printed to stderr, indicating the new locations of the
provided cursors.
- Expects a comma-separated list of UTF-8 byte offsets into the file. After formatting, a line
- Added debug logging for time taken to format each file.
- Added name for platform-dependent encoding configuration option, "native".
This has the behaviour of the previous implicit default.
Removed
- Stopped formatting inline assembly instructions. The lines are ignored.
v0.3.0
[0.3.0] - 2024-05-29
Removed
RefTokenandOwningTokentypes.
Changed
Tokentype to be a struct containing astd::borrow::Cowfor the token content instead of
an enum ofRefTokenandOwningToken.--files-fileparameter to--files-from.
Fixed
- Missing
winapikeyword. - Erroneous removal of BOM.
- Erroneous transcoding of UTF-16 input to UTF-8.
- Unwanted use of the replacement character when encoding. This now results in an error.
v0.2.0
[0.2.0] - 2024-05-07
Added
stringas a keyword.- Support for Delphi 12 multi-line string literals.
-CCLI option to override configuration options.--modeCLI option which replaces the--writeand--verifyoptions.
The default for this option is dynamic; when files to format are provided the default isfiles,
otherwise (when formatting stdin) it'sstdout. This differs from the previous default behaviour
which was equivalent tostdout.
checkmode replaces--verifywith some differences:- Non-zero exit code in the case of incorrectly formatted files.
- Can be used in stdin/stdout mode.
- Messages for incorrectly formatted files prefixed with 'CHECK' instead of 'VERIFY', and are
sent to stderr, not stdout.
Formatter::format_into_bufandReconstructor::reconstruct_into_bufto allow reuse of memory
allocations.- Validation on the reconstruction settings. This now ensures that indentation, eol, and continuation
are all non-empty and only consist of whitespace. Without this validation, the format may not be
idempotent. - Colour styling in CLI help.
RawTokenTypeas a copy ofTokenTypewithIdentifierOrKeyword.
Removed
add,remove, andvariantas keywords.- short version of
--config-fileCLI option. --write/-wCLI option (now accessible via--mode=files).--verifyCLI option (replaced by--mode=checkwith some differences).IdentifierOrKeywordvariant ofTokenTypeenum.
Changed
TokenType::TextLiteralto contain aTextLiteralKind.- Handling of unterminated comments and text literals.
- The default encoding on Windows to be the system ANSI codepage.
- The default encoding on non-Windows platforms to be UTF-8.
- Handling of IO errors. Previously any IO error would immediately crash the program.
Now errors are logged when they occur and cause the program to exit non-zero after
all other files have been formatted successfully. - Default continuation to be the same as the configured indentation.
- The intermediate type of tokens between lexing and line parsing from
TokentoRawToken.
This is to allow the logical line parser to consolidate the token types while processing.
Additionally, formatters and consolidators operating after parsing do not need to worry about
any identifier/keyword ambiguities. - Logical line parsing:
- Added more
LogicalLineTypevariants.AssignmentCompilerDirectiveForLoopRoutineHeaderInlineDeclarationInlineStatementGuidCaseHeader
- Added support for more Delphi structures:
- Tagged records.
withstatements.forwardandexternalroutine declarations.
- Simplified handling for comments and compiler directives.
- Consolidated all token types based on context.
- Improved support for
propertyand routine directives.
- Added more
Fixed
- Incorrect parsing for generic type param lists containing semicolons.
- Extra trailing newline when formatting stdin to stdout.
- Lexical edge cases:
- Codepoints in
[U+00, U+20)andU+3000are now lexed as whitespace instead ofUnknown. - Non-ascii codepoints (excluding
U+3000) are now lexed as identifiers instead ofUnknown. - Hex and binary integer literals token types were reversed (unobservable with the current rules).
- Binary literals now can contain underscore (e.g.
%_1). - Asm labels now can contain
@characters. - Asm integer literals are now supported (e.g. octal
076O, hex0FFH/$FF, binary010B). - Keywords used in qualified names are now lexed as identifiers (e.g.
System.String). - Integer literals can now be escaped with multiple ampersands (e.g.
&&0).
- Codepoints in
- Incorrect encoding used for writing files with encodings inferred from a BOM.
- Incorrect encoding used in stdin/stdout mode; UTF-8 was always used, but now the configured
encoding is respected.
v0.1.0
[0.1.0] - 2023-08-28
Added
langmodule containing all common types.traitsmodule outlining the API.LexerTokenConsolidatorLogicalLineParserLogicalLineConsolidatorTokenIgnorerTokenRemoverLogicalLineFormatterLogicalLineFileFormatterReconstructor
- Default implementations of the fundamental traits.
- Ability to recognise and format uses clauses.
- Package and library imports are not yet parsed.
- Program uses clauses are ignored.
- Formatter to remove repeated empty new lines.
- Formatter to normalise to a single new line at eof.
- Trailing whitespace removal. This is a built-in feature.
- Orchestrator to handle parallelising the reading, formatting, and writing of files.
- Configuration and command-line frameworks.
- Default command-line interface.
- Formatting toggle comments.
- Benchmarking tool.
- Token spacing rules.