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

Not all custom search scopes registered #738

Merged
merged 2 commits into from
Sep 23, 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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
- `SAP Commerce` tool window sometimes appears without any content [#725](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/725)
- Register sub-modules source directories for custom modules [#728](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/728)
- Register test source directories for custom backoffice modules [#736](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/736)
- Not all custom search scopes registered [#738](https://github.com/epam/sap-commerce-intellij-idea-plugin/pull/738)

## [2023.2.8]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,12 @@
package com.intellij.idea.plugin.hybris.project.configurators.impl;

import com.intellij.find.FindSettings;
import com.intellij.icons.AllIcons;
import com.intellij.ide.projectView.impl.ModuleGroup;
import com.intellij.idea.plugin.hybris.common.utils.HybrisI18NBundleUtils;
import com.intellij.idea.plugin.hybris.common.utils.HybrisIcons;
import com.intellij.idea.plugin.hybris.project.configurators.SearchScopeConfigurator;
import com.intellij.idea.plugin.hybris.settings.HybrisApplicationSettings;
import com.intellij.idea.plugin.hybris.settings.HybrisApplicationSettingsComponent;
import com.intellij.openapi.application.ApplicationManager;
import com.intellij.openapi.module.ModifiableModuleModel;
import com.intellij.openapi.progress.ProgressIndicator;
Expand All @@ -33,6 +34,7 @@
import com.intellij.util.ArrayUtil;
import org.jetbrains.annotations.NotNull;

import javax.swing.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -61,7 +63,7 @@ public void configure(
NamedScope hybrisScope = null;

if (groupExists(model, customGroupName)) {
customScope = createScope(customGroupName);
customScope = createScope(HybrisIcons.INSTANCE.getEXTENSION_CUSTOM(), customGroupName);
newScopes.add(customScope);

newScopes.add(new NamedScope(
Expand All @@ -78,19 +80,19 @@ public void configure(
));
}
if (groupExists(model, platformGroupName)) {
platformScope = createScope(platformGroupName);
platformScope = createScope(HybrisIcons.INSTANCE.getMODULE_PLATFORM_GROUP(), platformGroupName);
newScopes.add(platformScope);
}
if (groupExists(model, commerceGroupName)) {
commerceScope = createScope(commerceGroupName);
commerceScope = createScope(HybrisIcons.INSTANCE.getMODULE_COMMERCE_GROUP(), commerceGroupName);
newScopes.add(commerceScope);
}
if (platformScope != null && commerceScope != null) {
hybrisScope = createScopeFor2Groups(platformGroupName, commerceGroupName);
hybrisScope = createScopeFor2Groups(HybrisIcons.INSTANCE.getEXTENSION_PLATFORM(), platformGroupName, commerceGroupName);
newScopes.add(hybrisScope);
}
if (groupExists(model, nonHybrisGroupName)) {
newScopes.add(createScope(nonHybrisGroupName));
newScopes.add(createScope(AllIcons.Ide.LocalScope, nonHybrisGroupName));
}
newScopes.add(new NamedScope(
HybrisI18NBundleUtils.message("hybris.scope.editable.all.ts.files"),
Expand Down Expand Up @@ -151,21 +153,25 @@ private static void addOrReplaceScopes(@NotNull final Project project, @NotNull

private static boolean groupExists(@NotNull final ModifiableModuleModel model, final String groupName) {
return !new ModuleGroup(List.of(groupName))
.modulesInGroup(model.getProject())
.modulesInGroup(model.getProject(), true)
.isEmpty();
}

@NotNull
private static NamedScope createScope(@NotNull final String groupName) {
private static NamedScope createScope(final Icon icon, @NotNull final String groupName) {
final FilePatternPackageSet filePatternPackageSet = new FilePatternPackageSet(
groupName + '*',
"*//*"
);
return new NamedScope(SEARCH_SCOPE_Y_PREFIX + ' ' + groupName, filePatternPackageSet);
return new NamedScope(
SEARCH_SCOPE_Y_PREFIX + ' ' + groupName,
icon,
filePatternPackageSet
);
}

@NotNull
private static NamedScope createScopeFor2Groups(@NotNull final String firstGroupName, @NotNull final String secondGroupName) {
private static NamedScope createScopeFor2Groups(final Icon icon, @NotNull final String firstGroupName, @NotNull final String secondGroupName) {
final FilePatternPackageSet firstFilePatternPackageSet = new FilePatternPackageSet(
firstGroupName + '*',
"*//*"
Expand All @@ -179,7 +185,8 @@ private static NamedScope createScopeFor2Groups(@NotNull final String firstGroup
secondFilePatternPackageSet
);
return new NamedScope(
SEARCH_SCOPE_Y_PREFIX + ' ' + firstGroupName + ' ' + secondGroupName,
SEARCH_SCOPE_Y_PREFIX + ' ' + firstGroupName + " & " + secondGroupName,
icon,
unionPackageSet
);
}
Expand Down