AccessToken (@NotNull Object target) { if (!EDT.isCurrentThreadEdt()) { return AccessToken.EMPTY_ACCESS_TOKEN; } String prev = ourTargetClass; ourTargetClass = target.getClass().getName(); return new AccessToken() { @Override public void finish() { //noinspection AssignmentToStaticFieldFromInstanceMethod ourTargetClass = prev; } }; }