com.intellij.psi.util.CachedValuesManager Java Examples

The following examples show how to use com.intellij.psi.util.CachedValuesManager. 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 File: GlobalNamespaceLoader.java    From idea-php-drupal-symfony2-bridge with MIT License 6 votes vote down vote up
@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 #2
Source File: TranslationUtil.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
@NotNull
private synchronized static Collection<String> getAllKeys(@NotNull Project project) {
    CachedValue<Collection<String>> cachedValue = project.getUserData(TRANSLATION_KEYS);
    if (cachedValue != null && cachedValue.hasUpToDateValue()) {
        return TRANSLATION_KEYS_LOCAL_CACHE.getOrDefault(project, new ArrayList<>());
    }

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

        return CachedValueProvider.Result.create(new ArrayList<>(), MODIFICATION_COUNT);
    }, false);

    project.putUserData(TRANSLATION_KEYS, cachedValue);

    return TRANSLATION_KEYS_LOCAL_CACHE.getOrDefault(project, cachedValue.getValue());
}
 
Example #3
Source File: ResourcePathIndex.java    From idea-php-typo3-plugin with 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 #4
Source File: HtmlNSNamespaceProvider.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
private synchronized Collection<FluidNamespace> doProvide(@NotNull PsiElement element) {
    FileViewProvider viewProvider = element.getContainingFile().getViewProvider();
    if (!viewProvider.getLanguages().contains(HTMLLanguage.INSTANCE)) {
        return ContainerUtil.emptyList();
    }

    PsiFile htmlFile = viewProvider.getPsi(HTMLLanguage.INSTANCE);
    CachedValue userData = htmlFile.getUserData(HTML_NS_KEY);
    if (userData != null) {
        return (Collection<FluidNamespace>) userData.getValue();
    }

    CachedValue<Collection<FluidNamespace>> cachedValue = CachedValuesManager.getManager(element.getProject()).createCachedValue(() -> {
        HtmlNSVisitor visitor = new HtmlNSVisitor();
        htmlFile.accept(visitor);

        return CachedValueProvider.Result.createSingleDependency(visitor.namespaces, htmlFile);
    }, false);

    htmlFile.putUserData(HTML_NS_KEY, cachedValue);

    return cachedValue.getValue();
}
 
Example #5
Source File: FileIndexCaches.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * @param dataHolderKey Main data to cache
 * @param dataHolderNames Cache extracted name Set
 */
static public synchronized Map<String, List<String>> getStringDataCache(@NotNull final Project project, @NotNull Key<CachedValue<Map<String, List<String>>>> dataHolderKey, final @NotNull Key<CachedValue<Set<String>>> dataHolderNames, @NotNull final ID<String, String> ID, @NotNull final GlobalSearchScope scope) {
    return CachedValuesManager.getManager(project).getCachedValue(
        project,
        dataHolderKey,
        () -> {
            Map<String, List<String>> strings = new HashMap<>();

            final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();
            getIndexKeysCache(project, dataHolderNames, ID).forEach(parameterName -> {
                // just for secure
                if(parameterName == null) {
                    return;
                }

                strings.put(parameterName, fileBasedIndex.getValues(ID, parameterName, scope));
            });

            return CachedValueProvider.Result.create(strings, getModificationTrackerForIndexId(project, ID));
        },
        false
    );
}
 
Example #6
Source File: FileIndexCaches.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * @param dataHolderKey Main data to cache
 * @param dataHolderNames Cache extracted name Set
 */
static public synchronized <T> Map<String, List<T>> getSetDataCache(@NotNull final Project project, @NotNull Key<CachedValue<Map<String, List<T>>>> dataHolderKey, final @NotNull Key<CachedValue<Set<String>>> dataHolderNames, @NotNull final ID<String, T> ID, @NotNull final GlobalSearchScope scope) {
    return CachedValuesManager.getManager(project).getCachedValue(
        project,
        dataHolderKey,
        () -> {
            Map<String, List<T>> items = new HashMap<>();

            final FileBasedIndex fileBasedIndex = FileBasedIndex.getInstance();

            getIndexKeysCache(project, dataHolderNames, ID).forEach(service ->
                items.put(service, fileBasedIndex.getValues(ID, service, scope))
            );

            return CachedValueProvider.Result.create(items, getModificationTrackerForIndexId(project, ID));
        },
        false
    );
}
 
Example #7
Source File: VirtualFileTestContextProvider.java    From intellij with 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 #8
Source File: TestContextRunConfigurationProducer.java    From intellij with Apache License 2.0 6 votes vote down vote up
@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 #9
Source File: BinaryContextRunConfigurationProducer.java    From intellij with Apache License 2.0 6 votes vote down vote up
@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 #10
Source File: BlazeSourceJarNavigationPolicy.java    From intellij with Apache License 2.0 6 votes vote down vote up
@Nullable
@Override
public PsiFile getFileNavigationElement(ClsFileImpl file) {
  if (!enabled.getValue()) {
    return null;
  }
  return CachedValuesManager.getCachedValue(
      file,
      () -> {
        Result<PsiFile> result = getPsiFile(file);
        if (result == null) {
          result = notFound(file);
        }
        return result;
      });
}
 
