- 使用 Spring Initializr 创建 Spring Boot 应用程序
- 在Spring Boot中配置Cassandra
- 在 Spring Boot 上配置 Tomcat 连接池
- 将Camel消息路由到嵌入WildFly的Artemis上
本文整理了Java中fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlPsiElementFactory.createFromText()
方法的一些代码示例,展示了YamlPsiElementFactory.createFromText()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。YamlPsiElementFactory.createFromText()
方法的具体详情如下:
包路径:fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlPsiElementFactory
类名称:YamlPsiElementFactory
方法名:createFromText
暂无
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
@Override
public void applyFix(@NotNull Project project, @NotNull ProblemDescriptor descriptor) {
PsiElement psiElement1 = descriptor.getPsiElement();
YAMLKeyValue replacement = YamlPsiElementFactory.createFromText(
project,
YAMLKeyValue.class,
"class: " + replacementFQN
);
if (replacement != null && replacement.getValue() != null) {
psiElement1.replace(replacement.getValue());
}
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
private void insertYamlServiceTag() {
if(!(this.psiFile instanceof YAMLFile)) {
return;
}
String text = createServiceAsText(ServiceBuilder.OutputType.Yaml, this.psiFile);
YAMLKeyValue fromText = YamlPsiElementFactory.createFromText(project, YAMLKeyValue.class, text);
if(fromText == null) {
return;
}
PsiElement psiElement = YamlHelper.insertKeyIntoFile((YAMLFile) psiFile, fromText, "services");
if(psiElement != null) {
navigateToElement(new TextRange[] {psiElement.getTextRange()});
}
dispose();
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#getYamlKeyValueAsString
*/
public void testGetYamlKeyValueAsString() {
String[] strings = {
"{ name: routing.loader, method: foo }",
"{ name: routing.loader, method: 'foo' }",
"{ name: routing.loader, method: \"foo\" }",
};
for (String s : strings) {
assertEquals("foo", YamlHelper.getYamlKeyValueAsString(
YamlPsiElementFactory.createFromText(getProject(), YAMLHashImpl.class, s),
"method"
));
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#getYamlArrayOnSequenceOrArrayElements
*/
public void testGetYamlArrayOnSequenceOrArrayElementsForArray() {
YAMLCompoundValue fromText = YamlPsiElementFactory.createFromText(getProject(), YAMLCompoundValue.class, "" +
"calls: [@foo, @bar] \n"
);
assertNotNull(fromText);
String join = StringUtils.join(ContainerUtil.map(YamlHelper.getYamlArrayOnSequenceOrArrayElements(fromText), new Function<PsiElement, String>() {
@Override
public String fun(PsiElement psiElement) {
return psiElement.getText();
}
}), ",");
assertTrue(join.contains("foo"));
assertTrue(join.contains("bar"));
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#collectServiceTags
*/
public void testCollectServiceTags() {
YAMLKeyValue fromText = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "" +
"foo:\n" +
" tags:\n" +
" - { name: routing.loader, method: crossHint }\n" +
" - { name: routing.loader1, method: crossHint }\n"
);
assertNotNull(fromText);
assertContainsElements(YamlHelper.collectServiceTags(fromText), "routing.loader", "routing.loader1");
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
Collection<YAMLDocument> yamlDocuments = new ArrayList<YAMLDocument>();
yamlDocuments.add(YamlPsiElementFactory.createFromText(getProject(), YAMLDocument.class, String.format(
"route1:\n" +
" path: /foo\n" +
)));
yamlDocuments.add(YamlPsiElementFactory.createFromText(getProject(), YAMLDocument.class, String.format(
"route1:\n" +
" path: /foo\n" +
)));
yamlDocuments.add(YamlPsiElementFactory.createFromText(getProject(), YAMLDocument.class, String.format(
"route1:\n" +
" pattern: /foo\n" +
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#getYamlArrayOnSequenceOrArrayElements
*/
public void testGetYamlArrayOnSequenceOrArrayElements() {
String[] strings = {
"calls: [@foo, @bar] \n",
"calls:\n - @foo\n - @bar\n",
};
for (String s : strings) {
YAMLCompoundValue fromText = YamlPsiElementFactory.createFromText(getProject(), YAMLCompoundValue.class, s);
assertNotNull(fromText);
List<PsiElement> elements = YamlHelper.getYamlArrayOnSequenceOrArrayElements(fromText);
assertNotNull(elements);
String join = StringUtils.join(ContainerUtil.map(elements, new Function<PsiElement, String>() {
@Override
public String fun(PsiElement psiElement) {
return psiElement.getText();
}
}), ",");
assertTrue(join.contains("foo"));
assertTrue(join.contains("bar"));
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper#getYamlRouteDefinitions
*/
public void testGetYamlRouteDefinitionsForControllerKeyword() {
Collection<StubIndexedRoute> yamlRouteDefinitions = RouteHelper.getYamlRouteDefinitions(YamlPsiElementFactory.createFromText(getProject(), YAMLDocument.class,
"foo_keyword:\n" +
" path: /foo\n" +
" controller: 'AppBundle:Blog:list'\n"
));
StubIndexedRoute route = ContainerUtil.find(yamlRouteDefinitions, new MyEqualStubIndexedRouteCondition("foo_keyword"));
assertNotNull(route);
assertContainsElements(Collections.singletonList("AppBundle:Blog:list"), route.getController());
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#collectServiceTags
*/
public void testCollectServiceTagsForSymfony33TagsShortcutInline() {
YAMLKeyValue fromText = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "" +
"foo:\n" +
" tags: [routing.loader_tags_3, routing.loader_tags_4]\n"
);
assertNotNull(fromText);
Set<String> collection = YamlHelper.collectServiceTags(fromText);
assertContainsElements(collection, "routing.loader_tags_3");
assertContainsElements(collection, "routing.loader_tags_4");
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
public void testYmlTagAttributeExtraction() {
YAMLHashImpl fromText = YamlPsiElementFactory.createFromText(getProject(), YAMLHashImpl.class, "{ name: routing.loader, method: foo }");
YamlServiceTag tag = new YamlServiceTag("foo", "routing.loader", (YAMLMapping) fromText);
assertEquals("foo", tag.getAttribute("method"));
assertEquals("routing.loader", tag.getAttribute("name"));
}
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#collectServiceTags
*/
public void testCollectServiceTagsForSymfony33TagsShortcut() {
YAMLKeyValue fromText = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "" +
"foo:\n" +
" tags:\n" +
" - routing.loader_tags_1\n" +
" - routing.loader_tags_2\n"
);
assertNotNull(fromText);
Set<String> collection = YamlHelper.collectServiceTags(fromText);
assertContainsElements(collection, "routing.loader_tags_1");
assertContainsElements(collection, "routing.loader_tags_2");
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#insertKeyIntoFile
*/
public void testInsertKeyValueWithMissingMainKeyInRoot() {
YAMLFile yamlFile = (YAMLFile) myFixture.configureByText(YAMLFileType.YML, "foo: foo");
YAMLKeyValue yamlKeyValue = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "" +
"my_service:\n" +
" class: foo\n" +
" tag: foo"
);
assertNotNull(yamlKeyValue);
YamlHelper.insertKeyIntoFile(yamlFile, yamlKeyValue, "services");
assertEquals("" +
"foo: foo\n" +
"services:\n" +
" my_service:\n" +
" class: foo\n" +
" tag: foo",
yamlFile.getText()
);
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.routing.RouteHelper#getYamlRouteDefinitions
*/
public void testGetYamlRouteDefinitionsWithMethods() {
Collection<StubIndexedRoute> yamlRouteDefinitions = RouteHelper.getYamlRouteDefinitions(YamlPsiElementFactory.createFromText(getProject(), YAMLDocument.class,
"route1:\n" +
" path: /foo\n" +
" methods: [GET]\n" +
"route2:\n" +
" path: /foo\n" +
" methods: GET\n" +
"route3:\n" +
" path: /foo\n" +
" methods: [GET, POST]\n"
));
assertContainsElements(Collections.singletonList("get"), ContainerUtil.find(yamlRouteDefinitions, new MyEqualStubIndexedRouteCondition("route1")).getMethods());
assertContainsElements(Collections.singletonList("get"), ContainerUtil.find(yamlRouteDefinitions, new MyEqualStubIndexedRouteCondition("route2")).getMethods());
assertContainsElements(Arrays.asList("get", "post"), ContainerUtil.find(yamlRouteDefinitions, new MyEqualStubIndexedRouteCondition("route3")).getMethods());
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#insertKeyIntoFile
*/
public void testInsertKeyWithArrayValue() {
YAMLFile yamlFile = (YAMLFile) myFixture.configureByText(YAMLFileType.YML, "" +
"services:\n" +
" foo:\n" +
" car: test"
);
YAMLKeyValue yamlKeyValue = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "" +
"my_service:\n" +
" class: foo\n" +
" tag:\n" +
" - foo\n"
);
assertNotNull(yamlKeyValue);
YamlHelper.insertKeyIntoFile(yamlFile, yamlKeyValue, "services");
assertEquals("" +
"services:\n" +
" foo:\n" +
" car: test\n" +
" my_service:\n" +
" class: foo\n" +
" tag:\n" +
" - foo",
yamlFile.getText()
);
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitTagsOnServiceDefinition
*/
public void testVisitTagsOnServiceDefinitionWithQuote() {
YAMLKeyValue yamlKeyValue = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "foo:\n" +
" tags:\n" +
" - { name: 'kernel.event_listener', event: 'eventName', method: 'methodName' }\n"
);
ListYamlTagVisitor visitor = new ListYamlTagVisitor();
YamlHelper.visitTagsOnServiceDefinition(yamlKeyValue, visitor);
assertEquals("kernel.event_listener", visitor.getItem().getName());
assertEquals("eventName", visitor.getItem().getAttribute("event"));
assertEquals("methodName", visitor.getItem().getAttribute("method"));
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitTagsOnServiceDefinition
*/
public void testVisitTagsOnServiceDefinitionForSymfony33TagsShortcut() {
YAMLKeyValue yamlKeyValue = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "foo:\n" +
" tags:\n" +
" - kernel.event_listener\n" +
" - kernel.event_listener2\n"
);
ListYamlTagVisitor visitor = new ListYamlTagVisitor();
YamlHelper.visitTagsOnServiceDefinition(yamlKeyValue, visitor);
assertEquals("kernel.event_listener", visitor.getItem(0).getName());
assertEquals("kernel.event_listener", visitor.getItem(0).getAttribute("name"));
assertEquals("kernel.event_listener2", visitor.getItem(1).getName());
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitTagsOnServiceDefinition
*/
public void testVisitTagsOnServiceDefinitionWithDoubleQuote() {
YAMLKeyValue yamlKeyValue = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "foo:\n" +
" tags:\n" +
" - { name: \"kernel.event_listener\", event: \"eventName\", method: \"methodName\" }\n"
);
ListYamlTagVisitor visitor = new ListYamlTagVisitor();
YamlHelper.visitTagsOnServiceDefinition(yamlKeyValue, visitor);
assertEquals("kernel.event_listener", visitor.getItem().getName());
assertEquals("eventName", visitor.getItem().getAttribute("event"));
assertEquals("methodName", visitor.getItem().getAttribute("method"));
}
代码示例来源:origin: Haehnchen/idea-php-symfony2-plugin
/**
* @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitTagsOnServiceDefinition
*/
public void testVisitTagsOnServiceDefinition() {
YAMLKeyValue yamlKeyValue = YamlPsiElementFactory.createFromText(getProject(), YAMLKeyValue.class, "foo:\n" +
" tags:\n" +
" - { name: kernel.event_listener, event: eventName, method: methodName }\n" +
" - { name: kernel.event_listener2, event: eventName2, method: methodName2 }\n"
);
ListYamlTagVisitor visitor = new ListYamlTagVisitor();
YamlHelper.visitTagsOnServiceDefinition(yamlKeyValue, visitor);
assertEquals("kernel.event_listener", visitor.getItem(0).getName());
assertEquals("eventName", visitor.getItem(0).getAttribute("event"));
assertEquals("methodName", visitor.getItem(0).getAttribute("method"));
assertEquals("kernel.event_listener2", visitor.getItem(1).getName());
assertEquals("eventName2", visitor.getItem(1).getAttribute("event"));
assertEquals("methodName2", visitor.getItem(1).getAttribute("method"));
}
本文整理了Java中fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlPsiElementFactory.createDummyFile()方法的一些
本文整理了Java中fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlPsiElementFactory.createFromText()方法的一些代
我是一名优秀的程序员,十分优秀!