99import com .intellij .openapi .vfs .VirtualFile ;
1010import com .intellij .psi .PsiFile ;
1111import com .magento .idea .magento2plugin .project .Settings ;
12+ import java .util .ArrayList ;
1213import java .util .List ;
1314
1415public final class IsFileInEditableModuleUtil {
@@ -29,37 +30,33 @@ public static boolean execute(final PsiFile file) {
2930 }
3031
3132 /**
32- * Validates if a given virtual file is located within editable paths defined by Magento project structure .
33+ * Validates if a given virtual file is located within editable paths.
3334 *
3435 * @param project the current project containing the virtual file
3536 * @param virtualFile the file to check against editable module directories
3637 * @return true if the file is in an editable module directory, false otherwise
3738 */
3839 public static boolean execute (final Project project , final VirtualFile virtualFile ) {
39- final Settings settings = Settings .getInstance (project );
40- List <String > magentoToFolders = settings .getMagentoFolders ();
41- final String magentoPathUrl = MagentoPathUrlUtil .execute (project );
42- if (magentoPathUrl != null ) {
43- if (magentoToFolders == null ) {
44- magentoToFolders = List .of (
45- magentoPathUrl
46- );
47- } else {
48- magentoToFolders .add (
49- magentoPathUrl
50- );
51- }
40+ final String magentoRootPath = MagentoPathUrlUtil .execute (project );
41+ if (magentoRootPath == null ) {
42+ return false ;
5243 }
5344
45+ final Settings settings = Settings .getInstance (project );
46+ List <String > editablePaths = settings .getMagentoFolders ();
47+ if (editablePaths == null ) {
48+ editablePaths = new ArrayList <>();
49+ }
5450
55-
56- if (magentoToFolders == null ) {
57- return false ;
51+ editablePaths .add (magentoRootPath );
52+ final String magentoDesignPath = MagentoPathUrlUtil .getDesignPath (project );
53+ if (magentoDesignPath != null ) {
54+ editablePaths .add (magentoDesignPath );
5855 }
5956
60- final String filePath = virtualFile .getUrl ();
61- for (final String editablePath : magentoToFolders ) {
62- if (normalizeUrl (filePath ).startsWith (normalizeUrl (editablePath ))) {
57+ final String currentFilePath = virtualFile .getUrl ();
58+ for (final String editablePath : editablePaths ) {
59+ if (normalizeUrl (currentFilePath ).startsWith (normalizeUrl (editablePath ))) {
6360 return true ;
6461 }
6562 }
0 commit comments