Java Code Examples for com.intellij.psi.util.PsiModificationTracker

The following examples show how to use com.intellij.psi.util.PsiModificationTracker. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: idea-php-typo3-plugin   Source File: ResourcePathIndex.java    License: MIT License 6 votes vote down vote up
@NotNull
private synchronized static Collection<String> getAllResourceKeys(@NotNull Project project) {
    CachedValue<Collection<String>> userData = project.getUserData(RESOURCE_KEYS);
    if (userData != null && userData.hasUpToDateValue()) {
        return RESOURCE_KEYS_LOCAL_CACHE.getOrDefault(project, new ArrayList<>());
    }

    CachedValue<Collection<String>> cachedValue = CachedValuesManager.getManager(project).createCachedValue(() -> {
        Collection<String> allKeys = FileBasedIndex.getInstance().getAllKeys(ResourcePathIndex.KEY, project);
        if (RESOURCE_KEYS_LOCAL_CACHE.containsKey(project)) {
            RESOURCE_KEYS_LOCAL_CACHE.replace(project, allKeys);
        } else {
            RESOURCE_KEYS_LOCAL_CACHE.put(project, allKeys);
        }

        return CachedValueProvider.Result.create(new ArrayList<>(), PsiModificationTracker.MODIFICATION_COUNT);
    }, false);
    project.putUserData(RESOURCE_KEYS, cachedValue);

    return RESOURCE_KEYS_LOCAL_CACHE.getOrDefault(project, cachedValue.getValue());
}
 
Example 2
@Nullable
private RunConfigurationContext findTestContext(ConfigurationContext context) {
  if (!SmRunnerUtils.getSelectedSmRunnerTreeElements(context).isEmpty()) {
    // handled by a different producer
    return null;
  }
  ContextWrapper wrapper = new ContextWrapper(context);
  PsiElement psi = context.getPsiLocation();
  return psi == null
      ? null
      : CachedValuesManager.getCachedValue(
          psi,
          cacheKey,
          () ->
              CachedValueProvider.Result.create(
                  doFindTestContext(wrapper.context),
                  PsiModificationTracker.MODIFICATION_COUNT,
                  BlazeSyncModificationTracker.getInstance(wrapper.context.getProject())));
}
 
Example 3
@Nullable
private BinaryRunContext findRunContext(ConfigurationContext context) {
  if (!SmRunnerUtils.getSelectedSmRunnerTreeElements(context).isEmpty()) {
    // not a binary run context
    return null;
  }
  ContextWrapper wrapper = new ContextWrapper(context);
  PsiElement psi = context.getPsiLocation();
  return psi == null
      ? null
      : CachedValuesManager.getCachedValue(
          psi,
          () ->
              CachedValueProvider.Result.create(
                  doFindRunContext(wrapper.context),
                  PsiModificationTracker.MODIFICATION_COUNT,
                  BlazeSyncModificationTracker.getInstance(wrapper.context.getProject())));
}
 
Example 4
Source Project: intellij   Source File: VirtualFileTestContextProvider.java    License: Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public RunConfigurationContext getTestContext(ConfigurationContext context) {
  PsiElement psi = context.getPsiLocation();
  if (!(psi instanceof PsiFileSystemItem) || !(psi instanceof FakePsiElement)) {
    return null;
  }
  VirtualFile vf = ((PsiFileSystemItem) psi).getVirtualFile();
  if (vf == null) {
    return null;
  }
  WorkspacePath path = getWorkspacePath(context.getProject(), vf);
  if (path == null) {
    return null;
  }
  return CachedValuesManager.getCachedValue(
      psi,
      () ->
          CachedValueProvider.Result.create(
              doFindTestContext(context, vf, psi, path),
              PsiModificationTracker.MODIFICATION_COUNT,
              BlazeSyncModificationTracker.getInstance(context.getProject())));
}
 
