Skip to content

Commit 58f32f9

Browse files
645: Code refactoring
1 parent 67e9fc7 commit 58f32f9

File tree

1 file changed

+31
-8
lines changed

1 file changed

+31
-8
lines changed

src/com/magento/idea/magento2plugin/stubs/indexes/js/RequireJsIndex.java

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -43,30 +43,45 @@ public class RequireJsIndex extends FileBasedIndexExtension<String, String> {
4343
final Map<String, String> map = new HashMap<>();
4444
final JSFile jsFile = (JSFile) inputData.getPsiFile();
4545

46-
final JSVarStatement jsVarStatement = PsiTreeUtil.getChildOfType(jsFile, JSVarStatement.class);
46+
final JSVarStatement jsVarStatement = PsiTreeUtil.getChildOfType(
47+
jsFile,
48+
JSVarStatement.class
49+
);
50+
4751
if (jsVarStatement == null) {
4852
return map;
4953
}
5054
final JSVariable[] jsVariableList = jsVarStatement.getVariables();
55+
5156
for (final JSVariable jsVariable : jsVariableList) {
5257
final String name = jsVariable.getName();
58+
5359
if (name.equals("config")) {
54-
final JSObjectLiteralExpression config = PsiTreeUtil.getChildOfType(jsVariable, JSObjectLiteralExpression.class);
60+
final JSObjectLiteralExpression config = PsiTreeUtil.getChildOfType(
61+
jsVariable,
62+
JSObjectLiteralExpression.class
63+
);
64+
5565
if (config == null) {
5666
return map;
5767
}
5868
parseConfigMap(map, config);
5969

6070
final JSProperty pathsMap = config.findProperty("paths");
71+
6172
if (pathsMap == null) {
6273
return map;
6374
}
64-
final JSObjectLiteralExpression[] pathGroupsWrappers = PsiTreeUtil.getChildrenOfType(pathsMap, JSObjectLiteralExpression.class);
75+
final JSObjectLiteralExpression[] pathGroupsWrappers = PsiTreeUtil
76+
.getChildrenOfType(pathsMap, JSObjectLiteralExpression.class);
77+
6578
for (final JSObjectLiteralExpression pathGroupsWrapper : pathGroupsWrappers) {
6679
final JSProperty[] allConfigs = pathGroupsWrapper.getProperties();
80+
6781
for (final JSProperty mapping : allConfigs) {
6882
final String nameConfig = mapping.getName();
6983
final JSExpression value = mapping.getValue();
84+
7085
if (value == null) {
7186
continue;
7287
}
@@ -86,21 +101,29 @@ private void parseConfigMap(
86101
final JSObjectLiteralExpression config
87102
) {
88103
final JSProperty configMap = config.findProperty("map");
104+
89105
if (configMap == null) {
90106
return;
91107
}
92108

93-
final JSObjectLiteralExpression[] configGroupsWrappers = PsiTreeUtil.getChildrenOfType(configMap, JSObjectLiteralExpression.class);
109+
final JSObjectLiteralExpression[] configGroupsWrappers = PsiTreeUtil.getChildrenOfType(
110+
configMap,
111+
JSObjectLiteralExpression.class
112+
);
94113
for (final JSObjectLiteralExpression configGroupsWrapper : configGroupsWrappers) {
95114
final PsiElement[] configGroups = configGroupsWrapper.getChildren();
96115

97116
for (final PsiElement configGroup : configGroups) {
98-
final JSObjectLiteralExpression mappingWrapper = PsiTreeUtil.getChildOfType(configGroup, JSObjectLiteralExpression.class);
117+
final JSObjectLiteralExpression mappingWrapper = PsiTreeUtil.getChildOfType(
118+
configGroup,
119+
JSObjectLiteralExpression.class
120+
);
99121
final JSProperty[] allConfigs = mappingWrapper.getProperties();
100122

101123
for (final JSProperty mapping : allConfigs) {
102124
final String nameConfig = mapping.getName();
103125
final JSExpression value = mapping.getValue();
126+
104127
if (value == null) {
105128
continue;
106129
}
@@ -118,10 +141,9 @@ private void parseConfigMap(
118141

119142
@Override
120143
public @NotNull FileBasedIndex.InputFilter getInputFilter() {
121-
return virtualFile -> (
144+
return virtualFile ->
122145
virtualFile.getFileType().equals(JavaScriptFileType.INSTANCE)
123-
&& virtualFile.getName().equals("requirejs-config.js")
124-
);
146+
&& virtualFile.getName().equals("requirejs-config.js");
125147
}
126148

127149
@Override
@@ -134,6 +156,7 @@ public int getVersion() {
134156
return 1;
135157
}
136158

159+
@Override
137160
public @NotNull DataExternalizer<String> getValueExternalizer() {
138161
return EnumeratorStringDescriptor.INSTANCE;
139162
}

0 commit comments

Comments
 (0)