void (final Project project, final XmlFile containingFile, final String languageName) { WriteCommandAction.writeCommandAction(project).withName(getFamilyName()).run(() -> { final PsiFileFactory factory = PsiFileFactory.getInstance(project); final XmlFile dummyFile = (XmlFile)factory.createFileFromText("_Dummy_.fxml", XmlFileType.INSTANCE, "<?language " + languageName + "?>"); final XmlDocument document = dummyFile.getDocument(); if (document != null) { final XmlProlog prolog = document.getProlog(); final Collection<XmlProcessingInstruction> instructions = PsiTreeUtil.findChildrenOfType(prolog, XmlProcessingInstruction.class); LOG.assertTrue(instructions.size() == 1); final XmlDocument xmlDocument = containingFile.getDocument(); if (xmlDocument != null) { final XmlProlog xmlProlog = xmlDocument.getProlog(); if (xmlProlog != null) { final PsiElement element = xmlProlog.addBefore(instructions.iterator().next(), xmlProlog.getFirstChild()); xmlProlog.addAfter(PsiParserFacade.getInstance(project).createWhiteSpaceFromText("\n\n"), element); } } } }); }