Skip to content

Commit 20ec7d1

Browse files
committed
Refactor utility classes and fix configuration inconsistencies
Refactored utility classes to improve structure and clarity by adding proper encapsulation and final declarations. Fixed group ID inconsistencies in plugin XML to align with intended usage. Re-enabled commented-out steps in `uitests.yml` for capturing and uploading artifacts on test failures.
1 parent 0a5dac6 commit 20ec7d1

File tree

4 files changed

+29
-24
lines changed

4 files changed

+29
-24
lines changed

.github/workflows/uitests.yml

+12-13
Original file line numberDiff line numberDiff line change
@@ -70,16 +70,15 @@ jobs:
7070
7171
# Uncomment if investigation is needed:
7272

73-
# - name: Capture Test Artifacts on Failure
74-
# if: failure() && matrix.os == 'windows-latest'
75-
# run: tar -cvzf video.tgz ./video
76-
# shell: bash
77-
#
78-
# - name: Upload Test Video Artifact
79-
# if: failure() && matrix.os == 'windows-latest'
80-
# uses: actions/upload-artifact@v4
81-
# with:
82-
# name: latest-test-video
83-
# path: video.tgz
84-
# overwrite: true
85-
73+
- name: Capture Test Artifacts on Failure
74+
if: failure() && matrix.os == 'windows-latest'
75+
run: tar -cvzf video.tgz ./video
76+
shell: bash
77+
78+
- name: Upload Test Video Artifact
79+
if: failure() && matrix.os == 'windows-latest'
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: latest-test-video
83+
path: video.tgz
84+
overwrite: true

src/main/java/com/magento/idea/magento2plugin/util/magento/IsFileInEditableModuleUtil.java

+3-4
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,19 @@ public static boolean execute(final PsiFile file) {
3737
* @return true if the file is in an editable module directory, false otherwise
3838
*/
3939
public static boolean execute(final Project project, final VirtualFile virtualFile) {
40-
final Settings settings = Settings.getInstance(project);
41-
List<String> editablePaths = settings.getMagentoFolders();
4240
final String magentoRootPath = MagentoPathUrlUtil.execute(project);
43-
final String magentoDesignPath = MagentoPathUrlUtil.getDesignPath(project);
44-
4541
if (magentoRootPath == null) {
4642
return false;
4743
}
4844

45+
final Settings settings = Settings.getInstance(project);
46+
List<String> editablePaths = settings.getMagentoFolders();
4947
if (editablePaths == null) {
5048
editablePaths = new ArrayList<>();
5149
}
5250

5351
editablePaths.add(magentoRootPath);
52+
final String magentoDesignPath = MagentoPathUrlUtil.getDesignPath(project);
5453
if (magentoDesignPath != null) {
5554
editablePaths.add(magentoDesignPath);
5655
}

src/main/java/com/magento/idea/magento2plugin/util/magento/MagentoPathUrlUtil.java

+12-5
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,22 @@
1111
import com.magento.idea.magento2plugin.magento.packages.Package;
1212
import com.magento.idea.magento2plugin.project.Settings;
1313

14-
public class MagentoPathUrlUtil {
14+
public final class MagentoPathUrlUtil {
15+
16+
/**
17+
* Private constructor to prevent instantiation of utility class.
18+
*/
19+
private MagentoPathUrlUtil() {
20+
}
21+
1522
/**
1623
* Constructs a file URL for the Magento packages root, based on the project settings.
1724
*
1825
* @param project the project instance
1926
* @return the constructed file URL
2027
*/
21-
public static String execute(Project project) {
22-
String magentoPath = Settings.getMagentoPath(project);
28+
public static String execute(final Project project) {
29+
final String magentoPath = Settings.getMagentoPath(project);
2330
if (magentoPath != null) {
2431
return VirtualFileManager.constructUrl(
2532
"file",
@@ -38,8 +45,8 @@ public static String execute(Project project) {
3845
* @param project the project instance
3946
* @return the constructed file URL
4047
*/
41-
public static String getDesignPath(Project project) {
42-
String magentoPath = Settings.getMagentoPath(project);
48+
public static String getDesignPath(final Project project) {
49+
final String magentoPath = Settings.getMagentoPath(project);
4350
if (magentoPath != null) {
4451
return VirtualFileManager.constructUrl(
4552
"file",

src/main/resources/META-INF/plugin.xml

+2-2
Original file line numberDiff line numberDiff line change
@@ -176,10 +176,10 @@
176176
</group>
177177

178178
<action id="AddMagentoContentRoot" class="com.magento.idea.magento2plugin.actions.content.root.MarkDirectoryAsMagentoContentRot" text="Mark Directory As Magento Code Root" description="Adds Magento code root">
179-
<add-to-group group-id="PS.MarkRootGroup" anchor="last"/>
179+
<add-to-group group-id="MarkRootGroup" anchor="last"/>
180180
</action>
181181
<action id="RemoveMagentoContentRoot" class="com.magento.idea.magento2plugin.actions.content.root.UnmarkDirectoryAsMagentoContentRot" text="Unmark Directory As Magento Code Root" description="Removes Magento code root">
182-
<add-to-group group-id="PS.MarkRootGroup" anchor="last"/>
182+
<add-to-group group-id="MarkRootGroup" anchor="last"/>
183183
</action>
184184
</actions>
185185

0 commit comments

Comments
 (0)