diff --git a/CHANGELOG.md b/CHANGELOG.md
index 0db7ae405..ac5f9052f 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -2,6 +2,7 @@
### Features
- Rely on `intelliLang` plugin to inject `FlexibleSearch` and `Polyglot Query` languages into the Java code [#817](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/817)
+- Inject `FlexibleSearch` language into the `FlexibleSearchQuery` and its descendants in Java code [#819](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/819)
- Added navigation to the `items.xml` Ordering Attribute from the generated classes [#818](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/818)
### `Polyglot Query` enhancements
diff --git a/resources/injection/languageInjections.xml b/resources/injection/languageInjections.xml
index e3be47607..b091d695a 100644
--- a/resources/injection/languageInjections.xml
+++ b/resources/injection/languageInjections.xml
@@ -22,12 +22,10 @@
[y] FlexibleSearch
(\\s|.)*GET(\\s|.)*\{(.*)}
-
[y] Polyglot Query
(\\s|.)*SELECT(\\s|.)*FROM(\\s|.)*\{(\\s|.)*
-
\ No newline at end of file
diff --git a/src/com/intellij/idea/plugin/hybris/common/HybrisConstants.kt b/src/com/intellij/idea/plugin/hybris/common/HybrisConstants.kt
index c61c54775..2526ac1bf 100644
--- a/src/com/intellij/idea/plugin/hybris/common/HybrisConstants.kt
+++ b/src/com/intellij/idea/plugin/hybris/common/HybrisConstants.kt
@@ -270,7 +270,6 @@ object HybrisConstants {
const val CLASS_FQN_ITEM_ROOT = "de.hybris.platform.core.model.ItemModel"
const val CLASS_FQN_ENUM_ROOT = "de.hybris.platform.core.HybrisEnumValue"
const val CLASS_NAME_ENUM = "HybrisEnumValue"
- const val CLASS_NAME_FLEXIBLE_SEARCH_SERVICE = "FlexibleSearchService"
const val CLASS_FQN_INTERCEPTOR_MAPPING = "de.hybris.platform.servicelayer.interceptor.impl.InterceptorMapping"
const val CLASS_FQN_ANNOTATION_ACCESSOR = "de.hybris.bootstrap.annotations.Accessor"
const val CLASS_FQN_CONFIG_IMPORT_PROCESSOR = "de.hybris.platform.commerceservices.impex.impl.ConfigPropertyImportProcessor"
diff --git a/src/com/intellij/idea/plugin/hybris/startup/HybrisIntelliLangStartupActivity.kt b/src/com/intellij/idea/plugin/hybris/startup/HybrisIntelliLangStartupActivity.kt
index 0d74c8cd7..c4b492b71 100644
--- a/src/com/intellij/idea/plugin/hybris/startup/HybrisIntelliLangStartupActivity.kt
+++ b/src/com/intellij/idea/plugin/hybris/startup/HybrisIntelliLangStartupActivity.kt
@@ -18,14 +18,20 @@
package com.intellij.idea.plugin.hybris.startup
import com.intellij.idea.plugin.hybris.common.HybrisConstants
+import com.intellij.idea.plugin.hybris.flexibleSearch.FlexibleSearchLanguage
+import com.intellij.idea.plugin.hybris.polyglotQuery.PolyglotQueryLanguage
import com.intellij.idea.plugin.hybris.settings.HybrisProjectSettingsComponent
import com.intellij.openapi.project.DumbService
import com.intellij.openapi.project.Project
import com.intellij.openapi.startup.ProjectActivity
+import com.intellij.patterns.PsiJavaPatterns
import com.intellij.psi.JavaPsiFacade
import com.intellij.psi.search.GlobalSearchScope
import com.intellij.psi.search.searches.ClassInheritorsSearch
+import org.intellij.plugins.intelliLang.Configuration
+import org.intellij.plugins.intelliLang.inject.config.InjectionPlace
import org.intellij.plugins.intelliLang.inject.java.InjectionCache
+import org.intellij.plugins.intelliLang.inject.java.JavaLanguageInjectionSupport
/**
* TODO: reset Injection Cache on CRUD operation on classes related to FlexibleSearchQuery
@@ -40,6 +46,24 @@ class HybrisIntelliLangStartupActivity : ProjectActivity {
add(HybrisConstants.CLASS_NAME_FLEXIBLE_SEARCH_QUERY)
addAll(findCustomExtensionsOfTheFlexibleSearch(project))
}
+
+ val targetLanguages = setOf(FlexibleSearchLanguage.INSTANCE.id, PolyglotQueryLanguage.instance.id)
+
+ // TODO: replace with pattern declared in the XML file once https://youtrack.jetbrains.com/issue/IDEA-339624/ will be resolved.
+ // com.intellij.patterns.compiler.PatternCompiler cannot parse primitive booleans required by the pattern
+ Configuration.getInstance().getInjections(JavaLanguageInjectionSupport.JAVA_SUPPORT_ID)
+ .filter { targetLanguages.contains(it.injectedLanguageId) }
+ .forEach {
+ val injectionPlaces = it.injectionPlaces.toMutableSet()
+ val psiParameterInjectionPlace = InjectionPlace(
+ PsiJavaPatterns.psiParameter().ofMethod(
+ PsiJavaPatterns.psiMethod().definedInClass(PsiJavaPatterns.psiClass().inheritorOf(false, HybrisConstants.CLASS_FQN_FLEXIBLE_SEARCH_QUERY))
+ ),
+ true
+ )
+ injectionPlaces.add(psiParameterInjectionPlace)
+ it.setInjectionPlaces(*injectionPlaces.toTypedArray())
+ }
}
}