Skip to content

Commit 482f513

Browse files
committed
Fix type resolution for parent elements in nested for directives
1 parent 70990bb commit 482f513

File tree

3 files changed

+8
-5
lines changed

3 files changed

+8
-5
lines changed

src/main/kotlin/org/domaframework/doma/intellij/common/util/ForDirectiveUtil.kt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,9 @@ class ForDirectiveUtil {
186186
forDirectiveBlocks.drop(1).forEach { directive ->
187187
// Get the definition type of the target directive
188188
val formItem = ForItem(directive.item)
189-
if (targetForItem != null && formItem.element.textOffset > targetForItem.textOffset) {
189+
if (targetForItem != null &&
190+
formItem.element.textOffset > targetForItem.textOffset
191+
) {
190192
return parentClassType
191193
}
192194
val forDirectiveExpr = formItem.getParentForDirectiveExpr()

src/main/kotlin/org/domaframework/doma/intellij/contributor/sql/provider/SqlParameterCompletionProvider.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,9 +421,9 @@ class SqlParameterCompletionProvider : CompletionProvider<CompletionParameters>(
421421
): Boolean {
422422
val project = top.project
423423
val forDirectiveBlocks = ForDirectiveUtil.getForDirectiveBlocks(top)
424-
ForDirectiveUtil.findForItem(top, forDirectives = forDirectiveBlocks) ?: return false
424+
val forItem = ForDirectiveUtil.findForItem(top, forDirectives = forDirectiveBlocks) ?: return false
425425

426-
val forItemClassType = ForDirectiveUtil.getForDirectiveItemClassType(project, forDirectiveBlocks) ?: return false
426+
val forItemClassType = ForDirectiveUtil.getForDirectiveItemClassType(project, forDirectiveBlocks, forItem) ?: return false
427427
val specifiedClassType = ForDirectiveUtil.resolveForDirectiveItemClassTypeBySuffixElement(top.text)
428428
val topClassType =
429429
if (specifiedClassType != null) {

src/main/kotlin/org/domaframework/doma/intellij/document/generator/DocumentDaoParameterGenerator.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,9 @@ class DocumentDaoParameterGenerator(
4545
val searchElement = fieldAccessBlocks?.firstOrNull() ?: originalElement
4646

4747
var isBatchAnnotation = false
48-
if (ForDirectiveUtil.findForItem(searchElement, forDirectives = forDirectives) != null) {
49-
val forItemClassType = ForDirectiveUtil.getForDirectiveItemClassType(project, forDirectives)
48+
val forItem = ForDirectiveUtil.findForItem(searchElement, forDirectives = forDirectives)
49+
if (forItem != null) {
50+
val forItemClassType = ForDirectiveUtil.getForDirectiveItemClassType(project, forDirectives, forItem)
5051
val specifiedClassType =
5152
ForDirectiveUtil.resolveForDirectiveItemClassTypeBySuffixElement(
5253
searchElement.text,

0 commit comments

Comments
 (0)