PerFileMappings<Language> () { return new PerFileMappings<>() { @Override public void setMapping(@Nullable VirtualFile file, @Nullable Language value) { myScratchMapping.setMapping(file, value == null ? null : value.getID()); } @Override public @Nullable Language getMapping(@Nullable VirtualFile file) { return Language.findLanguageByID(myScratchMapping.getMapping(file)); } }; }