Example #11
Source File: ProducerUtils.java    From intellij with 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 #12
Source File: ConfigAddPathTwigNamespaces.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@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 File: CSharpTypeDeclarationImpl.java    From consulo-csharp with 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 #14
Source File: PsiPackageSupportProviders.java    From consulo with Apache License 2.0 6 votes vote down vote up
@RequiredReadAction
public static boolean isPackageSupported(@Nonnull Project project) {
  return CachedValuesManager.getManager(project).getCachedValue(project, () -> {
    boolean result = false;
    PsiPackageSupportProvider[] extensions = PsiPackageSupportProvider.EP_NAME.getExtensions();
    ModuleManager moduleManager = ModuleManager.getInstance(project);
    loop:
    for (Module module : moduleManager.getModules()) {
      ModuleRootManager rootManager = ModuleRootManager.getInstance(module);
      for (ModuleExtension moduleExtension : rootManager.getExtensions()) {
        for (PsiPackageSupportProvider extension : extensions) {
          if (extension.isSupported(moduleExtension)) {
            result = true;
            break loop;
          }
        }
      }
    }
    return CachedValueProvider.Result.create(result, ProjectRootManager.getInstance(project));
  });
}
 
Example #15
Source File: CSharpModifierListImplUtil.java    From consulo-csharp with 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 #16
Source File: HaxeHierarchyUtils.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
/**
 * Retrieve the list of classes implemented in the given File.
 *
 * @param psiRoot - File to search.
 * @return A List of found classes, or an empty array if none.
 */
@NotNull
public static List<HaxeClass> getClassList(@NotNull HaxeFile psiRoot) {
  CachedValuesManager manager = CachedValuesManager.getManager(psiRoot.getProject());
  ArrayList<HaxeClass> classList = manager.getCachedValue(psiRoot, () -> {
    ArrayList<HaxeClass> classes = new ArrayList<>();
    for (PsiElement child : psiRoot.getChildren()) {
      if (child instanceof HaxeClass) {
        classes.add((HaxeClass)child);
      }
    }
    return new CachedValueProvider.Result<>(classes, psiRoot);
  });

  return classList;
}
 
Example #17
Source File: SubscriberIndexUtil.java    From idea-php-shopware-plugin with 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 #18
Source File: Unity3dManifest.java    From consulo-unity3d with 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 #19
Source File: TemplateAnnotationTypeProvider.java    From idea-php-generics-plugin with MIT License 6 votes vote down vote up
@NotNull
private static Map<String, Collection<TemplateAnnotationUsage>> getTemplateAnnotationUsagesMap(@NotNull Project project) {
    return CachedValuesManager.getManager(project).getCachedValue(project, PHP_GENERICS_TEMPLATES, () -> {
        Map<String, Collection<TemplateAnnotationUsage>> map = new HashMap<>();

        FileBasedIndex instance = FileBasedIndex.getInstance();
        GlobalSearchScope scope = PhpIndex.getInstance(project).getSearchScope();

        instance.processAllKeys(TemplateAnnotationIndex.KEY, (key) -> {
            map.putIfAbsent(key, new HashSet<>());
            map.get(key).addAll(instance.getValues(TemplateAnnotationIndex.KEY, key, scope));
            return true;
        }, project);

        return CachedValueProvider.Result.create(map, getModificationTracker(project));
    }, false);
}
 
Example #20
Source File: ViewCollector.java    From Thinkphp5-Plugin with MIT License 5 votes vote down vote up
private static void collectIdeJsonBladePaths(@NotNull Project project, @NotNull Collection<TemplatePath> templatePaths) {
    for (PsiFile psiFile : FilenameIndex.getFilesByName(project, "ide-blade.json", GlobalSearchScope.allScope(project))) {
        Collection<TemplatePath> cachedValue = CachedValuesManager.getCachedValue(psiFile, new MyJsonCachedValueProvider(psiFile));
        if (cachedValue != null) {
            templatePaths.addAll(cachedValue);
        }
    }
}
 
Example #21
Source File: FileIncludeManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private VirtualFile[] getFiles(@Nonnull VirtualFile file, boolean compileTimeOnly) {
  PsiFile psiFile = myPsiManager.findFile(file);
  if (psiFile == null) {
    return VirtualFile.EMPTY_ARRAY;
  }
  if (compileTimeOnly) {
    return CachedValuesManager.getManager(myProject).getParameterizedCachedValue(psiFile, COMPILE_TIME_KEY, COMPILE_TIME_PROVIDER, false, psiFile);
  }
  return CachedValuesManager.getManager(myProject).getParameterizedCachedValue(psiFile, RUNTIME_KEY, RUNTIME_PROVIDER, false, psiFile);
}
 
