diff --git a/platform/core-api/src/com/intellij/psi/util/ProfilingInfo.java b/platform/core-api/src/com/intellij/psi/util/ProfilingInfo.java index df264ca2e9eb..c61b01139800 100644 --- a/platform/core-api/src/com/intellij/psi/util/ProfilingInfo.java +++ b/platform/core-api/src/com/intellij/psi/util/ProfilingInfo.java @@ -17,8 +17,10 @@ public class ProfilingInfo { myOrigin = origin; } - public void valueDisposed() { - myDisposedTimeStamp = currentTime(); + public synchronized void valueDisposed() { + if (myDisposedTimeStamp != 0) { + myDisposedTimeStamp = currentTime(); + } } public void valueUsed() { diff --git a/platform/core-impl/src/com/intellij/util/CachedValueBase.java b/platform/core-impl/src/com/intellij/util/CachedValueBase.java index 71e839490527..d59e93e931df 100644 --- a/platform/core-impl/src/com/intellij/util/CachedValueBase.java +++ b/platform/core-impl/src/com/intellij/util/CachedValueBase.java @@ -1,11 +1,13 @@ // Copyright 2000-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.util; -import com.intellij.openapi.Disposable; import com.intellij.openapi.diagnostic.Logger; import com.intellij.openapi.editor.Document; import com.intellij.openapi.project.Project; -import com.intellij.openapi.util.*; +import com.intellij.openapi.util.ModificationTracker; +import com.intellij.openapi.util.RecursionGuard; +import com.intellij.openapi.util.RecursionManager; +import com.intellij.openapi.util.Ref; import com.intellij.psi.util.CachedValueProfiler; import com.intellij.psi.util.CachedValueProvider; import com.intellij.psi.util.ProfilingInfo; @@ -99,20 +101,17 @@ public abstract class CachedValueBase { } public boolean hasUpToDateValue() { - return getUpToDateOrNull(false) != null; + return getUpToDateOrNull() != null; } @Nullable - final Data getUpToDateOrNull(boolean dispose) { + final Data getUpToDateOrNull() { Data data = getRawData(); if (data != null) { if (isUpToDate(data)) { return data; } - if (dispose && data.myValue instanceof Disposable && compareAndClearData(data)) { - Disposer.dispose((Disposable)data.myValue); - } if (data instanceof ProfilingData) { ((ProfilingData)data).myProfilingInfo.valueDisposed(); } @@ -196,7 +195,7 @@ public abstract class CachedValueBase { public abstract boolean isFromMyProject(Project project); - protected static class Data implements Disposable { + protected static class Data { private final T myValue; private final Object[] myDependencies; private final long[] myTimeStamps; @@ -207,13 +206,6 @@ public abstract class CachedValueBase { myTimeStamps = timeStamps; } - @Override - public void dispose() { - if (myValue instanceof Disposable) { - Disposer.dispose((Disposable)myValue); - } - } - public T getValue() { return myValue; } @@ -239,7 +231,7 @@ public abstract class CachedValueBase { @Nullable protected

T getValueWithLock(P param) { - Data data = getUpToDateOrNull(true); + Data data = getUpToDateOrNull(); if (data != null) { return data.getValue(); } diff --git a/platform/core-impl/src/com/intellij/util/CachedValuesManagerImpl.java b/platform/core-impl/src/com/intellij/util/CachedValuesManagerImpl.java index ae9c524a1a7a..a8abe1bc1468 100644 --- a/platform/core-impl/src/com/intellij/util/CachedValuesManagerImpl.java +++ b/platform/core-impl/src/com/intellij/util/CachedValuesManagerImpl.java @@ -52,7 +52,7 @@ public class CachedValuesManagerImpl extends CachedValuesManager { CachedValue value = dataHolder.getUserData(key); if (value instanceof CachedValueBase && ((CachedValueBase)value).isFromMyProject(myProject)) { //noinspection unchecked - CachedValueBase.Data data = ((CachedValueBase)value).getUpToDateOrNull(false); + CachedValueBase.Data data = ((CachedValueBase)value).getUpToDateOrNull(); if (data != null) { return data.getValue(); }