void (@NotNull SmartPsiElementPointer<?> pointer) { if (!(pointer instanceof SmartPsiElementPointerImpl) || myProject.isDisposed()) { return; } ensureMyProject(pointer.getProject()); int refCount = ((SmartPsiElementPointerImpl<?>)pointer).incrementAndGetReferenceCount(-1); if (refCount == -1) { LOG.error("Double smart pointer removal"); return; } if (refCount == 0) { PsiElement element = ((SmartPointerEx<?>)pointer).getCachedElement(); if (element != null) { element.putUserData(CACHED_SMART_POINTER_KEY, null); } SmartPointerElementInfo info = ((SmartPsiElementPointerImpl<?>)pointer).getElementInfo(); info.cleanup(); SmartPointerTracker.PointerReference reference = ((SmartPsiElementPointerImpl<?>)pointer).pointerReference; if (reference != null) { if (reference.get() != pointer) { throw new IllegalStateException("Reference points to " + reference.get()); } reference.tracker.removeReference(reference); } } }