@@ -0,0 +1,2019 @@
+package fr.adrienbrault.idea.symfony2plugin.util.yaml;%0A%0Aimport com.intellij.openapi.project.Project;%0Aimport com.intellij.openapi.util.Ref;%0Aimport com.intellij.psi.PsiElement;%0Aimport com.intellij.psi.PsiFile;%0Aimport com.intellij.psi.PsiFileFactory;%0Aimport com.intellij.psi.PsiRecursiveElementWalkingVisitor;%0Aimport com.intellij.psi.tree.IElementType;%0Aimport org.jetbrains.annotations.NotNull;%0Aimport org.jetbrains.annotations.Nullable;%0Aimport org.jetbrains.yaml.YAMLFileType;%0A%0Apublic class YamlPsiElementFactory %7B%0A%0A    @NotNull%0A    public static PsiElement createYamlPsiFromText(Project p, final IElementType type, @NotNull String text) %7B%0A        final Ref%3CPsiElement%3E ret = new Ref%3CPsiElement%3E();%0A        PsiFile dummyFile = createDummyFile(p, text);%0A        dummyFile.accept(new PsiRecursiveElementWalkingVisitor() %7B%0A            @Override%0A            public void visitElement(PsiElement element) %7B%0A                if(element.getNode() == type) %7B%0A                    ret.set(element);%0A                %7D%0A%0A                super.visitElement(element);%0A            %7D%0A        %7D);%0A%0A        assert !ret.isNull() : %22cannot create element from text:%5Cn%22 + dummyFile.getText();%0A%0A        return ret.get();%0A    %7D%0A%0A    @Nullable%0A    public static %3CT extends PsiElement%3E T createFromText(@NotNull Project p, final Class%3CT%3E aClass, String text) %7B%0A        final PsiElement%5B%5D ret = new PsiElement%5B%5D%7Bnull%7D;%0A%0A        createDummyFile(p, text).accept(new PsiRecursiveElementWalkingVisitor() %7B%0A            public void visitElement(PsiElement element) %7B%0A                if(aClass.isInstance(element)) %7B%0A                    ret%5B0%5D = element;%0A                %7D%0A%0A                super.visitElement(element);%0A            %7D%0A        %7D);%0A%0A        return (T) ret%5B0%5D;%0A    %7D%0A%0A%0A    @NotNull%0A    private static PsiFile createDummyFile(Project p, String fileText) %7B%0A        return PsiFileFactory.getInstance(p).createFileFromText(%22DUMMY__.%22 + YAMLFileType.YML.getDefaultExtension(), YAMLFileType.YML, fileText, System.currentTimeMillis(), false);%0A    %7D%0A%0A%7D%0A

add YamlPsiElementFactory for creating psi elements based on PhpPsiElementFactory