From fe95514af7a15d42f53801e4f38892cda53572c2 Mon Sep 17 00:00:00 2001 From: Dmitry Batkovich Date: Thu, 10 Oct 2019 14:28:31 +0300 Subject: [PATCH] add a special assertion if FileContentImpl#getPsiFile is called for a file with non language file type GitOrigin-RevId: 58d83b8cbd96b3a0a893e3e6b18368440435c48d --- .../src/com/intellij/util/indexing/FileContentImpl.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/platform/core-impl/src/com/intellij/util/indexing/FileContentImpl.java b/platform/core-impl/src/com/intellij/util/indexing/FileContentImpl.java index 208fa9827b38..baeb61a65690 100644 --- a/platform/core-impl/src/com/intellij/util/indexing/FileContentImpl.java +++ b/platform/core-impl/src/com/intellij/util/indexing/FileContentImpl.java @@ -114,7 +114,12 @@ public class FileContentImpl extends IndexedFileImpl implements PsiDependentFile if (project == null) { project = DefaultProjectFactory.getInstance().getDefaultProject(); } - return createFileFromText(project, text, (LanguageFileType)getFileTypeWithoutSubstitution(), myFile, myFileName); + FileType fileType = getFileTypeWithoutSubstitution(); + if (!(fileType instanceof LanguageFileType)) { + throw new AssertionError("PSI can be created only for a file with LanguageFileType but actual is " + fileType.getClass() + "." + + "\nPlease use a proper FileBasedIndexExtension#getInputFilter() implementation for the caller index"); + } + return createFileFromText(project, text, (LanguageFileType)fileType, myFile, myFileName); } @NotNull