add a special assertion if FileContentImpl#getPsiFile is called for a file with non language file type

GitOrigin-RevId: 58d83b8cbd96b3a0a893e3e6b18368440435c48d
This commit is contained in:
Dmitry Batkovich
2019-10-10 15:31:26 +00:00
committed by intellij-monorepo-bot
parent 93d6f7d6e6
commit fe95514af7
@@ -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