From 084c0a3e94a185e9966ae84317f2b774c0cf531b Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Thu, 23 Oct 2014 14:10:17 +0400 Subject: [PATCH] resource bundle manager reduced count of getUrl() call while listening psi changes --- .../properties/ResourceBundleManager.java | 33 ++++++++++++++----- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/ResourceBundleManager.java b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/ResourceBundleManager.java index 2dba8899afe7..9e2e8e477d64 100644 --- a/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/ResourceBundleManager.java +++ b/plugins/properties/properties-psi-impl/src/com/intellij/lang/properties/ResourceBundleManager.java @@ -20,7 +20,9 @@ import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.*; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.NotNullLazyValue; import com.intellij.openapi.util.NullableComputable; +import com.intellij.openapi.util.Pair; import com.intellij.openapi.util.text.StringUtil; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.psi.*; @@ -65,18 +67,31 @@ public class ResourceBundleManager implements PersistentStateComponent> oldAndNewUrls = new NotNullLazyValue>() { + @NotNull + @Override + protected Pair compute() { + final String newUrl = propertiesFile.getVirtualFile().getUrl(); + return Pair.create(oldParentUrl + newUrl.substring(newParentUrl.length()), newUrl); + } + }; + + if (!myState.getDissociatedFiles().isEmpty()) { + if (myState.getDissociatedFiles().remove(oldAndNewUrls.getValue().getFirst())) { + myState.getDissociatedFiles().add(oldAndNewUrls.getValue().getSecond()); } } + + if (!myState.getCustomResourceBundles().isEmpty()) { + for (CustomResourceBundleState customResourceBundleState : myState.getCustomResourceBundles()) { + if (customResourceBundleState.getFileUrls().remove(oldAndNewUrls.getValue().getFirst())) { + customResourceBundleState.getFileUrls().add(oldAndNewUrls.getValue().getSecond()); + break; + } + } + } + } @Nullable