Example #22
Source File: CSharpLambdaExpressionImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Nonnull
@Override
public DotNetModifierList getModifierList()
{
	return CachedValuesManager.getManager(getProject()).createCachedValue(() -> CachedValueProvider.Result.<DotNetModifierList>create(new CSharpAnonymousModifierListImpl
			(CSharpLambdaExpressionImpl.this), CSharpLambdaExpressionImpl.this), false).getValue();
}
 
Example #23
Source File: CSharpCompositeTypeDeclaration.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Nullable
public static CSharpCompositeTypeDeclaration findCompositeType(@Nonnull CSharpTypeDeclaration parent)
{
	Object cachedValue = CachedValuesManager.getCachedValue(parent, () -> CachedValueProvider.Result.create(findCompositeTypeImpl(parent), PsiModificationTracker
			.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT));
	return cachedValue == ObjectUtil.NULL ? null : (CSharpCompositeTypeDeclaration) cachedValue;
}
 
Example #24
Source File: CSharpGenericParameterImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@RequiredReadAction
@Nonnull
@Override
public DotNetTypeRef[] getExtendTypeRefs()
{
	return CachedValuesManager.getCachedValue(this, () -> CachedValueProvider.Result.create(CSharpGenericConstraintUtil.getExtendTypes(CSharpGenericParameterImpl.this), PsiModificationTracker
			.OUT_OF_CODE_BLOCK_MODIFICATION_COUNT));
}
 
Example #25
Source File: TemplateManagerImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static OffsetsInFile insertDummyIdentifierWithCache(PsiFile file, int startOffset, int endOffset, String replacement) {
  ProperTextRange editRange = ProperTextRange.create(startOffset, endOffset);
  assertRangeWithinDocument(editRange, file.getViewProvider().getDocument());

  ConcurrentMap<Pair<ProperTextRange, String>, OffsetsInFile> map = CachedValuesManager.getCachedValue(file, () -> CachedValueProvider.Result
          .create(ConcurrentFactoryMap.createMap(key -> copyWithDummyIdentifier(new OffsetsInFile(file), key.first.getStartOffset(), key.first.getEndOffset(), key.second)), file,
                  file.getViewProvider().getDocument()));
  return map.get(Pair.create(editRange, replacement));
}
 
Example #26
Source File: CSharpFileImpl.java    From consulo-csharp with Apache License 2.0 5 votes vote down vote up
@Override
@Nonnull
@RequiredReadAction
public CSharpUsingListChild[] getUsingStatements()
{
	return CachedValuesManager.getCachedValue(this, () -> CachedValueProvider.Result.create(getUsingStatementsInner(), PsiModificationTracker.MODIFICATION_COUNT)) ;
}
 
Example #27
Source File: XQueryFile.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@NotNull
public Collection<XQueryModuleImport> getModuleImports() {
    if (moduleImports == null) {
        moduleImports = CachedValuesManager
                .getManager(getProject())
                .createCachedValue(new CachedValueProvider<Collection<XQueryModuleImport>>() {
                    @Override
                    public Result<Collection<XQueryModuleImport>> compute() {
                        return CachedValueProvider.Result.create(calcModuleImports(), XQueryFile.this);
                    }
                }, false);
    }
    return moduleImports.getValue();
}
 
Example #28
Source File: XQueryFile.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@NotNull
public Collection<XQueryNamespaceDecl> getNamespaceDeclarations() {
    if (namespaceDeclarations == null) {
        namespaceDeclarations = CachedValuesManager
                .getManager(getProject())
                .createCachedValue(new CachedValueProvider<Collection<XQueryNamespaceDecl>>() {
                    @Override
                    public Result<Collection<XQueryNamespaceDecl>> compute() {
                        return CachedValueProvider.Result.create(calcNamespaceDeclarations(), XQueryFile.this);
                    }
                }, false);
    }
    return namespaceDeclarations.getValue();
}
 
Example #29
Source File: XQueryFile.java    From intellij-xquery with Apache License 2.0 5 votes vote down vote up
@NotNull
public Collection<XQueryFunctionDecl> getFunctionDeclarations() {
    if (functionDeclarations == null) {
        functionDeclarations = CachedValuesManager
                .getManager(getProject())
                .createCachedValue(new CachedValueProvider<Collection<XQueryFunctionDecl>>() {
                    @Override
                    public Result<Collection<XQueryFunctionDecl>> compute() {
                        return CachedValueProvider.Result.create(calcFunctionDeclarations(), XQueryFile.this);
                    }
                }, false);
    }
    return functionDeclarations.getValue();
}
 
Example #30
Source File: CompilerEncodingServiceImpl.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Inject
public CompilerEncodingServiceImpl(@Nonnull Project project) {
  myProject = project;
  myModuleFileEncodings = CachedValuesManager.getManager(project).createCachedValue(new CachedValueProvider<Map<Module, Set<Charset>>>() {
    @Override
    public Result<Map<Module, Set<Charset>>> compute() {
      Map<Module, Set<Charset>> result = computeModuleCharsetMap();
      return Result.create(result, ProjectRootManager.getInstance(myProject),
                           ((EncodingProjectManagerImpl)EncodingProjectManager.getInstance(myProject)).getModificationTracker());
    }
  }, false);
}