Skip to content

Conversation

@catturtle123
Copy link
Contributor

@catturtle123 catturtle123 commented Jan 23, 2026

This PR addresses issue #1726

Summary

  • Default Data Query Style Change: Changed the default query generation style to compact (single line) to ensure broader compatibility across Java versions.

  • Architectural Refinement (Interface Separation): Decoupled the query formatting logic by introducing the QueryFormatter interface with dedicated implementations (JpqlQueryFormatter, MongoQueryFormatter). This allows for repository-specific formatting strategies.

  • Robust String Escaping & Formatting:

  • Integrated StringEscapeUtils.escapeJava() to safe-guard generated queries against syntax errors.

  • Multiline Indentation: Improved Text Block generation by adding proper indentation/alignment to ensure the generated query is visually consistent with the surrounding Java code.

  • Configuration & Fallback: Updated logic to use compact and multiline keywords from UserSettings. Implemented a fallback mechanism that defaults to compact and triggers a log.warn for invalid or null inputs.

Key Changes

  • Refactoring & Logic:

  • QueryFormatter.java, JpqlQueryFormatter.java, MongoQueryFormatter.java: Separated formatting logic into an interface-based structure.

  • BootJavaConfig.java: Updated style selection and added validation/fallback logic.

  • DataRepositoryAotMetadataCodeLensProvider.java: Refactored to prioritize safety and proper indentation.

  • Test Suite Updates:

  • QueryMethodCodeActionProviderJpaTest.java & QueryMethodCodeActionProviderMongoDbTest.java: Updated to verify the output specifically for the compact style.

  • DataRepositoryAotMetadataCodeLensProviderTest.java: Added comprehensive test cases for both compact and multiline styles, verifying correct indentation.

Resolved Issues

  • Fixed Syntax Errors: Resolved IndexOutOfBoundsException by properly escaping special characters.
  • Visual Alignment: Multiline queries now include appropriate leading spaces, improving the aesthetics of the generated code.
  • Error Resilience: Prevents IDE tool failure by falling back to a safe default when configuration is missing or malformed.

Discussion Points

  • Test Coverage Asymmetry: Currently, DataRepositoryAotMetadataCodeLensProviderTest provides full coverage for both styles. However, QueryMethodCodeActionProviderJpaTest and QueryMethodCodeActionProviderMongoDbTest are currently limited to verifying the compact style. Should I expand these two classes to include multiline test cases as well to maintain consistency?
  • Fallback Strategy: Is the use of log.warn followed by a fallback to compact an acceptable approach for handling unexpected user configuration values? (Silent fallback to compact for null cases (no log.warn).)

Test

스크린샷 2026-01-24 오전 12 23 56 스크린샷 2026-01-24 오전 12 10 43 스크린샷 2026-01-24 오전 12 10 51 스크린샷 2026-01-24 오전 12 10 59 스크린샷 2026-01-24 오전 12 11 10

catturtle123 and others added 4 commits January 21, 2026 00:55
Signed-off-by: Junhwan Kim <musoyou1085@gmail.com>
Signed-off-by: Junhwan Kim <musoyou1085@gmail.com>
- Introduce QueryFormatter interface and implementations for JPQL and MongoDB queries
- Add BootJavaConfig option to select query style (compact or multiline)
- Update code lens and code action providers to use configurable query formatting
- Enhance tests to verify multiline and compact query styles

Signed-off-by: Junhwan Kim <musoyou1085@gmail.com>
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