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

CockpitNG: Added code completion for AdvancedSearch operator parameter #537

Merged
merged 2 commits into from
Aug 2, 2023
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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [2023.2.6]

### `CockpitNG` enhancements
- Added code completion for AdvancedSearch `operator` parameter [#537](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/537)

### Features
- Added possibility to import Gradle KTS projects as modules [#534](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/534)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,9 @@
package com.intellij.idea.plugin.hybris.system.cockpitng.model.advancedSearch;

import com.intellij.idea.plugin.hybris.common.HybrisConstants;
import com.intellij.util.xml.DomElement;
import com.intellij.util.xml.GenericAttributeValue;
import com.intellij.util.xml.Namespace;
import com.intellij.util.xml.Required;
import com.intellij.util.xml.SubTagList;
import com.intellij.idea.plugin.hybris.system.cockpitng.util.xml.CngMergeByConverter;
import com.intellij.idea.plugin.hybris.system.cockpitng.util.xml.CngOperatorConverter;
import com.intellij.util.xml.*;
import com.intellij.idea.plugin.hybris.system.cockpitng.model.config.hybris.MergeMode;
import com.intellij.idea.plugin.hybris.system.cockpitng.model.config.hybris.Positioned;
import org.jetbrains.annotations.NotNull;
Expand Down Expand Up @@ -55,6 +53,7 @@ public interface Field extends DomElement, Positioned {
*/
@NotNull
@com.intellij.util.xml.Attribute ("operator")
@Convert(CngOperatorConverter.class)
GenericAttributeValue<String> getOperator();


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,36 @@ import com.intellij.util.xml.DomManager

object CngUtils {

private val operatorValues = setOf(
"equals",
"unequal",
"startsWith",
"endsWith",
"contains",
"doesNotContain",
"like",
"greater",
"greaterOrEquals",
"less",
"lessOrEquals",
"in",
"notIn",
"exists",
"notExists",
"isEmpty",
"isNotEmpty",
"or",
"and",
"match",
)

fun isConfigFile(file: XmlFile) = DomManager.getDomManager(file.project).getFileElement(file, Config::class.java) != null

fun getValidMergeByValues(project: Project) = CngMetaModelAccess.getInstance(project).getMetaModel()
.contextAttributes
.keys
// exclude itself
.filter { Context.MERGE_BY != it }

fun getOperatorValues() = operatorValues
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* This file is part of "SAP Commerce Developers Toolset" plugin for Intellij IDEA.
* Copyright (C) 2019 EPAM Systems <[email protected]>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* See the GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.intellij.idea.plugin.hybris.system.cockpitng.util.xml

import com.intellij.idea.plugin.hybris.system.cockpitng.util.CngUtils
import com.intellij.util.xml.ConvertContext
import com.intellij.util.xml.ResolvingConverter

class CngOperatorConverter : ResolvingConverter<String>() {

override fun toString(t: String?, context: ConvertContext?) = t

override fun fromString(s: String?, context: ConvertContext?) = s

override fun getVariants(context: ConvertContext) = CngUtils.getOperatorValues()
}