Skip to content

Commit 548359f

Browse files
645: Code refactoring
1 parent b206366 commit 548359f

File tree

1 file changed

+30
-24
lines changed

1 file changed

+30
-24
lines changed

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

Lines changed: 30 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -66,29 +66,7 @@ public class RequireJsIndex extends FileBasedIndexExtension<String, String> {
6666
return map;
6767
}
6868
parseConfigMap(map, config);
69-
70-
final JSProperty pathsMap = config.findProperty("paths");
71-
72-
if (pathsMap == null) {
73-
return map;
74-
}
75-
final JSObjectLiteralExpression[] pathGroupsWrappers = PsiTreeUtil
76-
.getChildrenOfType(pathsMap, JSObjectLiteralExpression.class);
77-
78-
for (final JSObjectLiteralExpression pathGroupsWrapper : pathGroupsWrappers) {
79-
final JSProperty[] allConfigs = pathGroupsWrapper.getProperties();
80-
81-
for (final JSProperty mapping : allConfigs) {
82-
final String nameConfig = mapping.getName();
83-
final JSExpression value = mapping.getValue();
84-
85-
if (value == null) {
86-
continue;
87-
}
88-
final String valueConfig = value.getText();
89-
map.put(nameConfig, valueConfig);
90-
}
91-
}
69+
parseConfigPaths(map, config);
9270
}
9371
}
9472

@@ -105,11 +83,11 @@ private void parseConfigMap(
10583
if (configMap == null) {
10684
return;
10785
}
108-
10986
final JSObjectLiteralExpression[] configGroupsWrappers = PsiTreeUtil.getChildrenOfType(
11087
configMap,
11188
JSObjectLiteralExpression.class
11289
);
90+
11391
for (final JSObjectLiteralExpression configGroupsWrapper : configGroupsWrappers) {
11492
final PsiElement[] configGroups = configGroupsWrapper.getChildren();
11593

@@ -134,6 +112,34 @@ private void parseConfigMap(
134112
}
135113
}
136114

115+
private void parseConfigPaths(
116+
final Map<String, String> map,
117+
final JSObjectLiteralExpression config
118+
) {
119+
final JSProperty pathsMap = config.findProperty("paths");
120+
121+
if (pathsMap == null) {
122+
return;
123+
}
124+
final JSObjectLiteralExpression[] pathGroupsWrappers = PsiTreeUtil
125+
.getChildrenOfType(pathsMap, JSObjectLiteralExpression.class);
126+
127+
for (final JSObjectLiteralExpression pathGroupsWrapper : pathGroupsWrappers) {
128+
final JSProperty[] allConfigs = pathGroupsWrapper.getProperties();
129+
130+
for (final JSProperty mapping : allConfigs) {
131+
final String nameConfig = mapping.getName();
132+
final JSExpression value = mapping.getValue();
133+
134+
if (value == null) {
135+
continue;
136+
}
137+
final String valueConfig = value.getText();
138+
map.put(nameConfig, valueConfig);
139+
}
140+
}
141+
}
142+
137143
@Override
138144
public @NotNull KeyDescriptor<String> getKeyDescriptor() {
139145
return new EnumeratorStringDescriptor();

0 commit comments

Comments
 (0)