boolean (PsiReference ref) { synchronized (IS_BEING_RESOLVED_KEY) { PsiElement elt = ref.getElement(); List<Thread> lockingThreads = elt.getUserData(IS_BEING_RESOLVED_KEY); final Thread currentThread = Thread.currentThread(); if (lockingThreads == null) { lockingThreads = new ArrayList<Thread>(1); elt.putUserData(IS_BEING_RESOLVED_KEY, lockingThreads); } else { if (lockingThreads.contains(currentThread)) return false; } lockingThreads.add(currentThread); } return true; }