Skip to content

Commit 9b2842e

Browse files
committed
Fixed CheckStyle and PMD issues
1 parent c053c60 commit 9b2842e

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

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

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -15,17 +15,17 @@
1515
import com.intellij.psi.PsiFile;
1616
import com.intellij.psi.PsiManager;
1717
import com.magento.idea.magento2plugin.util.magento.GetModuleNameByDirectoryUtil;
18-
import org.jetbrains.annotations.NotNull;
19-
import org.jetbrains.annotations.Nullable;
20-
2118
import java.util.Arrays;
2219
import java.util.List;
20+
import org.jetbrains.annotations.NotNull;
21+
import org.jetbrains.annotations.Nullable;
2322

2423
public class CopyMagentoPath extends CopyPathProvider {
25-
public static final String PHTML = "phtml";
26-
public static final String JS = "js";
27-
public static final String CSS = "css";
28-
private final List<String> acceptedTypes = Arrays.asList(PHTML, JS, CSS);
24+
public static final String PHTML_EXTENSION = "phtml";
25+
public static final String JS_EXTENSION = "js";
26+
public static final String CSS_EXTENSION = "css";
27+
private final List<String> acceptedTypes
28+
= Arrays.asList(PHTML_EXTENSION, JS_EXTENSION, CSS_EXTENSION);
2929
public static final String SEPARATOR = "::";
3030
private int index;
3131

@@ -51,7 +51,7 @@ public void update(@NotNull final AnActionEvent event) {
5151
}
5252
}
5353

54-
private boolean isNotValidFile(VirtualFile virtualFile) {
54+
private boolean isNotValidFile(final VirtualFile virtualFile) {
5555
return virtualFile != null && virtualFile.isDirectory()
5656
|| virtualFile != null && !acceptedTypes.contains(virtualFile.getExtension());
5757
}
@@ -77,31 +77,30 @@ public String getPathToElement(
7777
return null;
7878
}
7979
final StringBuilder fullPath = new StringBuilder(virtualFile.getPath());
80-
final StringBuilder magentoPath
81-
= new StringBuilder(moduleName);
8280

8381
index = -1;
8482
String[] paths;
8583

86-
if (PHTML.equals(virtualFile.getExtension())) {
84+
if (PHTML_EXTENSION.equals(virtualFile.getExtension())) {
8785
paths = templatePaths;
88-
} else if (JS.equals(virtualFile.getExtension()) || CSS.equals(virtualFile.getExtension())) {
86+
} else if (JS_EXTENSION.equals(virtualFile.getExtension())
87+
|| CSS_EXTENSION.equals(virtualFile.getExtension())) {
8988
paths = webPaths;
9089
} else {
9190
return fullPath.toString();
9291
}
9392

94-
final int endIndex = getIndexOf(fullPath, paths[++index], paths);
93+
final int endIndex = getIndexOf(paths, fullPath, paths[++index]);
9594
final int offset = paths[index].length();
9695

9796
fullPath.replace(0, endIndex + offset, "");
9897

99-
return magentoPath.append(SEPARATOR).append(fullPath).toString();
98+
return moduleName + SEPARATOR + fullPath;
10099
}
101100

102-
private int getIndexOf(final StringBuilder fullPath, final String path, final String[] paths) {
101+
private int getIndexOf(final String[] paths, final StringBuilder fullPath, final String path) {
103102
return fullPath.lastIndexOf(path) == -1
104-
? getIndexOf(fullPath, paths[++index], paths)
103+
? getIndexOf(paths, fullPath, paths[++index])
105104
: fullPath.lastIndexOf(path);
106105
}
107106
}

0 commit comments

Comments
 (0)