Skip to content

Refactor publish view formatting and JSON fix pipeline (#197)#230

Open
svensieber wants to merge 12 commits into
EXXETA:developfrom
svensieber:develop
Open

Refactor publish view formatting and JSON fix pipeline (#197)#230
svensieber wants to merge 12 commits into
EXXETA:developfrom
svensieber:develop

Conversation

@svensieber
Copy link
Copy Markdown
Collaborator

Summary

Follows up on #197.

  • Introduce FormatOptions record to replace 4 overloaded boolean-parameter methods in AutoFormatPayload
  • Simplify PublishViewController JSON fix logic by removing redundant stabilize loop (64-pass worst case) and duplicate quote-repair regex
  • Replace \u0000 null-char placeholder in unescape with proper char-by-char parsing
  • Extract shared SilentSaxErrorHandler into core module, eliminating duplication between XmlFormatPlugin and XmlXsdValidator
  • Enhance JsonFormat auto-fix pipeline: multi-pass with trailing commas, missing colons/commas, smart quotes, BOM normalization, mismatched closers
  • Add Prettify button, separate highlighting toggle from auto-formatting
  • Add Mockito test dependency, replace sun.misc.Unsafe with Mockito.mock in tests
  • Add PublishViewControllerFormattingTest and JsonFormatTest

Sven Sieber added 12 commits September 17, 2025 14:22
# Conflicts:
#	core/src/main/java/org/correomqtt/core/plugin/PluginManager.java
…SON fix pipeline, extract shared utilities

- Replace 4 overloaded boolean-parameter methods in AutoFormatPayload with FormatOptions record
- Simplify PublishViewController JSON fix logic by removing redundant stabilize loop and duplicate quote-repair
- Introduce proper char-by-char unescape instead of null-char placeholder
- Extract shared SilentSaxErrorHandler into core module, used by XmlFormatPlugin and XmlXsdValidator
- Add Prettify button, separate highlighting toggle from auto-formatting
- Enhance JsonFormat auto-fix: multi-pass pipeline, trailing commas, missing colons, smart quotes, BOM normalization
- Add Mockito test dependency, replace sun.misc.Unsafe with Mockito.mock in tests
- Add PublishViewControllerFormattingTest and JsonFormatTest
- Add i18n keys for new UI elements (DE/EN)
…thods

- AutoFormatPayload: extract detectFormat(), findFormat(), applyFormatting()
- JsonFormat: extract JsonTokenFixer, StringScanner, span builder helpers
- Fix empty method comments, unused imports, unnecessary casts, unreachable catch
- Replace string concatenations with text blocks in tests
…inner class

- SilentSaxErrorHandler: remove singleton pattern, use plain instantiation
- JsonTokenFixer: move all helper methods into inner class where they belong
- Remove unused usedFallback variable and unused prettyString parameter
- Simplify scanDoubleQuotedString to return boolean instead of record
- Move SilentSaxErrorHandler from core into xml-format and xml-xsd-validator plugins
- Revert AutoFormatPayload and test SonarCloud refactoring (no gui changes)
- Make SilentSaxErrorHandler package-private in each plugin
Prettify, minify, fix JSON, escape, and unescape buttons are commented
out in the publish view FXML, controller, and tests. Only the
highlighting toggle button remains active. These features will be
re-implemented as plugin UI contributions.
getFxSpans() used getPrettyString() to build spans, causing a length
mismatch with the actual CodeArea text in highlight-only mode. Changed
both JsonFormat and XmlFormatPlugin to use the original text instead.
Also converted JsonMatch from Lombok class to Java record and added
null-token guard in getMatches().
Refactor AutoFormatPayload.autoFormatPayload() to reduce cognitive
complexity by extracting format-finding and format-application logic
into focused helper methods, eliminating break/continue statements.

Replace 4 duplicate span-length tests in JsonFormatTest with a single
parameterized test.
@sonarqubecloud
Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant