@@ -43,30 +43,45 @@ public class RequireJsIndex extends FileBasedIndexExtension<String, String> {
43
43
final Map <String , String > map = new HashMap <>();
44
44
final JSFile jsFile = (JSFile ) inputData .getPsiFile ();
45
45
46
- final JSVarStatement jsVarStatement = PsiTreeUtil .getChildOfType (jsFile , JSVarStatement .class );
46
+ final JSVarStatement jsVarStatement = PsiTreeUtil .getChildOfType (
47
+ jsFile ,
48
+ JSVarStatement .class
49
+ );
50
+
47
51
if (jsVarStatement == null ) {
48
52
return map ;
49
53
}
50
54
final JSVariable [] jsVariableList = jsVarStatement .getVariables ();
55
+
51
56
for (final JSVariable jsVariable : jsVariableList ) {
52
57
final String name = jsVariable .getName ();
58
+
53
59
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
+
55
65
if (config == null ) {
56
66
return map ;
57
67
}
58
68
parseConfigMap (map , config );
59
69
60
70
final JSProperty pathsMap = config .findProperty ("paths" );
71
+
61
72
if (pathsMap == null ) {
62
73
return map ;
63
74
}
64
- final JSObjectLiteralExpression [] pathGroupsWrappers = PsiTreeUtil .getChildrenOfType (pathsMap , JSObjectLiteralExpression .class );
75
+ final JSObjectLiteralExpression [] pathGroupsWrappers = PsiTreeUtil
76
+ .getChildrenOfType (pathsMap , JSObjectLiteralExpression .class );
77
+
65
78
for (final JSObjectLiteralExpression pathGroupsWrapper : pathGroupsWrappers ) {
66
79
final JSProperty [] allConfigs = pathGroupsWrapper .getProperties ();
80
+
67
81
for (final JSProperty mapping : allConfigs ) {
68
82
final String nameConfig = mapping .getName ();
69
83
final JSExpression value = mapping .getValue ();
84
+
70
85
if (value == null ) {
71
86
continue ;
72
87
}
@@ -86,21 +101,29 @@ private void parseConfigMap(
86
101
final JSObjectLiteralExpression config
87
102
) {
88
103
final JSProperty configMap = config .findProperty ("map" );
104
+
89
105
if (configMap == null ) {
90
106
return ;
91
107
}
92
108
93
- final JSObjectLiteralExpression [] configGroupsWrappers = PsiTreeUtil .getChildrenOfType (configMap , JSObjectLiteralExpression .class );
109
+ final JSObjectLiteralExpression [] configGroupsWrappers = PsiTreeUtil .getChildrenOfType (
110
+ configMap ,
111
+ JSObjectLiteralExpression .class
112
+ );
94
113
for (final JSObjectLiteralExpression configGroupsWrapper : configGroupsWrappers ) {
95
114
final PsiElement [] configGroups = configGroupsWrapper .getChildren ();
96
115
97
116
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
+ );
99
121
final JSProperty [] allConfigs = mappingWrapper .getProperties ();
100
122
101
123
for (final JSProperty mapping : allConfigs ) {
102
124
final String nameConfig = mapping .getName ();
103
125
final JSExpression value = mapping .getValue ();
126
+
104
127
if (value == null ) {
105
128
continue ;
106
129
}
@@ -118,10 +141,9 @@ private void parseConfigMap(
118
141
119
142
@ Override
120
143
public @ NotNull FileBasedIndex .InputFilter getInputFilter () {
121
- return virtualFile -> (
144
+ return virtualFile ->
122
145
virtualFile .getFileType ().equals (JavaScriptFileType .INSTANCE )
123
- && virtualFile .getName ().equals ("requirejs-config.js" )
124
- );
146
+ && virtualFile .getName ().equals ("requirejs-config.js" );
125
147
}
126
148
127
149
@ Override
@@ -134,6 +156,7 @@ public int getVersion() {
134
156
return 1 ;
135
157
}
136
158
159
+ @ Override
137
160
public @ NotNull DataExternalizer <String > getValueExternalizer () {
138
161
return EnumeratorStringDescriptor .INSTANCE ;
139
162
}
0 commit comments