作者:大大炮 | 来源:互联网 | 2023-10-13 08:59
本文整理了Java中fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlPsiElementFactory.createDummyFi
本文整理了Java中fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlPsiElementFactory.createDummyFile()
方法的一些代码示例,展示了YamlPsiElementFactory.createDummyFile()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlPsiElementFactory.createDummyFile()
方法的具体详情如下:
包路径:fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlPsiElementFactory
类名称:YamlPsiElementFactory
方法名:createDummyFile
YamlPsiElementFactory.createDummyFile介绍
暂无
代码示例
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Nullable
public static T createFromText(@NotNull Project p, final Class aClass, String text) {
final PsiElement[] ret = new PsiElement[]{null};
createDummyFile(p, text).accept(new PsiRecursiveElementWalkingVisitor() {
public void visitElement(PsiElement element) {
if(ret[0] == null && aClass.isInstance(element)) {
ret[0] = element;
}
super.visitElement(element);
}
});
return (T) ret[0];
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@NotNull
public static PsiElement createYamlPsiFromText(Project p, final IElementType type, @NotNull String text) {
final Ref ret = new Ref<>();
PsiFile dummyFile = createDummyFile(p, text);
dummyFile.accept(new PsiRecursiveElementWalkingVisitor() {
@Override
public void visitElement(PsiElement element) {
if(element.getNode() == type) {
ret.set(element);
}
super.visitElement(element);
}
});
assert !ret.isNull() : "cannot create element from text:\n" + dummyFile.getText();
return ret.get();
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
private int getIndentForTextContent(@NotNull String content) {
return YamlHelper.getIndentSpaceForFile((YAMLFile) YamlPsiElementFactory.createDummyFile(
getProject(),
"foo.yml",
content
));
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public void testThatNonConfigRootShouldNotProvideLinemarker() {
PsiElement yaml = YamlPsiElementFactory.createDummyFile(getProject(), "foobar.yml", "foobar_root:\n" +
" foo: ~"
);
assertLineMarkerIsEmpty(yaml);
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public void testThatConfigRootProvidesLinemarker() {
PsiElement yaml = YamlPsiElementFactory.createDummyFile(getProject(), "config.yml", "foobar_root:\n" +
" foo: ~"
);
assertLineMarker(yaml, new LineMarker.ToolTipEqualsAssert("Navigate to configuration"));
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see TwigUtil#getTwigPathFromYamlConfigResolved
*/
public void testGetTwigPathFromYamlConfigResolved() {
createFile("app/test/foo.yaml");
PsiFile dummyFile = YamlPsiElementFactory.createDummyFile(getProject(), "" +
"twig:\n" +
" paths:\n" +
" '%kernel.root_dir%/test': foo\n" +
" '%kernel.project_dir%/app/test': project\n" +
" '%kernel.root_dir%/../app': app\n"
);
Collection> paths = TwigUtil.getTwigPathFromYamlConfigResolved((YAMLFile) dummyFile);
assertNotNull(
paths.stream().filter(pair -> "foo".equals(pair.getFirst()) && "app/test".equals(pair.getSecond())).findFirst()
);
assertNotNull(
paths.stream().filter(pair -> "project".equals(pair.getFirst()) && "app/test".equals(pair.getSecond())).findFirst()
);
assertNotNull(
paths.stream().filter(pair -> "app".equals(pair.getFirst()) && "app".equals(pair.getSecond())).findFirst()
);
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public void testBuildForClassWithoutParameter() {
PsiFile dummyFile = YamlPsiElementFactory.createDummyFile(getProject(), "foo.yml", "services:\n foobar: ~");
ServiceBuilder serviceBuilder = new ServiceBuilder(Collections.emptyList(), dummyFile, false);
assertEquals(
"foobar:\n class: Foobar",
serviceBuilder.build(ServiceBuilder.OutputType.Yaml, "Foobar", "foobar")
);
assertEquals(
"",
StringUtils.trim(serviceBuilder.build(ServiceBuilder.OutputType.XML, "Foobar", "foobar"))
);
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public void testInsertTranslationForYamlFile() {
PsiFile dummyFile = YamlPsiElementFactory.createDummyFile(getProject(), "foo.de.yml", "car: 'foo'");
CommandProcessor.getInstance().executeCommand(getProject(), () -> ApplicationManager.getApplication().runWriteAction(() -> {
TranslationInsertUtil.invokeTranslation(dummyFile, "foobar", "value");
}), null, null);
String text = dummyFile.getText();
assertTrue(text.contains("foobar: 'value'"));
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public void testBuildForConstructor() {
ServiceBuilder serviceBuilder = new ServiceBuilder(
getMethodModelParameters(),
YamlPsiElementFactory.createDummyFile(getProject(), "foo.yml", "services:\n foobar: ~"),
false
);
String expectedYaml = "" +
"foobar:\n" +
" class: Foo\\Bar\n" +
" arguments: ['@foobar']";
assertEquals(
expectedYaml,
serviceBuilder.build(ServiceBuilder.OutputType.Yaml, "Foo\\Bar", "foobar")
);
String expectedXml = "" +
"\n" +
" \n" +
"";
assertEquals(
expectedXml,
StringUtils.trim(serviceBuilder.build(ServiceBuilder.OutputType.XML, "Foo\\Bar", "foobar"))
);
}