Skip to content
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

Impex: Inject complete User Rights block on code completion for $START_USERRIGHTS #446

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
- Added `env.properties` support for project properties code completion [#419](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/419)
- Inject FlexibleSearch language into suitable macro declaration values [#433](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/433)
- Inject FlexibleSearch language into `SearchRestriction :: query` respecting `restrictedType` [#434](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/434)
- Inject complete `User Rights` block on code completion for `$START_USERRIGHTS` [#446](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/446)
- Inspection rule: validate that `lang` modifier value is present in the `lang.packs` [#417](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/417)
- Inspection rule: validate that `lang` modifier is used only for localized attributes [#418](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/418)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,22 @@ import com.intellij.idea.plugin.hybris.common.utils.HybrisIcons
import com.intellij.openapi.application.ApplicationManager
import com.intellij.util.ProcessingContext

private val keywords = mutableListOf(
"\$START_USERRIGHTS",
"\$END_USERRIGHTS",
"\$config-"
)

class ImpexKeywordMacroCompletionProvider : CompletionProvider<CompletionParameters>() {

override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
keywords
.map {
LookupElementBuilder.create(it)
.withIcon(HybrisIcons.MACROS)
}
.forEach { result.addElement(it) }

val userRightsStart = "\$START_USERRIGHTS"
val userRightsEnd = "\$END_USERRIGHTS"
result.addElement(LookupElementBuilder.create(
"""
$userRightsStart
Type;UID;MemberOfGroups;Password;Target;read;change;create;remove;change_perm
; ; ; ; ; ; ; ; ;
$userRightsEnd
""".trimIndent()
)
.withPresentableText("\$START_USERRIGHTS")
.withIcon(HybrisIcons.MACROS)
)
}

companion object {
Expand Down