Merge branch 'set-original' of https://github.com/dzharkov/intellij-community
authorAndrey Starovoyt <andrey.starovoyt@jetbrains.com>
Fri, 10 Jun 2016 09:39:05 +0000 (12:39 +0300)
committerAndrey Starovoyt <andrey.starovoyt@jetbrains.com>
Fri, 10 Jun 2016 09:39:05 +0000 (12:39 +0300)
platform/lang-impl/src/com/intellij/codeInsight/template/postfix/templates/PostfixLiveTemplate.java

index 7b3ac17ba00c69758a724d876bc7eca84741dbdb..a4c108495182e361281f696ae5990dad4a5e0756 100644 (file)
@@ -39,6 +39,7 @@ import com.intellij.psi.PsiDocumentManager;
 import com.intellij.psi.PsiElement;
 import com.intellij.psi.PsiFile;
 import com.intellij.psi.PsiFileFactory;
+import com.intellij.psi.impl.source.PsiFileImpl;
 import com.intellij.psi.util.PsiUtilCore;
 import com.intellij.util.containers.ContainerUtil;
 import org.jetbrains.annotations.NotNull;
@@ -269,6 +270,11 @@ public class PostfixLiveTemplate extends CustomLiveTemplateBase {
   public static PsiFile copyFile(@NotNull PsiFile file, @NotNull StringBuilder fileContentWithoutKey) {
     final PsiFileFactory psiFileFactory = PsiFileFactory.getInstance(file.getProject());
     PsiFile copy = psiFileFactory.createFileFromText(file.getName(), file.getFileType(), fileContentWithoutKey);
+
+    if (copy instanceof PsiFileImpl) {
+      ((PsiFileImpl) copy).setOriginalFile(file);
+    }
+
     VirtualFile vFile = copy.getVirtualFile();
     if (vFile != null) {
       vFile.putUserData(UndoConstants.DONT_RECORD_UNDO, Boolean.TRUE);