Skip to content

Commit c053c60

Browse files
committed
Added CSS support for Copy Magento Path
1 parent 906a192 commit c053c60

File tree

1 file changed

+18
-21
lines changed

1 file changed

+18
-21
lines changed

src/com/magento/idea/magento2plugin/actions/CopyMagentoPath.java

Lines changed: 18 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@
2424
public class CopyMagentoPath extends CopyPathProvider {
2525
public static final String PHTML = "phtml";
2626
public static final String JS = "js";
27-
private final List<String> acceptedTypes = Arrays.asList(PHTML, JS);
27+
public static final String CSS = "css";
28+
private final List<String> acceptedTypes = Arrays.asList(PHTML, JS, CSS);
2829
public static final String SEPARATOR = "::";
2930
private int index;
3031

@@ -35,10 +36,11 @@ public class CopyMagentoPath extends CopyPathProvider {
3536
"templates/"
3637
};
3738

38-
private final String[] jsPaths = {
39+
private final String[] webPaths = {
3940
"view/frontend/web/",
4041
"view/adminhtml/web/",
41-
"view/base/web/"
42+
"view/base/web/",
43+
"web/"
4244
};
4345

4446
@Override
@@ -77,29 +79,24 @@ public String getPathToElement(
7779
final StringBuilder fullPath = new StringBuilder(virtualFile.getPath());
7880
final StringBuilder magentoPath
7981
= new StringBuilder(moduleName);
80-
String path = fullPath.toString();
82+
83+
index = -1;
84+
String[] paths;
8185

8286
if (PHTML.equals(virtualFile.getExtension())) {
83-
index = -1;
84-
final int endIndex = getIndexOf(fullPath, templatePaths[++index], templatePaths);
85-
final int offset = templatePaths[index].length();
87+
paths = templatePaths;
88+
} else if (JS.equals(virtualFile.getExtension()) || CSS.equals(virtualFile.getExtension())) {
89+
paths = webPaths;
90+
} else {
91+
return fullPath.toString();
92+
}
8693

87-
fullPath.replace(0, endIndex + offset, "");
88-
magentoPath.append(SEPARATOR);
89-
magentoPath.append(fullPath);
90-
path = magentoPath.toString();
91-
} else if (JS.equals(virtualFile.getExtension())) {
92-
index = -1;
93-
final int endIndex = getIndexOf(fullPath, jsPaths[++index], jsPaths);
94-
final int offset = jsPaths[index].length();
94+
final int endIndex = getIndexOf(fullPath, paths[++index], paths);
95+
final int offset = paths[index].length();
9596

96-
fullPath.replace(0, endIndex + offset, "");
97-
magentoPath.append(SEPARATOR);
98-
magentoPath.append(fullPath);
99-
path = magentoPath.toString();
100-
}
97+
fullPath.replace(0, endIndex + offset, "");
10198

102-
return path;
99+
return magentoPath.append(SEPARATOR).append(fullPath).toString();
103100
}
104101

105102
private int getIndexOf(final StringBuilder fullPath, final String path, final String[] paths) {

0 commit comments

Comments
 (0)