|
9 | 9 | import com.intellij.openapi.vfs.VirtualFile;
|
10 | 10 | import com.intellij.psi.PsiFile;
|
11 | 11 | import com.magento.idea.magento2plugin.project.Settings;
|
| 12 | +import java.util.ArrayList; |
12 | 13 | import java.util.List;
|
13 | 14 |
|
14 | 15 | public final class IsFileInEditableModuleUtil {
|
@@ -37,31 +38,26 @@ public static boolean execute(final PsiFile file) {
|
37 | 38 | */
|
38 | 39 | public static boolean execute(final Project project, final VirtualFile virtualFile) {
|
39 | 40 | final Settings settings = Settings.getInstance(project);
|
40 |
| - List<String> magentoToFolders = settings.getMagentoFolders(); |
41 |
| - final String magentoPathUrl = MagentoPathUrlUtil.execute(project); |
42 |
| - final String magentoDesignUrl = MagentoPathUrlUtil.getDesignPath(project); |
43 |
| - if (magentoPathUrl != null) { |
44 |
| - if (magentoToFolders == null) { |
45 |
| - magentoToFolders = List.of( |
46 |
| - magentoPathUrl, |
47 |
| - magentoDesignUrl |
48 |
| - ); |
49 |
| - } else { |
50 |
| - magentoToFolders.add( |
51 |
| - magentoPathUrl |
52 |
| - ); |
53 |
| - } |
54 |
| - } |
| 41 | + List<String> editablePaths = settings.getMagentoFolders(); |
| 42 | + final String magentoRootPath = MagentoPathUrlUtil.execute(project); |
| 43 | + final String magentoDesignPath = MagentoPathUrlUtil.getDesignPath(project); |
55 | 44 |
|
| 45 | + if (magentoRootPath == null) { |
| 46 | + return false; |
| 47 | + } |
56 | 48 |
|
| 49 | + if (editablePaths == null) { |
| 50 | + editablePaths = new ArrayList<>(); |
| 51 | + } |
57 | 52 |
|
58 |
| - if (magentoToFolders == null) { |
59 |
| - return false; |
| 53 | + editablePaths.add(magentoRootPath); |
| 54 | + if (magentoDesignPath != null) { |
| 55 | + editablePaths.add(magentoDesignPath); |
60 | 56 | }
|
61 | 57 |
|
62 |
| - final String filePath = virtualFile.getUrl(); |
63 |
| - for (final String editablePath : magentoToFolders) { |
64 |
| - if (normalizeUrl(filePath).startsWith(normalizeUrl(editablePath))) { |
| 58 | + final String currentFilePath = virtualFile.getUrl(); |
| 59 | + for (final String editablePath : editablePaths) { |
| 60 | + if (normalizeUrl(currentFilePath).startsWith(normalizeUrl(editablePath))) { |
65 | 61 | return true;
|
66 | 62 | }
|
67 | 63 | }
|
|
0 commit comments