1- /**
1+ /*
22 * Copyright © Magento, Inc. All rights reserved.
33 * See COPYING.txt for license details.
44 */
5+
56package com .magento .idea .magento2plugin .magento .packages ;
67
78import com .intellij .json .psi .JsonFile ;
89import com .intellij .json .psi .JsonObject ;
10+ import com .intellij .openapi .components .Service ;
911import com .intellij .openapi .project .DumbService ;
1012import com .intellij .openapi .project .Project ;
1113import com .intellij .openapi .vfs .VirtualFile ;
1820import com .intellij .psi .xml .XmlTag ;
1921import com .intellij .util .indexing .FileBasedIndex ;
2022import com .magento .idea .magento2plugin .stubs .indexes .ModulePackageIndex ;
21- import org .jetbrains .annotations .NotNull ;
22- import org .jetbrains .annotations .Nullable ;
2323import java .util .ArrayList ;
2424import java .util .Collection ;
2525import java .util .HashMap ;
2626import java .util .Map ;
27+ import org .jetbrains .annotations .NotNull ;
28+ import org .jetbrains .annotations .Nullable ;
29+
30+ @ Service
31+ public final class MagentoComponentManager {
2732
28- public class MagentoComponentManager {
2933 private Map <String , MagentoComponent > components = new HashMap <>();
3034 private long cacheStartTime ;
3135 private static final int CACHE_LIFE_TIME = 20000 ;
32- private static MagentoComponentManager magentoComponentManager ;
33- private Project project ;
36+ private final Project project ;
3437
35- private MagentoComponentManager (Project project ){
38+ public MagentoComponentManager (final Project project ) {
3639 this .project = project ;
3740 }
3841
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 );
4444 }
4545
4646 public Collection <MagentoComponent > getAllComponents () {
@@ -60,8 +60,8 @@ public <T extends MagentoComponent> Collection<T> getAllComponentsOfType(@NotNul
6060 return result ;
6161 }
6262
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 ()) {
6565 return new HashMap <>();
6666 }
6767
0 commit comments