Refactor publish view formatting and JSON fix pipeline (#197)#230
Open
svensieber wants to merge 12 commits into
Open
Refactor publish view formatting and JSON fix pipeline (#197)#230svensieber wants to merge 12 commits into
svensieber wants to merge 12 commits into
Conversation
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.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Summary
Follows up on #197.
FormatOptionsrecord to replace 4 overloaded boolean-parameter methods inAutoFormatPayloadPublishViewControllerJSON fix logic by removing redundant stabilize loop (64-pass worst case) and duplicate quote-repair regex\u0000null-char placeholder in unescape with proper char-by-char parsingSilentSaxErrorHandlerinto core module, eliminating duplication betweenXmlFormatPluginandXmlXsdValidatorJsonFormatauto-fix pipeline: multi-pass with trailing commas, missing colons/commas, smart quotes, BOM normalization, mismatched closerssun.misc.UnsafewithMockito.mockin testsPublishViewControllerFormattingTestandJsonFormatTest