Skip to content

Commit

Permalink
Merge pull request #386 from valb3r/bugfix/FBP-384-more-injections
Browse files Browse the repository at this point in the history
FBP-384. More injections
  • Loading branch information
valb3r authored Feb 17, 2024
2 parents 7129887 + 9d6fd5d commit 853ef3b
Showing 1 changed file with 27 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,14 @@ abstract class DefaultXmlInjector: MultiHostInjector {
listOf(
{ tryToInjectCalledElement(context, context, registrar) },
{ tryToInjectSkipExpression(context, context, registrar) },
{ tryToInjectInServiceTask(context, context, registrar) }
{ tryToInjectInTaskOfType("serviceTask", context, context, registrar) },
{ tryToInjectInTaskOfType("sendTask", context, context, registrar) }
).map { it() }.firstOrNull { it }
}
is XmlText -> { tryToInjectConditionExpression(context, context, registrar) }
is XmlText -> listOf(
{ tryToInjectConditionExpression(context, context, registrar)},
{ tryToInjectFieldExpression(context, context, registrar) }
).map { it() }.firstOrNull { it }
}
}

Expand Down Expand Up @@ -66,6 +70,25 @@ abstract class DefaultXmlInjector: MultiHostInjector {
return false
}

private fun tryToInjectFieldExpression(context: XmlText, asHost: PsiLanguageInjectionHost, registrar: MultiHostRegistrar): Boolean {
val parent = context.parent
if (parent !is XmlTag) {
return false
}

val enclosingParent = parent.parent
if (enclosingParent !is XmlTag) {
return false
}

if (enclosingParent.localName == "field" && parent.localName == "expression") {
injectSpel(asHost, registrar)
return true
}

return false
}

private fun tryToInjectCalledElement(context: XmlAttributeValue, asHost: PsiLanguageInjectionHost, registrar: MultiHostRegistrar): Boolean {
return injectByAttrName("calledElement", context, asHost, registrar)
}
Expand All @@ -88,13 +111,13 @@ abstract class DefaultXmlInjector: MultiHostInjector {
return false
}

private fun tryToInjectInServiceTask(context: XmlAttributeValue, asHost: PsiLanguageInjectionHost, registrar: MultiHostRegistrar): Boolean {
private fun tryToInjectInTaskOfType(taskType: String, context: XmlAttributeValue, asHost: PsiLanguageInjectionHost, registrar: MultiHostRegistrar): Boolean {
val parent = context.parent
if (parent !is XmlAttribute) {
return false
}

if (parent.parent.localName != "serviceTask") {
if (parent.parent.localName != taskType) {
return false
}

Expand Down

0 comments on commit 853ef3b

Please sign in to comment.