Example 5
Source Project: intellij   Source File: ProducerUtils.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Based on {@link JUnitUtil#isTestClass}. We don't use that directly because it returns true for
 * all inner classes of a test class, regardless of whether they're also test classes.
 */
public static boolean isTestClass(PsiClass psiClass) {
  if (psiClass.getQualifiedName() == null) {
    return false;
  }
  if (JUnitUtil.isJUnit5(psiClass) && JUnitUtil.isJUnit5TestClass(psiClass, true)) {
    return true;
  }
  if (!PsiClassUtil.isRunnableClass(psiClass, true, true)) {
    return false;
  }
  if (isJUnit4Class(psiClass)) {
    return true;
  }
  if (isTestCaseInheritor(psiClass)) {
    return true;
  }
  return CachedValuesManager.getCachedValue(
      psiClass,
      () ->
          CachedValueProvider.Result.create(
              hasTestOrSuiteMethods(psiClass),
              PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT));
}
 
Example 6
Source Project: idea-php-shopware-plugin   Source File: SubscriberIndexUtil.java    License: MIT License 6 votes vote down vote up
@NotNull
public static Collection<ServiceResource> getIndexedBootstrapResources(@NotNull Project project) {

    // cache
    CachedValue<Collection<ServiceResource>> cache = project.getUserData(SERVICE_RESOURCE);
    if (cache == null) {
        cache = CachedValuesManager.getManager(project).createCachedValue(() -> CachedValueProvider.Result.create(
            getIndexedBootstrapResources(project, BootstrapResource.INIT_RESOURCE, BootstrapResource.AFTER_INIT_RESOURCE, BootstrapResource.AFTER_REGISTER_RESOURCE),
            PsiModificationTracker.MODIFICATION_COUNT
        ), false);

        project.putUserData(SERVICE_RESOURCE, cache);
    }

    return cache.getValue();
}
 
Example 7
Source Project: consulo-unity3d   Source File: Unity3dManifest.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
public static Unity3dManifest parse(@Nonnull Project project)
{
	return CachedValuesManager.getManager(project).getCachedValue(project, () ->
	{
		Path projectPath = Paths.get(project.getBasePath());
		Path manifestJson = projectPath.resolve(Paths.get("Packages", "manifest.json"));
		if(Files.exists(manifestJson))
		{
			Gson gson = new Gson();
			try (Reader reader = Files.newBufferedReader(manifestJson))
			{
				return CachedValueProvider.Result.create(gson.fromJson(reader, Unity3dManifest.class), PsiModificationTracker.MODIFICATION_COUNT);
			}
			catch(Exception e)
			{
				LOG.error(e);
			}
		}
		return CachedValueProvider.Result.create(EMPTY, PsiModificationTracker.MODIFICATION_COUNT);
	});
}
 
Example 8
@Override
@NotNull
public Collection<String> getGlobalNamespaces(@NotNull AnnotationGlobalNamespacesLoaderParameter parameter) {
    Project project = parameter.getProject();

    CachedValue<Collection<String>> cache = project.getUserData(CACHE);

    if(cache == null) {
        cache = CachedValuesManager.getManager(project).createCachedValue(() ->
            CachedValueProvider.Result.create(getGlobalNamespacesInner(project), PsiModificationTracker.MODIFICATION_COUNT), false
        );

        project.putUserData(CACHE, cache);
    }

    return cache.getValue();
}
 
Example 9
Source Project: consulo-csharp   Source File: CSharpModifierListImplUtil.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
@RequiredReadAction
public static EnumSet<CSharpModifier> getModifiersCached(@Nonnull CSharpModifierList modifierList)
{
	if(!modifierList.isValid())
	{
		return emptySet;
	}

	return CachedValuesManager.getCachedValue(modifierList, () ->
	{
		Set<CSharpModifier> modifiers = new THashSet<>();
		for(CSharpModifier modifier : CSharpModifier.values())
		{
			if(hasModifier(modifierList, modifier))
			{
				modifiers.add(modifier);
			}
		}
		return CachedValueProvider.Result.create(modifiers.isEmpty() ? emptySet : EnumSet.copyOf(modifiers), PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
	});
}
 
Example 10
Source Project: consulo-csharp   Source File: CSharpTypeDeclarationImpl.java    License: Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
@Nonnull
@Override
public DotNetTypeRef[] getExtendTypeRefs()
{
	return CachedValuesManager.getCachedValue(this, new CachedValueProvider<DotNetTypeRef[]>()
	{
		@Nullable
		@Override
		@RequiredReadAction
		public Result<DotNetTypeRef[]> compute()
		{
			DotNetTypeRef[] extendTypeRefs = CSharpTypeDeclarationImplUtil.getExtendTypeRefs(CSharpTypeDeclarationImpl.this);
			return Result.create(extendTypeRefs, PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT);
		}
	});
}
 
Example 11
Source Project: consulo-csharp   Source File: CSharpBlockStatementImpl.java    License: Apache License 2.0 6 votes vote down vote up
@Nonnull
private Collection<CSharpElementGroup<CSharpMethodDeclaration>> getLocalMethods()
{
	return CachedValuesManager.getCachedValue(this, () -> {
		MultiMap<String, CSharpMethodDeclaration> multiMap = new MultiMap<>();

		for(DotNetStatement statement : getStatements())
		{
			if(statement instanceof CSharpLocalMethodDeclarationStatementImpl)
			{
				CSharpMethodDeclaration method = ((CSharpLocalMethodDeclarationStatementImpl) statement).getMethod();

				multiMap.putValue(method.getName(), method);
			}
		}

		List<CSharpElementGroup<CSharpMethodDeclaration>> list = multiMap
				.entrySet()
				.stream()
				.map(e -> new CSharpElementGroupImpl<>(getProject(), e.getKey(), e.getValue()))
				.collect(Collectors.toList());

		return CachedValueProvider.Result.create(list, PsiModificationTracker.MODIFICATION_COUNT);
	});
}
 
Example 12
@NotNull
@Override
public Collection<TwigPath> getNamespaces(@NotNull TwigNamespaceExtensionParameter parameter) {
    Project project = parameter.getProject();

    Collection<Pair<String, String>> cachedValue = CachedValuesManager.getManager(project).getCachedValue(
        project,
        CACHE,
        () -> CachedValueProvider.Result.create(getTwigPaths(project), PsiModificationTracker.MODIFICATION_COUNT),
        false
    );

    // TwigPath is not cache able as it right now; we need to build it here
    return cachedValue.stream()
        .map(p -> new TwigPath(p.getFirst(), p.getSecond(), TwigUtil.NamespaceType.ADD_PATH, true))
        .collect(Collectors.toList());
}
 
Example 13
Source Project: idea-php-symfony2-plugin   Source File: SymfonyUtil.java    License: MIT License 6 votes vote down vote up
private static boolean compare(@NotNull Project project, @NotNull String version, @NotNull Comparator comparator) {
    Set<String> cache = CachedValuesManager.getManager(project).getCachedValue(
        project,
        CACHE,
        () -> CachedValueProvider.Result.create(getVersions(project), PsiModificationTracker.MODIFICATION_COUNT),
        false
    );

    for (String s : cache) {
        if(comparator.accepts(s)) {
            return true;
        }
    }

    return false;
}
 
Example 14
Source Project: consulo   Source File: TextEditorHighlightingPass.java    License: Apache License 2.0 6 votes vote down vote up
protected boolean isValid() {
  if (isDumbMode() && !DumbService.isDumbAware(this)) {
    return false;
  }

  if (PsiModificationTracker.SERVICE.getInstance(myProject).getModificationCount() != myInitialPsiStamp) {
    return false;
  }

  if (myDocument != null) {
    if (myDocument.getModificationStamp() != myInitialDocStamp) return false;
    PsiFile file = PsiDocumentManager.getInstance(myProject).getPsiFile(myDocument);
    return file != null && file.isValid();
  }

  return true;
}
 
Example 15
Source Project: consulo   Source File: PsiCachedValue.java    License: Apache License 2.0 6 votes vote down vote up
@Override
protected long getTimeStamp(@Nonnull Object dependency) {
  if (dependency instanceof PsiDirectory) {
    return myManager.getModificationTracker().getOutOfCodeBlockModificationCount();
  }

  if (dependency instanceof PsiElement) {
    PsiElement element = (PsiElement)dependency;
    if (!element.isValid()) return -1;
    PsiFile containingFile = element.getContainingFile();
    if (containingFile != null) return containingFile.getModificationStamp();
  }

  if (dependency == PsiModificationTracker.MODIFICATION_COUNT || dependency == PSI_MOD_COUNT_OPTIMIZATION) {
    return myManager.getModificationTracker().getModificationCount();
  }
  if (dependency == PsiModificationTracker.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT) {
    return myManager.getModificationTracker().getOutOfCodeBlockModificationCount();
  }
  if (dependency == PsiModificationTracker.JAVA_STRUCTURE_MODIFICATION_COUNT) {
    return myManager.getModificationTracker().getJavaStructureModificationCount();
  }

  return super.getTimeStamp(dependency);
}
 
Example 16
Source Project: consulo   Source File: CtrlMouseHandler.java    License: Apache License 2.0 6 votes vote down vote up
private void updateOnPsiChanges(@Nonnull LightweightHint hint, @Nonnull Info info, @Nonnull Consumer<? super String> textConsumer, @Nonnull String oldText, @Nonnull Editor editor) {
  if (!hint.isVisible()) return;
  Disposable hintDisposable = Disposable.newDisposable("CtrlMouseHandler.TooltipProvider.updateOnPsiChanges");
  hint.addHintListener(__ -> Disposer.dispose(hintDisposable));
  myProject.getMessageBus().connect(hintDisposable).subscribe(PsiModificationTracker.TOPIC, () -> ReadAction.nonBlocking(() -> {
    try {
      DocInfo newDocInfo = info.getInfo();
      return (Runnable)() -> {
        if (newDocInfo.text != null && !oldText.equals(newDocInfo.text)) {
          updateText(newDocInfo.text, textConsumer, hint, editor);
        }
      };
    }
    catch (IndexNotReadyException e) {
      showDumbModeNotification(myProject);
      return createDisposalContinuation();
    }
  }).finishOnUiThread(ModalityState.defaultModalityState(), Runnable::run).withDocumentsCommitted(myProject).expireWith(hintDisposable).expireWhen(() -> !info.isValid(editor.getDocument()))
          .coalesceBy(hint).submit(AppExecutorUtil.getAppExecutorService()));
}
 
Example 17
Source Project: IntelliJDeodorant   Source File: AbstractRefactoringPanel.java    License: MIT License 5 votes vote down vote up
/**
 * Adds a listener that invalidates found refactoring opportunities if the structure of PSI is changed.
 */
private void registerPsiModificationListener() {
    if (!isPreviewUsage) {
        MessageBus projectMessageBus = scope.getProject().getMessageBus();
        projectMessageBus.connect().subscribe(PsiModificationTracker.TOPIC, () -> ApplicationManager.getApplication().invokeLater(this::showRefreshingProposal));
    }
}
 
Example 18
Source Project: idea-php-typo3-plugin   Source File: JavaScriptUtil.java    License: MIT License 5 votes vote down vote up
@NotNull
public static Map<String, List<PsiFile>> getModuleMap(@NotNull Project project) {
    return CachedValuesManager.getManager(project).getCachedValue(
        project,
        MODULE_MAP,
        () -> CachedValueProvider.Result.create(doGetModuleMap(project), PsiModificationTracker.MODIFICATION_COUNT),
        false
    );
}
 
Example 19
Source Project: intellij   Source File: GoogleTestLocation.java    License: Apache License 2.0 5 votes vote down vote up
private static boolean unsyncedFileContainsGtestMacroCalls(OCFile file) {
  return CachedValuesManager.getCachedValue(
      file,
      () ->
          CachedValueProvider.Result.create(
              computeUnsyncedFileContainsGtestMacroCalls(file),
              PsiModificationTracker.MODIFICATION_COUNT));
}
 
Example 20
Source Project: idea-php-toolbox   Source File: ExtensionProviderUtil.java    License: MIT License 5 votes vote down vote up
@NotNull
synchronized public static Collection<PhpToolboxProviderInterface> getProviders(final @NotNull Project project) {
    CachedValue<Collection<PhpToolboxProviderInterface>> cache = project.getUserData(PROVIDER_CACHE);

    if(cache == null) {
        cache = CachedValuesManager.getManager(project).createCachedValue(() -> CachedValueProvider.Result.create(getProvidersInner(project), PsiModificationTracker.MODIFICATION_COUNT), false);

        project.putUserData(PROVIDER_CACHE, cache);
    }

    return cache.getValue();
}
 
Example 21
Source Project: idea-php-toolbox   Source File: ExtensionProviderUtil.java    License: MIT License 5 votes vote down vote up
@NotNull
synchronized public static Collection<JsonRegistrar> getRegistrar(final @NotNull Project project, final @NotNull PhpToolboxApplicationService phpToolboxApplicationService) {
    CachedValue<Collection<JsonRegistrar>> cache = project.getUserData(REGISTRAR_CACHE);

    if(cache == null) {
        cache = CachedValuesManager.getManager(project).createCachedValue(() -> CachedValueProvider.Result.create(getRegistrarInner(project, phpToolboxApplicationService), PsiModificationTracker.MODIFICATION_COUNT), false);

        project.putUserData(REGISTRAR_CACHE, cache);
    }

    return cache.getValue();
}
 
Example 22
Source Project: idea-php-toolbox   Source File: ExtensionProviderUtil.java    License: MIT License 5 votes vote down vote up
@NotNull
synchronized public static Collection<JsonRegistrar> getTypes(final @NotNull Project project) {
    CachedValue<Collection<JsonRegistrar>> cache = project.getUserData(TYPE_CACHE);

    if(cache == null) {
        cache = CachedValuesManager.getManager(project).createCachedValue(() -> CachedValueProvider.Result.create(getTypesInner(project), PsiModificationTracker.MODIFICATION_COUNT), false);

        project.putUserData(TYPE_CACHE, cache);
    }

    return cache.getValue();
}
 
Example 23
Source Project: idea-php-toolbox   Source File: ExtensionProviderUtil.java    License: MIT License 5 votes vote down vote up
synchronized public static Collection<JsonConfigFile> getJsonConfigs(final @NotNull Project project, final @NotNull PhpToolboxApplicationService phpToolboxApplicationService) {
    CachedValue<Collection<JsonConfigFile>> cache = project.getUserData(CONFIGS_CACHE);

    if(cache == null) {
        cache = CachedValuesManager.getManager(project).createCachedValue(() -> CachedValueProvider.Result.create(getJsonConfigsInner(project, phpToolboxApplicationService), PsiModificationTracker.MODIFICATION_COUNT), false);
        project.putUserData(CONFIGS_CACHE, cache);
    }

    Collection<JsonConfigFile> jsonConfigFiles = new ArrayList<>(cache.getValue());

    // prevent reindex issues
    if (!DumbService.getInstance(project).isDumb()) {
        CachedValue<Collection<JsonConfigFile>> indexCache = project.getUserData(CONFIGS_CACHE_INDEX);

        if (indexCache == null) {
            indexCache = CachedValuesManager.getManager(project).createCachedValue(() -> {
                Collection<JsonConfigFile> jsonConfigFiles1 = new ArrayList<>();

                for (final PsiFile psiFile : FilenameIndex.getFilesByName(project, ".ide-toolbox.metadata.json", GlobalSearchScope.allScope(project))) {
                    JsonConfigFile cachedValue = CachedValuesManager.getCachedValue(psiFile, () -> new CachedValueProvider.Result<>(
                        JsonParseUtil.getDeserializeConfig(psiFile.getText()),
                        psiFile,
                        psiFile.getVirtualFile()
                    ));

                    if(cachedValue != null) {
                        jsonConfigFiles1.add(cachedValue);
                    }
                }

                return CachedValueProvider.Result.create(jsonConfigFiles1, PsiModificationTracker.MODIFICATION_COUNT);
            }, false);
        }

        project.putUserData(CONFIGS_CACHE_INDEX, indexCache);
        jsonConfigFiles.addAll(indexCache.getValue());
    }

    return jsonConfigFiles;
}
 
Example 24
Source Project: idea-php-shopware-plugin   Source File: ServiceCollector.java    License: MIT License 5 votes vote down vote up
@Nullable
@Override
public Result<Collection<ServiceInterface>> compute() {
    return Result.create(
        ContainerUtil.map(SubscriberIndexUtil.getIndexedBootstrapResources(args.getProject(), BootstrapResource.INIT_RESOURCE), (Function<ServiceResource, ServiceInterface>) resource
            -> new SerializableService(resource.getServiceName()).setClassName(SubscriberIndexUtil.getTypeForResource(args.getProject(), resource)))
        , PsiModificationTracker.MODIFICATION_COUNT
    );
}
 
Example 25
Source Project: idea-php-shopware-plugin   Source File: ServiceCollector.java    License: MIT License 5 votes vote down vote up
@Nullable
@Override
public Result<Collection<String>> compute() {
    return Result.create(
        ContainerUtil.map(SubscriberIndexUtil.getIndexedBootstrapResources(args.getProject()), ServiceResource::getServiceName),
        PsiModificationTracker.MODIFICATION_COUNT
    );
}
 
Example 26
Source Project: railways   Source File: RoutesView.java    License: MIT License 5 votes vote down vote up
public RoutesView(@NotNull Project project) {
    myProject = project;
    mainPanel = new MainPanel(project);
    myConnection = myProject.getMessageBus().connect();

    // Subscribe on files changes to update Route list regularly.
    // We connect to project bus, as module bus don't work with this topic
    MessageBusConnection conn = project.getMessageBus().connect();
    conn.subscribe(PsiModificationTracker.TOPIC, new PSIModificationListener());
}
 
Example 27
Source Project: idea-php-toolbox   Source File: ExtensionProviderUtil.java    License: MIT License 5 votes vote down vote up
@NotNull
synchronized public static Collection<PhpToolboxProviderInterface> getProviders(final @NotNull Project project) {
    CachedValue<Collection<PhpToolboxProviderInterface>> cache = project.getUserData(PROVIDER_CACHE);

    if(cache == null) {
        cache = CachedValuesManager.getManager(project).createCachedValue(() -> CachedValueProvider.Result.create(getProvidersInner(project), PsiModificationTracker.MODIFICATION_COUNT), false);

        project.putUserData(PROVIDER_CACHE, cache);
    }

    return cache.getValue();
}
 
Example 28
Source Project: idea-php-toolbox   Source File: ExtensionProviderUtil.java    License: MIT License 5 votes vote down vote up
@NotNull
synchronized public static Collection<JsonRegistrar> getRegistrar(final @NotNull Project project, final @NotNull PhpToolboxApplicationService phpToolboxApplicationService) {
    CachedValue<Collection<JsonRegistrar>> cache = project.getUserData(REGISTRAR_CACHE);

    if(cache == null) {
        cache = CachedValuesManager.getManager(project).createCachedValue(() -> CachedValueProvider.Result.create(getRegistrarInner(project, phpToolboxApplicationService), PsiModificationTracker.MODIFICATION_COUNT), false);

        project.putUserData(REGISTRAR_CACHE, cache);
    }

    return cache.getValue();
}
 
Example 29
Source Project: idea-php-toolbox   Source File: ExtensionProviderUtil.java    License: MIT License 5 votes vote down vote up
@NotNull
synchronized public static Collection<JsonRegistrar> getTypes(final @NotNull Project project) {
    CachedValue<Collection<JsonRegistrar>> cache = project.getUserData(TYPE_CACHE);

    if(cache == null) {
        cache = CachedValuesManager.getManager(project).createCachedValue(() -> CachedValueProvider.Result.create(getTypesInner(project), PsiModificationTracker.MODIFICATION_COUNT), false);

        project.putUserData(TYPE_CACHE, cache);
    }

    return cache.getValue();
}
 
Example 30
Source Project: idea-php-toolbox   Source File: ExtensionProviderUtil.java    License: MIT License 5 votes vote down vote up
synchronized public static Collection<JsonConfigFile> getJsonConfigs(final @NotNull Project project, final @NotNull PhpToolboxApplicationService phpToolboxApplicationService) {
    CachedValue<Collection<JsonConfigFile>> cache = project.getUserData(CONFIGS_CACHE);

    if(cache == null) {
        cache = CachedValuesManager.getManager(project).createCachedValue(() -> CachedValueProvider.Result.create(getJsonConfigsInner(project, phpToolboxApplicationService), PsiModificationTracker.MODIFICATION_COUNT), false);
        project.putUserData(CONFIGS_CACHE, cache);
    }

    Collection<JsonConfigFile> jsonConfigFiles = new ArrayList<>(cache.getValue());

    // prevent reindex issues
    if (!DumbService.getInstance(project).isDumb()) {
        CachedValue<Collection<JsonConfigFile>> indexCache = project.getUserData(CONFIGS_CACHE_INDEX);

        if (indexCache == null) {
            indexCache = CachedValuesManager.getManager(project).createCachedValue(() -> {
                Collection<JsonConfigFile> jsonConfigFiles1 = new ArrayList<>();

                for (final PsiFile psiFile : FilenameIndex.getFilesByName(project, ".ide-toolbox.metadata.json", GlobalSearchScope.allScope(project))) {
                    JsonConfigFile cachedValue = CachedValuesManager.getCachedValue(psiFile, () -> new CachedValueProvider.Result<>(
                        JsonParseUtil.getDeserializeConfig(psiFile.getText()),
                        psiFile,
                        psiFile.getVirtualFile()
                    ));

                    if(cachedValue != null) {
                        jsonConfigFiles1.add(cachedValue);
                    }
                }

                return CachedValueProvider.Result.create(jsonConfigFiles1, PsiModificationTracker.MODIFICATION_COUNT);
            }, false);
        }

        project.putUserData(CONFIGS_CACHE_INDEX, indexCache);
        jsonConfigFiles.addAll(indexCache.getValue());
    }

    return jsonConfigFiles;
}