[mod-commands] PsiUpdateImpl: set original file for code style settings

GitOrigin-RevId: a97779a8674bc00b0fb9787f98913e1d71c273c3
This commit is contained in:
Tagir Valeev
2024-02-19 14:21:03 +00:00
committed by intellij-monorepo-bot
parent 895ba65ec6
commit 3c5f1db918
@@ -223,22 +223,26 @@ final class PsiUpdateImpl {
}
private static @NotNull PsiFile copyFile(Project project, PsiFile origFile) {
PsiFile file;
var manager = InjectedLanguageManager.getInstance(project);
boolean injectedFragment = manager.isInjectedFragment(origFile);
if (!injectedFragment) {
PsiElement navigationElement = origFile.getNavigationElement();
if (navigationElement != origFile && navigationElement instanceof PsiFile) {
return (PsiFile)navigationElement.copy();
file = (PsiFile)navigationElement.copy();
}
else {
file = (PsiFile)origFile.copy();
}
return (PsiFile)origFile.copy();
}
else {
PsiFile file = PsiFileFactory.getInstance(project).createFileFromText(
file = PsiFileFactory.getInstance(project).createFileFromText(
origFile.getName(), origFile.getLanguage(), manager.getUnescapedText(origFile),
false, true, true, origFile.getVirtualFile());
file.putUserData(ORIGINAL_FILE_FOR_INJECTION, origFile);
return file;
}
file.putUserData(PsiFileFactory.ORIGINAL_FILE, origFile);
return file;
}
private static class ModPsiUpdaterImpl implements ModPsiUpdater, DocumentListener, Disposable {