diff --git a/platform/lang-impl/src/com/intellij/psi/templateLanguages/TemplateDataLanguagePusher.java b/platform/lang-impl/src/com/intellij/psi/templateLanguages/TemplateDataLanguagePusher.java index cae3f6e1d059..daa7557ac1dd 100644 --- a/platform/lang-impl/src/com/intellij/psi/templateLanguages/TemplateDataLanguagePusher.java +++ b/platform/lang-impl/src/com/intellij/psi/templateLanguages/TemplateDataLanguagePusher.java @@ -23,7 +23,9 @@ import com.intellij.openapi.roots.impl.PushedFilePropertiesUpdater; import com.intellij.openapi.util.Key; import com.intellij.openapi.vfs.VirtualFile; import com.intellij.openapi.vfs.newvfs.FileAttribute; +import com.intellij.openapi.vfs.newvfs.persistent.VfsDependentEnum; import com.intellij.util.io.DataInputOutputUtil; +import com.intellij.util.io.EnumeratorStringDescriptor; import com.intellij.util.messages.MessageBus; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; @@ -39,6 +41,12 @@ public class TemplateDataLanguagePusher implements FilePropertyPusher public static final Key KEY = Key.create("TEMPLATE_DATA_LANGUAGE"); + private static final VfsDependentEnum ourLanguagesEnumerator = new VfsDependentEnum<>( + "languages", + EnumeratorStringDescriptor.INSTANCE, + 1 + ); + @Override public void initExtra(@NotNull Project project, @NotNull MessageBus bus, @NotNull Engine languageLevelUpdater) { @@ -83,7 +91,7 @@ public class TemplateDataLanguagePusher implements FilePropertyPusher return true; } - private static final FileAttribute PERSISTENCE = new FileAttribute("template_language", 1, true); + private static final FileAttribute PERSISTENCE = new FileAttribute("template_language", 2, true); @Override public void persistAttribute(@NotNull Project project, @NotNull VirtualFile fileOrDir, @NotNull Language value) throws IOException { @@ -91,7 +99,8 @@ public class TemplateDataLanguagePusher implements FilePropertyPusher if (iStream != null) { try { final int oldLanguage = DataInputOutputUtil.readINT(iStream); - if (value.getID().hashCode() == oldLanguage) return; + String oldLanguageId = ourLanguagesEnumerator.getById(oldLanguage); + if (value.getID().equals(oldLanguageId)) return; } finally { //noinspection ThrowFromFinallyBlock @@ -101,7 +110,7 @@ public class TemplateDataLanguagePusher implements FilePropertyPusher if (value != Language.ANY || iStream != null) { final DataOutputStream oStream = PERSISTENCE.writeAttribute(fileOrDir); - DataInputOutputUtil.writeINT(oStream, value.getID().hashCode()); + DataInputOutputUtil.writeINT(oStream, ourLanguagesEnumerator.getId(value.getID())); oStream.close(); PushedFilePropertiesUpdater.getInstance(project).filePropertiesChanged(fileOrDir); }