Search in sources :

Example 6 with RefManagerExtension

use of com.intellij.codeInspection.lang.RefManagerExtension in project intellij-community by JetBrains.

the class RefManagerImpl method removeReference.

void removeReference(@NotNull RefElement refElem) {
    final PsiElement element = refElem.getElement();
    final RefManagerExtension extension = element != null ? getExtension(element.getLanguage()) : null;
    if (extension != null) {
        extension.removeReference(refElem);
    }
    synchronized (myRefTableLock) {
        mySortedRefs = null;
        if (element != null && (usePsiAsKey() ? myPsiToRefTable.remove(element) : myRefTable.remove(createAnchor(element))) != null)
            return;
        //PsiElement may have been invalidated and new one returned by getElement() is different so we need to do this stuff.
        if (usePsiAsKey()) {
            for (Map.Entry<PsiElement, RefElement> entry : myPsiToRefTable.entrySet()) {
                RefElement value = entry.getValue();
                PsiElement anchor = entry.getKey();
                if (value == refElem) {
                    myPsiToRefTable.remove(anchor);
                    break;
                }
            }
        } else {
            for (Map.Entry<PsiAnchor, RefElement> entry : myRefTable.entrySet()) {
                RefElement value = entry.getValue();
                PsiAnchor anchor = entry.getKey();
                if (value == refElem) {
                    myRefTable.remove(anchor);
                    break;
                }
            }
        }
    }
}
Also used : RefManagerExtension(com.intellij.codeInspection.lang.RefManagerExtension) THashMap(gnu.trove.THashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

Aggregations

RefManagerExtension (com.intellij.codeInspection.lang.RefManagerExtension)6 VirtualFile (com.intellij.openapi.vfs.VirtualFile)2 Nullable (org.jetbrains.annotations.Nullable)2 Document (com.intellij.openapi.editor.Document)1 Segment (com.intellij.openapi.util.Segment)1 LightElement (com.intellij.psi.impl.light.LightElement)1 THashMap (gnu.trove.THashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 Element (org.jdom.Element)1