private void updateStubIndices(@Nullable SerializedStubTree newTree) {
    try {
      Map<StubIndexKey<?, ?>, Map<Object, StubIdList>> oldForwardIndex =
        myCurrentTree == null ? Collections.emptyMap() : myCurrentTree.getStubIndicesValueMap();

      Map<StubIndexKey<?, ?>, Map<Object, StubIdList>> newForwardIndex =
        newTree == null ? Collections.emptyMap() : newTree.getStubIndicesValueMap();

      Collection<StubIndexKey<?, ?>> affectedIndexes =
        ContainerUtil.union(oldForwardIndex.keySet(), newForwardIndex.keySet());

      StubIndexEx stubIndex = (StubIndexEx)StubIndex.getInstance();
      if (FileBasedIndexEx.TRACE_STUB_INDEX_UPDATES) {
        stubIndex.getLogger()
          .info("stub indexes " + (newTree == null ? "deletion" : "update") + ": file = " + myInputId + " indexes " + affectedIndexes);
      }

      //noinspection rawtypes
      for (StubIndexKey key : affectedIndexes) {
        // StubIdList-s are ignored.
        Set<Object> oldKeys = oldForwardIndex.getOrDefault(key, Collections.emptyMap()).keySet();
        Set<Object> newKeys = newForwardIndex.getOrDefault(key, Collections.emptyMap()).keySet();

        //noinspection unchecked
        stubIndex.updateIndex(key, myInputId, oldKeys, newKeys);
      }
    } catch (ProcessCanceledException e) {
      LOG.error("ProcessCanceledException is not expected here", e);
      throw e;
    }
  }
private void updateStubIndices(@Nullable SerializedStubTree newTree)