diff --git a/platform/core-impl/src/com/intellij/psi/stubs/CoreStubTreeLoader.java b/platform/core-impl/src/com/intellij/psi/stubs/CoreStubTreeLoader.java index 06d90e719b2c..1f00d89d1b9e 100644 --- a/platform/core-impl/src/com/intellij/psi/stubs/CoreStubTreeLoader.java +++ b/platform/core-impl/src/com/intellij/psi/stubs/CoreStubTreeLoader.java @@ -28,6 +28,7 @@ import com.intellij.psi.tree.IStubFileElementType; import com.intellij.util.indexing.FileContent; import com.intellij.util.indexing.FileContentImpl; import com.intellij.util.indexing.IndexingDataKeys; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import java.io.IOException; @@ -83,4 +84,8 @@ public class CoreStubTreeLoader extends StubTreeLoader { return false; } + @Override + protected boolean isPrebuilt(@NotNull VirtualFile virtualFile) { + return false; + } } diff --git a/platform/core-impl/src/com/intellij/psi/stubs/StubTreeLoader.java b/platform/core-impl/src/com/intellij/psi/stubs/StubTreeLoader.java index 17f851061f66..8ab5e9dcb950 100644 --- a/platform/core-impl/src/com/intellij/psi/stubs/StubTreeLoader.java +++ b/platform/core-impl/src/com/intellij/psi/stubs/StubTreeLoader.java @@ -77,7 +77,14 @@ public abstract class StubTreeLoader { IndexingStampInfo indexingStampInfo = getIndexingStampInfo(file); boolean upToDate = indexingStampInfo != null && indexingStampInfo.isUpToDate(document, file, psiFile); + boolean canBePrebuilt = isPrebuilt(psiFile.getVirtualFile()); + String msg = _message + "\nPlease report the problem to JetBrains with the files attached\n"; + + if (canBePrebuilt) { + msg += "This stub can have pre-built origin\n"; + } + if (upToDate) { msg += "INDEXED VERSION IS THE CURRENT ONE"; } @@ -136,6 +143,8 @@ public abstract class StubTreeLoader { return upToDate ? handleUpToDateMismatch(msg, attachments) : new RuntimeExceptionWithAttachments(msg, attachments); } + protected abstract boolean isPrebuilt(@NotNull VirtualFile virtualFile); + private static UpToDateStubIndexMismatch handleUpToDateMismatch(@NotNull String message, Attachment[] attachments) { return new UpToDateStubIndexMismatch(message, attachments); } diff --git a/platform/lang-impl/src/com/intellij/psi/stubs/StubTreeLoaderImpl.java b/platform/lang-impl/src/com/intellij/psi/stubs/StubTreeLoaderImpl.java index 8ee7d0740ced..c09422b05da4 100644 --- a/platform/lang-impl/src/com/intellij/psi/stubs/StubTreeLoaderImpl.java +++ b/platform/lang-impl/src/com/intellij/psi/stubs/StubTreeLoaderImpl.java @@ -247,4 +247,22 @@ public class StubTreeLoaderImpl extends StubTreeLoader { protected IndexingStampInfo getIndexingStampInfo(@NotNull VirtualFile file) { return StubUpdatingIndex.getIndexingStampInfo(file); } + + @Override + protected boolean isPrebuilt(@NotNull VirtualFile virtualFile) { + boolean canBePrebuilt = false; + try { + final PrebuiltStubsProvider prebuiltStubsProvider = + PrebuiltStubsProviders.INSTANCE.forFileType(virtualFile.getFileType()); + if (prebuiltStubsProvider != null) { + canBePrebuilt = null != + prebuiltStubsProvider + .findStub(new FileContentImpl(virtualFile, virtualFile.contentsToByteArray())); + } + } + catch (Exception e) { + // pass + } + return canBePrebuilt; + } }