stubs: log PCE-s on index update
authorDmitry Batkovich <dmitry.batkovich@jetbrains.com>
Wed, 12 Aug 2020 06:54:46 +0000 (09:54 +0300)
committerintellij-monorepo-bot <intellij-monorepo-bot-no-reply@jetbrains.com>
Wed, 12 Aug 2020 07:02:58 +0000 (07:02 +0000)
GitOrigin-RevId: 2d1803c45cba55e231e5f4c5c6f35d82cb4090af

platform/lang-impl/src/com/intellij/psi/stubs/StubCumulativeInputDiffBuilder.java
platform/lang-impl/src/com/intellij/psi/stubs/StubIndexImpl.java
platform/lang-impl/src/com/intellij/psi/stubs/StubUpdatingIndex.java

index 9deea465db77b77e399f85d1c79511661661142f..dfbb3e4c49a4d098948854495adad75e451779d5 100644 (file)
@@ -2,6 +2,7 @@
 package com.intellij.psi.stubs;
 
 import com.intellij.openapi.diagnostic.Logger;
+import com.intellij.openapi.progress.ProcessCanceledException;
 import com.intellij.psi.impl.DebugUtil;
 import com.intellij.util.containers.ContainerUtil;
 import com.intellij.util.indexing.FileBasedIndexImpl;
@@ -72,28 +73,34 @@ class StubCumulativeInputDiffBuilder extends DirectInputDataDiffBuilder<Integer,
   }
 
   private void updateStubIndices(@Nullable SerializedStubTree newTree) {
-    Map<StubIndexKey<?, ?>, Map<Object, StubIdList>> oldForwardIndex =
-      myCurrentTree == null ? Collections.emptyMap() : myCurrentTree.getStubIndicesValueMap();
+    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();
+      Map<StubIndexKey<?, ?>, Map<Object, StubIdList>> newForwardIndex =
+        newTree == null ? Collections.emptyMap() : newTree.getStubIndicesValueMap();
 
-    Collection<StubIndexKey<?, ?>> affectedIndexes =
-      ContainerUtil.union(oldForwardIndex.keySet(), newForwardIndex.keySet());
+      Collection<StubIndexKey<?, ?>> affectedIndexes =
+        ContainerUtil.union(oldForwardIndex.keySet(), newForwardIndex.keySet());
 
-    if (FileBasedIndexImpl.DO_TRACE_STUB_INDEX_UPDATE) {
-      StubIndexImpl.LOG.info("stub indexes" + (newTree == null ? "deletion" : "update") + ": file = " + myInputId + " indexes " + affectedIndexes);
-    }
+      if (FileBasedIndexImpl.DO_TRACE_STUB_INDEX_UPDATE) {
+        StubIndexImpl.LOG
+          .info("stub indexes" + (newTree == null ? "deletion" : "update") + ": file = " + myInputId + " indexes " + affectedIndexes);
+      }
 
-    StubIndexImpl stubIndex = (StubIndexImpl)StubIndex.getInstance();
-    //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();
+      StubIndexImpl stubIndex = (StubIndexImpl)StubIndex.getInstance();
+      //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);
+        //noinspection unchecked
+        stubIndex.updateIndex(key, myInputId, oldKeys, newKeys);
+      }
+    } catch (ProcessCanceledException e) {
+      LOG.error("ProcessCanceledException is not expected here", e);
+      throw e;
     }
   }
 
index da4c2764bbb8f761a37ea89d0b5ef3a974af7cf1..a3f0bc26993505dcfd95093ddb6700d17b1a479b 100644 (file)
@@ -606,7 +606,7 @@ public final class StubIndexImpl extends StubIndexEx {
         }
         final UpdatableIndex<K, Void, FileContent> index = getIndex(stubIndexKey);
         if (index == null) return;
-        index.updateWithMap(new AbstractUpdateData<K, Void>(fileId) {
+        index.updateWithMap(new AbstractUpdateData<>(fileId) {
           @Override
           protected boolean iterateKeys(@NotNull KeyValueUpdateProcessor<? super K, ? super Void> addProcessor,
                                         @NotNull KeyValueUpdateProcessor<? super K, ? super Void> updateProcessor,
index b9d9e96b303b79395f27444f724343887ed0f626..7030065f22be89ba47dab1349b8b4df69ce38270 100644 (file)
@@ -414,11 +414,16 @@ public final class StubUpdatingIndex extends SingleEntryFileBasedIndexExtension<
       IndexingStampInfo indexingStampInfo = content == null ? null : calculateIndexingStamp(content);
 
       return () -> {
-        Boolean result = indexUpdateComputable.compute();
-        if (Boolean.TRUE.equals(result)) {
-          saveIndexingStampInfo(indexingStampInfo, inputId);
+        try {
+          Boolean result = indexUpdateComputable.compute();
+          if (Boolean.TRUE.equals(result)) {
+            saveIndexingStampInfo(indexingStampInfo, inputId);
+          }
+          return result;
+        } catch (ProcessCanceledException e) {
+          LOG.error("ProcessCanceledException is not expected here", e);
+          throw e;
         }
-        return result;
       };
     }