mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't reparse file if a language is substituted with a dialect of the language (in this case, PushedFilePropertiesUpdater does the job) (IDEA-CR-11333)
This commit is contained in:
@@ -59,11 +59,11 @@ public final class LanguageSubstitutors extends LanguageExtension<LanguageSubsti
|
||||
@NotNull final Language substitutedLang) {
|
||||
Language prevSubstitutedLang = SUBSTITUTED_LANG_KEY.get(file);
|
||||
final Language prevLang = ObjectUtils.notNull(prevSubstitutedLang, originalLang);
|
||||
if (!substitutedLang.equals(prevLang)) {
|
||||
if (ApplicationManager.getApplication().isDispatchThread() && myReparsingInProgress) {
|
||||
return; // avoid recursive reparsing
|
||||
}
|
||||
if (!haveCommonAncestorLanguage(substitutedLang, prevLang)) {
|
||||
if (file.replace(SUBSTITUTED_LANG_KEY, prevSubstitutedLang, substitutedLang)) {
|
||||
if (ApplicationManager.getApplication().isDispatchThread() && myReparsingInProgress) {
|
||||
return; // avoid recursive reparsing
|
||||
}
|
||||
invokeLaterIfNeeded(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -78,6 +78,22 @@ public final class LanguageSubstitutors extends LanguageExtension<LanguageSubsti
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean haveCommonAncestorLanguage(@NotNull Language lang1, @NotNull Language lang2) {
|
||||
Language rootLang1 = findRootLanguage(lang1);
|
||||
Language rootLang2 = findRootLanguage(lang2);
|
||||
return rootLang1.is(rootLang2);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private static Language findRootLanguage(@NotNull Language lang) {
|
||||
Language parent = lang.getBaseLanguage();
|
||||
while (parent != null) {
|
||||
lang = parent;
|
||||
parent = lang.getBaseLanguage();
|
||||
}
|
||||
return lang;
|
||||
}
|
||||
|
||||
private static void invokeLaterIfNeeded(@NotNull Runnable runnable, @NotNull ModalityState modalityState) {
|
||||
if (ApplicationManager.getApplication().isDispatchThread()) {
|
||||
runnable.run();
|
||||
|
||||
Reference in New Issue
Block a user