Skip to content

Releases: integrated-application-development/pasfmt

v0.6.0

25 Aug 04:23
Compare
Choose a tag to compare

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

02 Jun 05:51
Compare
Choose a tag to compare

Fixed

  • Fixed formatting of resourcestring sections.
  • Fixed indentation inside initialization/finalization sections.

v0.5.0

31 Mar 04:32
Compare
Choose a tag to compare

Changed

  • Never break in the middle of reference to function and reference 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 of anonymous 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

18 Mar 03:46
Compare
Choose a tag to compare

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-file no longer erroneously accepts a path to a directory and searches from it for a
    pasfmt.toml file. 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, and library files 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 package files are now flush with the margin, matching the style in
    the code generated by RAD Studio.
  • Changed error message when --mode=check fails 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_ending now controls the end-of-line sequence (previously reconstruction.eol). Default "native".
    • use_tabs now controls the character used for indentation. Default false.
    • tab_width now controls the number of spaces per indentation. Default 2.
    • continuation_indents now 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_column controls the line length.
    • Configuration option begin_style controls the location of begin in control flow statements.
  • Added cursor tracking, via the --cursor CLI option.
    • Expects a comma-separated list of UTF-8 byte offsets into the file. After formatting, a line
      with the structure CURSOR=1,2,3,4 is printed to stderr, indicating the new locations of the
      provided cursors.
  • 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

12 Mar 01:59
Compare
Choose a tag to compare
v0.4.0-rc2 Pre-release
Pre-release

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

20 Feb 02:54
Compare
Choose a tag to compare
v0.4.0-rc1 Pre-release
Pre-release

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-file no longer erroneously accepts a path to a directory and searches from it for a
    pasfmt.toml file. 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=check fails 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_ending now controls the end-of-line sequence (previously reconstruction.eol). Default "native".
    • use_tabs now controls the character used for indentation. Default false.
    • tab_width now controls the number of spaces per indentation. Default 2.
    • continuation_indents now 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_column controls the line length.
    • Configuration option begin_style controls the location of begin in control flow statements.
  • Added cursor tracking, via the --cursor CLI option.
    • Expects a comma-separated list of UTF-8 byte offsets into the file. After formatting, a line
      with the structure CURSOR=1,2,3,4 is printed to stderr, indicating the new locations of the
      provided cursors.
  • 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

29 May 03:02
Compare
Choose a tag to compare

[0.3.0] - 2024-05-29

Removed

  • RefToken and OwningToken types.

Changed

  • Token type to be a struct containing a std::borrow::Cow for the token content instead of
    an enum of RefToken and OwningToken.
  • --files-file parameter to --files-from.

Fixed

  • Missing winapi keyword.
  • 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

07 May 03:41
Compare
Choose a tag to compare

[0.2.0] - 2024-05-07

Added

  • string as a keyword.
  • Support for Delphi 12 multi-line string literals.
  • -C CLI option to override configuration options.
  • --mode CLI option which replaces the --write and --verify options.
    The default for this option is dynamic; when files to format are provided the default is files,
    otherwise (when formatting stdin) it's stdout. This differs from the previous default behaviour
    which was equivalent to stdout.

    check mode replaces --verify with 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_buf and Reconstructor::reconstruct_into_buf to 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.
  • RawTokenType as a copy of TokenType with IdentifierOrKeyword.

Removed

  • add, remove, and variant as keywords.
  • short version of --config-file CLI option.
  • --write/-w CLI option (now accessible via --mode=files).
  • --verify CLI option (replaced by --mode=check with some differences).
  • IdentifierOrKeyword variant of TokenType enum.

Changed

  • TokenType::TextLiteral to contain a TextLiteralKind.
  • 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 Token to RawToken.
    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 LogicalLineType variants.
      • Assignment
      • CompilerDirective
      • ForLoop
      • RoutineHeader
      • InlineDeclaration
      • InlineStatement
      • Guid
      • CaseHeader
    • Added support for more Delphi structures:
      • Tagged records.
      • with statements.
      • forward and external routine declarations.
    • Simplified handling for comments and compiler directives.
    • Consolidated all token types based on context.
    • Improved support for property and routine directives.

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) and U+3000 are now lexed as whitespace instead of Unknown.
    • Non-ascii codepoints (excluding U+3000) are now lexed as identifiers instead of Unknown.
    • 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, hex 0FFH/$FF, binary 010B).
    • 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).
  • 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

28 Aug 00:18
Compare
Choose a tag to compare

[0.1.0] - 2023-08-28

Added

  • lang module containing all common types.
  • traits module outlining the API.
    • Lexer
    • TokenConsolidator
    • LogicalLineParser
    • LogicalLineConsolidator
    • TokenIgnorer
    • TokenRemover
    • LogicalLineFormatter
    • LogicalLineFileFormatter
    • Reconstructor
  • 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.