-
Notifications
You must be signed in to change notification settings - Fork 0
Support custom functions #175
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this 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 pull request adds support for custom functions, enabling suggestion, inspection, and reference resolution when users register custom functions via settings.
- Introduces a new inspection processor for function call errors.
- Updates code formatting and common path parameter imports to use helper classes.
- Refactors function lookup and completion in SQL directives to use registered custom function settings.
Reviewed Changes
Copilot reviewed 29 out of 29 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| DaoPackageRenameListenerProcessor.kt | Updated import to use the CommonPathParameterHelper for resolving META-INF paths. |
| SqlInspectionVisitor.kt | Added support for visiting and processing SQL function calls via a new visitor method. |
| InspectionFunctionCallVisitorProcessor.kt | Introduces a processor that checks custom function registrations and issues an error if the function is missing. |
| SqlPostProcessor.kt | Modified SQL formatting logic to retrieve settings based on project context. |
| SqlFormattingModelBuilder.kt | Updated to use an active project helper when fetching SQL format settings. |
| SqlFormatPreProcessor.kt | Adjusted to pass the project instance when checking if SQL formatting is enabled. |
| PsiMethodExtension.kt | Removed deprecated code for Doma annotations. |
| ModuleExtensions.kt, ProjectExtensions.kt, DaoMethodUtil.kt, JarFileSearch.kt, FileTypeCheck.kt | Updated imports to use the CommonPathParameterHelper. |
| StaticBuildFunctionCollector.kt | Refactored function completion to iterate over custom function settings and improved the construction of lookup elements. |
| DirectiveCompletion.kt | Simplified by removing redundant project passing. |
| ExpressionFunctionsHelper.kt | Established the ExpressionFunctions interface and inheritor check for custom function resolution. |
| ActiveProjectHelper.kt | Added a utility to retrieve the active project based on focus. |
| CommonPathParameterHelper.kt | Introduced as a replacement for static constants, supporting path resolution improvements. |
Comments suppressed due to low confidence (1)
src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector/StaticBuildFunctionCollector.kt:70
- [nitpick] The filtering logic relies on bind.substringAfter('@') assuming that the bind string always contains an '@' character. Consider adding inline documentation or a safeguard to clarify this assumption.
it.name.startsWith(bind.substringAfter("@"))
… parameter in DirectiveCompletion
7799579 to
a9c1048
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Enable support for user-registered custom SQL functions across completion, inspection, and reference resolution, and migrate the SQL formatting flag to a project-level setting.
- Add
InspectionFunctionCallVisitorProcessorto validate calls against custom and built-in functions. - Introduce
StaticBuildFunctionCollectorfor completion of custom and built-in functions. - Rename and centralize SQL formatting settings under
DomaToolsFormatEnableSettings. - Update imports to use
CommonPathParameterHelperand adjust README to document new feature.
Reviewed Changes
Copilot reviewed 50 out of 50 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/kotlin/.../InspectionFunctionCallVisitorProcessor.kt | New visitor to inspect custom function calls |
| src/main/kotlin/.../formatter/SqlPostProcessor.kt | Switched to project-level DomaToolsFormatEnableSettings |
| src/main/kotlin/.../formatter/SqlFormattingModelBuilder.kt | Updated format‐enable check via ActiveProjectHelper |
| src/main/kotlin/.../formatter/SqlFormatPreProcessor.kt | Added project parameter to enable check, removed old settings |
| src/main/kotlin/.../common/sql/directive/collector/StaticBuildFunctionCollector.kt | New collector that indexes custom and built-in functions |
| src/main/kotlin/.../common/sql/validator/result/ValidationInvalidFunctionCallResult.kt | New result class for invalid function call inspection |
| src/main/kotlin/.../common/helper/CommonPathParameterHelper.kt | Introduce centralized path parameters helper |
| README.md | Documented new custom-function features and setting migration |
Comments suppressed due to low confidence (1)
src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector/StaticBuildFunctionCollector.kt:34
- This new logic for collecting custom and built-in functions lacks unit tests; add tests to cover scenarios with registered custom classes and the fallback to built-in functions.
public override fun collect(): List<LookupElement>? {
...maframework/doma/intellij/inspection/sql/processor/InspectionFunctionCallVisitorProcessor.kt
Outdated
Show resolved
Hide resolved
...maframework/doma/intellij/common/sql/validator/result/ValidationInvalidFunctionCallResult.kt
Outdated
Show resolved
Hide resolved
...maframework/doma/intellij/common/sql/validator/result/ValidationInvalidFunctionCallResult.kt
Outdated
Show resolved
Hide resolved
...g/domaframework/doma/intellij/common/sql/directive/collector/StaticBuildFunctionCollector.kt
Outdated
Show resolved
Hide resolved
src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlPostProcessor.kt
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for user-registered custom SQL functions in completion, inspection, and reference resolution, and moves the SQL formatting flag to project-level settings.
- Enable inspection of function calls against custom-registered classes, with fallback to built-in functions
- Offer custom functions in SQL completion and resolve their definitions for “Go To Declaration”
- Refactor SQL formatter to use a project-level enable flag via new
DomaToolsFormatEnableSettings
Reviewed Changes
Copilot reviewed 50 out of 50 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| src/main/kotlin/org/domaframework/doma/intellij/inspection/sql/processor/InspectionFunctionCallVisitorProcessor.kt | New visitor processor checks calls against custom and built-in functions |
| src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlPostProcessor.kt | Moved SQL format flag to project settings and extracted isEnableFormat |
| src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlFormattingModelBuilder.kt | Use ActiveProjectHelper to obtain project for formatting toggle |
| src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlFormatPreProcessor.kt | Updated isEnableFormat to accept Project and guard formatting |
| src/main/kotlin/org/domaframework/doma/intellij/extension/psi/PsiMethodExtension.kt | Removed unused annotation helper |
| src/main/kotlin/org/domaframework/doma/intellij/extension/ProjectExtensions.kt | Fallback to JavaPsiFacade when no project-scoped class is found |
| src/main/kotlin/org/domaframework/doma/intellij/extension/ModuleExtensions.kt | Switched to CommonPathParameterHelper for META-INF path |
| src/main/kotlin/org/domaframework/doma/intellij/contributor/sql/provider/SqlParameterCompletionProvider.kt | Drop unused Project and simplify directive handler instantiation |
| src/main/kotlin/org/domaframework/doma/intellij/common/sql/validator/result/ValidationInvalidFunctionCallResult.kt | New result type to highlight invalid custom function calls |
| src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/collector/StaticBuildFunctionCollector.kt | Rewritten collector to include custom functions with built-in fallback |
| src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/StaticDirectiveHandler.kt | Updated handler to pass element.project instead of injected Project |
| src/main/kotlin/org/domaframework/doma/intellij/common/sql/directive/DirectiveCompletion.kt | Removed unused Project constructor parameter |
| src/main/kotlin/org/domaframework/doma/intellij/common/psi/PsiDaoMethod.kt | Switched to CommonPathParameterHelper for resource paths |
| src/main/kotlin/org/domaframework/doma/intellij/common/helper/ExpressionFunctionsHelper.kt | New helper to locate and test against the ExpressionFunctions interface |
| src/main/kotlin/org/domaframework/doma/intellij/common/helper/ActiveProjectHelper.kt | Utility to retrieve the active IDE project |
| src/main/kotlin/org/domaframework/doma/intellij/common/dao/DaoMethodUtil.kt | Switched to CommonPathParameterHelper for resource constants |
| src/main/kotlin/org/domaframework/doma/intellij/common/JarFileSearch.kt | Switched to CommonPathParameterHelper for META-INF path |
| src/main/kotlin/org/domaframework/doma/intellij/common/FileTypeCheck.kt | Removed duplicate file-type check and switched to helper import |
| src/main/kotlin/org/domaframework/doma/intellij/common/CommonPathParameterHelper.kt | New helper object for common path constants |
| README.md | Documented custom-function inspection, completion, and reference features |
Comments suppressed due to low confidence (3)
src/main/kotlin/org/domaframework/doma/intellij/formatter/SqlPostProcessor.kt:71
- Missing import for
Project. Addimport com.intellij.openapi.project.Projectabove this function to ensure it compiles.
fun isEnableFormat(project: Project): Boolean {
src/main/kotlin/org/domaframework/doma/intellij/common/sql/validator/result/ValidationInvalidFunctionCallResult.kt:39
- This local
projectshadows the method parameterproject. Consider renaming one or removing the unused parameter to avoid confusion.
val project = identify.project
src/main/kotlin/org/domaframework/doma/intellij/common/helper/ExpressionFunctionsHelper.kt:25
- [nitpick] Holding a mutable static
expressionFunctioncan lead to stale or cross-project state. Consider returning the found class directly or scoping it per invocation.
var expressionFunction: PsiClass? = null
34fcfe8 to
a4a45a1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Adds support for user-registered custom functions in SQL editing—completion, validation, and reference resolution—while cleaning up project parameter passing and centralizing utilities.
- Remove explicit
projectparameters fromValidationResultsubclasses and useidentify.project - Implement dynamic collection of custom and built-in functions in
StaticBuildFunctionCollector - Introduce
ExpressionFunctionsHelperandActiveProjectHelper; consolidate path constants and update README
Reviewed Changes
Copilot reviewed 59 out of 59 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
ValidationResult.kt & related Validation*Result.kt |
Removed unused project parameters and streamlined registration of problems |
| StaticBuildFunctionCollector.kt | Refactored collection logic to load custom functions from settings and built-ins |
| ExpressionFunctionsHelper.kt | New helper for locating and checking ExpressionFunctions implementations |
| ActiveProjectHelper.kt | New helper for determining the currently active IDE project |
| CommonPathParameterHelper.kt & imports | Consolidated path constants into a single helper object |
| README.md | Updated documentation to describe new custom-function features |
a4a45a1 to
1b6db0b
Compare
Enable suggestion, inspection, and reference resolution for user-registered custom functions in function calls. Users register classes that define custom functions via the settings screen; during code completion, functions from those registered classes are offered as suggestions.
During code inspection, report an error if a function call refers to a method that is neither defined in any registered class nor declared in org.seasar.doma.expr.ExpressionFunctions.
For reference resolution, link each function call to the first class (among the registered ones) where the corresponding method is defined.
Setting
After this feature addition, the SQL formatting enable flag will be moved to the project-level settings. Since the configuration file has changed, please re-enable the flag in the settings screen (default: false).