1
- /**
1
+ /*
2
2
* Copyright © Magento, Inc. All rights reserved.
3
3
* See COPYING.txt for license details.
4
4
*/
5
+
5
6
package com .magento .idea .magento2plugin .magento .packages ;
6
7
7
8
import com .intellij .json .psi .JsonFile ;
8
9
import com .intellij .json .psi .JsonObject ;
10
+ import com .intellij .openapi .components .Service ;
9
11
import com .intellij .openapi .project .DumbService ;
10
12
import com .intellij .openapi .project .Project ;
11
13
import com .intellij .openapi .vfs .VirtualFile ;
18
20
import com .intellij .psi .xml .XmlTag ;
19
21
import com .intellij .util .indexing .FileBasedIndex ;
20
22
import com .magento .idea .magento2plugin .stubs .indexes .ModulePackageIndex ;
21
- import org .jetbrains .annotations .NotNull ;
22
- import org .jetbrains .annotations .Nullable ;
23
23
import java .util .ArrayList ;
24
24
import java .util .Collection ;
25
25
import java .util .HashMap ;
26
26
import java .util .Map ;
27
+ import org .jetbrains .annotations .NotNull ;
28
+ import org .jetbrains .annotations .Nullable ;
29
+
30
+ @ Service
31
+ public final class MagentoComponentManager {
27
32
28
- public class MagentoComponentManager {
29
33
private Map <String , MagentoComponent > components = new HashMap <>();
30
34
private long cacheStartTime ;
31
35
private static final int CACHE_LIFE_TIME = 20000 ;
32
- private static MagentoComponentManager magentoComponentManager ;
33
- private Project project ;
36
+ private final Project project ;
34
37
35
- private MagentoComponentManager (Project project ){
38
+ public MagentoComponentManager (final Project project ) {
36
39
this .project = project ;
37
40
}
38
41
39
- public static MagentoComponentManager getInstance (@ NotNull Project project ) {
40
- if (magentoComponentManager == null ) {
41
- magentoComponentManager = new MagentoComponentManager (project );
42
- }
43
- return magentoComponentManager ;
42
+ public static MagentoComponentManager getInstance (final @ NotNull Project project ) {
43
+ return project .getService (MagentoComponentManager .class );
44
44
}
45
45
46
46
public Collection <MagentoComponent > getAllComponents () {
@@ -60,8 +60,8 @@ public <T extends MagentoComponent> Collection<T> getAllComponentsOfType(@NotNul
60
60
return result ;
61
61
}
62
62
63
- synchronized private Map <String , MagentoComponent > getComponents () {
64
- if (DumbService . getInstance ( project ). isDumb () || project . isDisposed ()) {
63
+ private synchronized Map <String , MagentoComponent > getComponents () {
64
+ if (project . isDisposed () || DumbService . getInstance ( project ). isDumb ()) {
65
65
return new HashMap <>();
66
66
}
67
67
0 commit comments