From 46a96b02816adfd39d67ad7f230697d00b63ce4d Mon Sep 17 00:00:00 2001 From: Dmitry Trofimov Date: Fri, 6 Oct 2017 21:39:44 +0200 Subject: [PATCH] Add option to debug prebuilt indices --- platform/lang-impl/src/com/intellij/index/PrebuiltIndex.kt | 2 ++ .../src/com/intellij/index/PrebuiltIndexAwareIdIndexer.kt | 7 +++++++ 2 files changed, 9 insertions(+) diff --git a/platform/lang-impl/src/com/intellij/index/PrebuiltIndex.kt b/platform/lang-impl/src/com/intellij/index/PrebuiltIndex.kt index 54933312fc54..3bbc51e4f6d5 100644 --- a/platform/lang-impl/src/com/intellij/index/PrebuiltIndex.kt +++ b/platform/lang-impl/src/com/intellij/index/PrebuiltIndex.kt @@ -30,6 +30,8 @@ abstract class PrebuiltIndexProviderBase : Disposable { companion object { private val LOG = Logger.getInstance("#com.intellij.index.PrebuiltIndexProviderBase") + + val PREBUILT_INDICES_DEBUG: Boolean = System.getProperty("PREBUILT_INDICES_DEBUG", "false").toBoolean() } init { diff --git a/platform/lang-impl/src/com/intellij/index/PrebuiltIndexAwareIdIndexer.kt b/platform/lang-impl/src/com/intellij/index/PrebuiltIndexAwareIdIndexer.kt index 67ad4a17e69e..d66c7c6e48fd 100644 --- a/platform/lang-impl/src/com/intellij/index/PrebuiltIndexAwareIdIndexer.kt +++ b/platform/lang-impl/src/com/intellij/index/PrebuiltIndexAwareIdIndexer.kt @@ -1,6 +1,7 @@ // Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file. package com.intellij.index +import com.intellij.openapi.diagnostic.Logger import com.intellij.psi.impl.cache.impl.id.IdIndexEntry import com.intellij.psi.impl.cache.impl.id.IdIndexer import com.intellij.util.indexing.FileContent @@ -15,6 +16,7 @@ import java.io.DataOutput abstract class PrebuiltIndexAwareIdIndexer : PrebuiltIndexProviderBase>(), IdIndexer { companion object { + private val LOG = Logger.getInstance("#com.intellij.index.PrebuiltIndexAwareIdIndexer") val ID_INDEX_FILE_NAME = "id-index" } @@ -25,6 +27,11 @@ abstract class PrebuiltIndexAwareIdIndexer : PrebuiltIndexProviderBase { val map = get(inputData) return if (map != null) { + if (PREBUILT_INDICES_DEBUG) { + if (!map.equals(idIndexMap(inputData))) { + LOG.error("Prebuilt id index differs from actual value") + } + } map } else {