Commit ba519fd3 authored by peter's avatar peter Committed by Peter Gromov
Browse files

IDEA-CR-43505: CachedValuesManager: don't trackValue by default

those few who want that can add it as explicit dependency, the others shouldn't be forced to write "false"

(cherry picked from commit 1c818c71)
parent 3c241641
Showing with 8 additions and 5 deletions
+8 -5
......@@ -58,12 +58,11 @@ public abstract class CachedValuesManager {
public abstract <T,P> ParameterizedCachedValue<T,P> createParameterizedCachedValue(@NotNull ParameterizedCachedValueProvider<T,P> provider, boolean trackValue);
/**
* Rarely needed because it tracks the return value as a dependency.
* @return a CachedValue like in {@link #createCachedValue(CachedValueProvider, boolean)}, with trackable return value.
* Creates a new CachedValue instance with the given provider.
*/
@NotNull
public <T> CachedValue<T> createCachedValue(@NotNull CachedValueProvider<T> provider) {
return createCachedValue(provider, true);
return createCachedValue(provider, false);
}
public <T, P> T getParameterizedCachedValue(@NotNull UserDataHolder dataHolder,
......
......@@ -128,6 +128,7 @@ public class XmlEntityRefImpl extends XmlElementImpl implements XmlEntityRef {
final String declName = entityDecl.getName();
if (StringUtil.equals(declName, entityName)) {
result[0] = entityDecl;
deps.add(entityDecl.getContainingFile());
return false;
}
}
......
......@@ -29,6 +29,7 @@ import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiTreeUtil;
import com.intellij.psi.xml.*;
import com.intellij.util.ArrayUtil;
import com.intellij.util.IncorrectOperationException;
import com.intellij.util.SmartList;
import com.intellij.util.containers.ContainerUtil;
......@@ -66,8 +67,10 @@ public class XmlElementDescriptorImpl extends BaseXmlElementDescriptorImpl imple
private static final UserDataCache<CachedValue<XmlAttlistDecl[]>,XmlElement, Object> myAttlistDeclCache = new UserDataCache<CachedValue<XmlAttlistDecl[]>,XmlElement, Object>() {
@Override
protected final CachedValue<XmlAttlistDecl[]> compute(final XmlElement owner, Object o) {
return CachedValuesManager.getManager(owner.getProject()).createCachedValue(
() -> new CachedValueProvider.Result<>(doCollectAttlistDeclarations(owner), owner));
return CachedValuesManager.getManager(owner.getProject()).createCachedValue(() -> {
XmlAttlistDecl[] decls = doCollectAttlistDeclarations(owner);
return new CachedValueProvider.Result<>(decls, (Object[])ArrayUtil.append(decls, owner, XmlElement.class));
});
}
};
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment