diff --git a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerEx.java b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerEx.java index 986885478be9..455faa596ecf 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerEx.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerEx.java @@ -18,7 +18,6 @@ package com.intellij.psi.impl.smartPointers; import com.intellij.openapi.editor.RangeMarker; import com.intellij.psi.PsiElement; import com.intellij.psi.SmartPsiElementPointer; -import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; public interface SmartPointerEx extends SmartPsiElementPointer { @@ -27,6 +26,5 @@ public interface SmartPointerEx extends SmartPsiElementPoi void unfastenBelt(int offset); - @NotNull - SmartPointerElementInfo getElementInfo(); + PsiElement getCachedElement(); } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java index ac21ec12ebcc..e3e6af37658d 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPointerManagerImpl.java @@ -179,9 +179,11 @@ public class SmartPointerManagerImpl extends SmartPointerManager { private static SmartPsiElementPointer getCachedPointer(@NotNull E element) { Reference data = element.getUserData(CACHED_SMART_POINTER_KEY); SmartPsiElementPointer cachedPointer = data == null ? null : data.get(); - if (cachedPointer instanceof SmartPointerEx - && ((SmartPointerEx)cachedPointer).getElementInfo().restoreElement() != element) { - return null; + if (cachedPointer instanceof SmartPointerEx) { + PsiElement cachedElement = ((SmartPointerEx)cachedPointer).getCachedElement(); + if (cachedElement != null && cachedElement != element) { + return null; + } } return cachedPointer; } diff --git a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java index e468667881a3..dde40cb8887b 100644 --- a/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/impl/smartPointers/SmartPsiElementPointerImpl.java @@ -106,7 +106,7 @@ class SmartPsiElementPointerImpl implements SmartPointerEx myElement = element == null ? null : new SoftReference(element); } - private E getCachedElement() { + public E getCachedElement() { Reference ref = myElement; return ref == null ? null : ref.get(); } @@ -203,7 +203,6 @@ class SmartPsiElementPointerImpl implements SmartPointerEx myElementInfo.fastenBelt(offset, cachedRangeMarker); } - @Override @NotNull public SmartPointerElementInfo getElementInfo() { return myElementInfo;