Skip to content

Conversation

@xterao
Copy link
Collaborator

@xterao xterao commented May 21, 2025

Reference custom function definition class from config file

Change the logic that previously referenced the custom function definition based on the ExpressionFunctions implementation class registered in the settings screen so that it now reads the class name from the doma.compile.config file at the root of the resources directory.

Since Doma assumes one ExpressionFunctions implementation per project, update this behavior to match that convention.

Cache the module directory structure and the contents of the config file.

  • The module directory structure cache is refreshed whenever the rename processor runs or if the directory used to locate the config file becomes invalid.
  • The config file cache is updated based on its last-modified timestamp.

Reimplementation of the following task
#175
#181

@xterao xterao added this to the 0.8.0 Release milestone May 21, 2025
@xterao xterao requested a review from Copilot May 21, 2025 05:33
@xterao xterao added enhancement New feature or request feature labels May 21, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR shifts the custom function registration from the plugin settings UI to reading the ExpressionFunctions implementation class from doma.compile.config, aligning with Doma’s one-implementation convention.

  • Removed custom-function UI, state and settings handling.
  • Added DomaCompileConfigUtil to load doma.expr.functions from doma.compile.config.
  • Updated references and inspections to use the config value and cleared path caches on refactoring.

Reviewed Changes

Copilot reviewed 40 out of 40 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
src/main/resources/messages/DomaToolsBundle.properties Removed custom-functions keys and renamed related message keys.
src/main/kotlin/org/domaframework/doma/intellij/setting/SettingComponent.kt Dropped custom-function UI components and binding logic.
src/main/kotlin/org/domaframework/doma/intellij/reference/SqlElFunctionCallExprReference.kt Updated function lookup to use config file instead of settings.
src/main/kotlin/org/domaframework/doma/intellij/common/config/DomaCompileConfigUtil.kt New utility to read and cache doma.compile.config entries.
README.md Documented new doma.expr.functions config usage.
Comments suppressed due to low confidence (3)

README.md:99

  • Remove or update this bullet, as the settings screen no longer allows entering custom function classes (it's now driven by doma.compile.config).
- Specify the class names that define custom functions.

src/main/kotlin/org/domaframework/doma/intellij/reference/SqlElFunctionCallExprReference.kt:66

  • [nitpick] Rename implementsClass to something like functionsClass for clarity, and remove the safe-call operator (?) since the variable is guaranteed non-null.
val methods = implementsClass?.findMethodsByName(variableName, true)?.firstOrNull()

src/main/kotlin/org/domaframework/doma/intellij/common/config/DomaCompileConfigUtil.kt:36

  • Add unit tests for getConfigValue to verify loading, caching behavior, and fallback when the key or file is missing.
fun getConfigValue(

holder: ProblemsHolder,
isOnTheFly: Boolean,
): PsiElementVisitor {
// TODO Support Kotlin Project
Copy link

Copilot AI May 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Either implement Kotlin support for this inspector or create a tracked issue and remove or clarify this TODO.

Copilot uses AI. Check for mistakes.
@xterao xterao linked an issue May 21, 2025 that may be closed by this pull request
@xterao xterao linked an issue May 21, 2025 that may be closed by this pull request
@xterao xterao force-pushed the feature/reference-doma-compile-config branch from 34cd6ab to a5f1b3a Compare May 21, 2025 05:55
@xterao xterao self-assigned this May 21, 2025
@xterao xterao force-pushed the feature/reference-doma-compile-config branch from 52bcad2 to 5e60af6 Compare May 21, 2025 06:04
@xterao xterao merged commit a1dc2f6 into main May 21, 2025
3 checks passed
@xterao xterao deleted the feature/reference-doma-compile-config branch May 21, 2025 06:37
@xterao xterao linked an issue May 26, 2025 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request feature

Projects

None yet

2 participants