ResourceBundleWithCachedFiles (@NotNull final PropertiesFile representative) { return ReadAction.compute(() -> { final PsiFile containingFile = representative.getContainingFile(); if (!containingFile.isValid()) { return ResourceBundleWithCachedFiles.EMPTY; } final ResourceBundleManager manager = ResourceBundleManager.getInstance(representative.getProject()); final CustomResourceBundle customResourceBundle = manager.getCustomResourceBundle(representative); if (customResourceBundle != null) { return new ResourceBundleWithCachedFiles(customResourceBundle, customResourceBundle.getPropertiesFiles()); } final VirtualFile virtualFile = representative.getVirtualFile(); if (virtualFile == null) { return ResourceBundleWithCachedFiles.EMPTY; } if (manager.isDefaultDissociated(virtualFile)) { return new ResourceBundleWithCachedFiles(new ResourceBundleImpl(representative), Collections.singletonList(representative)); } final String baseName = manager.getBaseName(containingFile); final String extension = containingFile.getVirtualFile().getExtension(); final PsiDirectory directory = containingFile.getContainingDirectory(); if (directory == null) return ResourceBundleWithCachedFiles.EMPTY; final ResourceBundleWithCachedFiles bundle = getResourceBundle(baseName, extension, directory); return bundle == null ? new ResourceBundleWithCachedFiles(new ResourceBundleImpl(representative), Collections.singletonList(representative)) : bundle; }); }