org.jetbrains.yaml.YAMLFileType Java Examples
The following examples show how to use
org.jetbrains.yaml.YAMLFileType.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServiceLineMarkerProviderTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testYamlServiceLineMarker() { myFixture.configureByText(YAMLFileType.YML, "services:\n" + " foo:\n" + " class: Service\\YamlBar" ); assertLineMarker(PhpPsiElementFactory.createPsiFileFromText(getProject(), "<?php\n" + "namespace Service{\n" + " class YamlBar{}\n" + "}" ), new LineMarker.TargetAcceptsPattern("Navigate to definition", PlatformPatterns.psiElement(YAMLKeyValue.class).with(new PatternCondition<YAMLKeyValue>("KeyText") { @Override public boolean accepts(@NotNull YAMLKeyValue yamlKeyValue, ProcessingContext processingContext) { return yamlKeyValue.getKeyText().equals("foo"); } }))); }
Example #2
Source File: YamlGotoCompletionRegistrarTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testThatRouteInsideRouteDefaultKeyCompletedAndNavigable() { assertCompletionContains(YAMLFileType.YML, "" + "root:\n" + " path: /wp-admin\n" + " defaults:\n" + " route: '<caret>'\n", "foo_route" ); assertNavigationMatch(YAMLFileType.YML, "" + "root:\n" + " path: /wp-admin\n" + " defaults:\n" + " route: 'foo_<caret>route'\n" ); }
Example #3
Source File: YamlHelperLightTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCallArgumentMethodIndex */ public void testVisitServiceCallArgumentMethodIndex() { myFixture.configureByText(YAMLFileType.YML, "services:\n" + " foobar:\n" + " class: Foo\\Bar\n" + " calls:\n" + " - [ 'setBar', [@f<caret>oo] ]\n" ); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); YAMLScalar parent = (YAMLScalar) psiElement.getParent(); Collection<Parameter> parameters = new ArrayList<>(); YamlHelper.visitServiceCallArgumentMethodIndex(parent, parameters::add); assertNotNull(ContainerUtil.find(parameters, parameter -> "arg1".equals(parameter.getName()))); }
Example #4
Source File: YamlCompletionContributorTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
private void assertCompletion3rdInvocationContains(String configureByText, String... lookupStrings) { myFixture.configureByText(YAMLFileType.YML, configureByText); myFixture.complete(CompletionType.BASIC, 3); if(lookupStrings.length == 0) { fail("No lookup element given"); } List<String> lookupElements = myFixture.getLookupElementStrings(); if(lookupElements == null || lookupElements.size() == 0) { fail(String.format("failed that empty completion contains %s", Arrays.toString(lookupStrings))); } for (String s : lookupStrings) { if(!lookupElements.contains(s)) { fail(String.format("failed that completion contains %s in %s", s, lookupElements.toString())); } } }
Example #5
Source File: YamlGotoCompletionRegistrarTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testThatTemplateInsideRouteDefaultKeyCompletedAndNavigable() { if(System.getenv("PHPSTORM_ENV") != null) return; try { createDummyFiles("app/Resources/views/foo.html.twig"); } catch (Exception e) { e.printStackTrace(); } assertCompletionContains(YAMLFileType.YML, "" + "root:\n" + " path: /wp-admin\n" + " defaults:\n" + " template: '<caret>'\n", "foo.html.twig" ); assertNavigationMatch(YAMLFileType.YML, "" + "root:\n" + " path: /wp-admin\n" + " defaults:\n" + " template: 'foo.ht<caret>ml.twig'\n" ); }
Example #6
Source File: RoutesStubIndexTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see fr.adrienbrault.idea.symfony2plugin.stubs.indexes.RoutesStubIndex#getIndexer() */ public void testControllerAsInvokeRoutingSupportsClassPatternForDefaults() { myFixture.configureByText(YAMLFileType.YML, "" + "controller_invoke:\n" + " pattern: /\n" + " defaults: { _controller: Foobar\\Foobar\\Foobar }" + "\n" + "controller_invoke_2:\n" + " pattern: /\n" + " defaults: { _controller: \\Foobar\\Foobar\\Foobar }" + "\n" ); assertIndexContainsKeyWithValue(RoutesStubIndex.KEY, "controller_invoke", value -> "Foobar\\Foobar\\Foobar".equalsIgnoreCase(value.getController()) ); assertIndexContainsKeyWithValue(RoutesStubIndex.KEY, "controller_invoke_2", value -> "Foobar\\Foobar\\Foobar".equalsIgnoreCase(value.getController()) ); }
Example #7
Source File: ControllerCompletionTest.java From idea-php-drupal-symfony2-bridge with MIT License | 6 votes |
public void testThatEntityFormCompletesAndNavigates() { assertCompletionContains(YAMLFileType.YML, "" + "config.import_full:\n" + " defaults:\n" + " _controller: '<caret>'", "\\Drupal\\contact\\Controller\\ContactController::foo" ); assertCompletionNotContains(YAMLFileType.YML, "" + "config.import_full:\n" + " defaults:\n" + " _controller: '<caret>'", "\\Drupal\\contact\\Controller\\ContactController::privateBar" ); assertCompletionNotContains(YAMLFileType.YML, "" + "config.import_full:\n" + " defaults:\n" + " _controller: '<caret>'", "\\Drupal\\contact\\Controller\\ContactController::__construct" ); }
Example #8
Source File: YamlHelperLightTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCallArgument */ public void testVisitServiceCallArgument() { myFixture.configureByText(YAMLFileType.YML, "services:\n" + " foobar:\n" + " class: Foo\\Bar\n" + " calls:\n" + " - [ 'setBar', [@f<caret>oo] ]\n" ); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); YAMLScalar parent = (YAMLScalar) psiElement.getParent(); Collection<String> values = new ArrayList<>(); YamlHelper.visitServiceCallArgument(parent, parameterVisitor -> values.add(parameterVisitor.getClassName() + ":" + parameterVisitor.getMethod() + ":" + parameterVisitor.getParameterIndex()) ); assertContainsElements(values, "Foo\\Bar:setBar:0"); }
Example #9
Source File: YamlHelperLightTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#insertKeyIntoFile */ public void testInsertKeyIntoFile() { YAMLFile yamlFile = (YAMLFile) myFixture.configureByText(YAMLFileType.YML, "" + "foo:\n" + " bar:\n" + " car: test" ); YamlHelper.insertKeyIntoFile(yamlFile, "value", "foo", "bar", "apple"); assertEquals("" + "foo:\n" + " bar:\n" + " car: test\n" + " apple: value", yamlFile.getText() ); }
Example #10
Source File: TwigUtilTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see TwigUtil#getTwigGlobalsFromYamlConfig */ public void testGetTwigGlobalsFromYamlConfig() { String content = "twig:\n" + " globals:\n" + " ga_tracking: '%ga_tracking%'\n" + " user_management: '@AppBundle\\Service\\UserManagement'\n" ; YAMLFile yamlFile = (YAMLFile) PsiFileFactory.getInstance(getProject()) .createFileFromText("DUMMY__." + YAMLFileType.YML.getDefaultExtension(), YAMLFileType.YML, content, System.currentTimeMillis(), false); Map<String, String> globals = TwigUtil.getTwigGlobalsFromYamlConfig(yamlFile); assertEquals("%ga_tracking%", globals.get("ga_tracking")); assertEquals("@AppBundle\\Service\\UserManagement", globals.get("user_management")); }
Example #11
Source File: CaseSensitivityServiceInspection.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@NotNull public PsiElementVisitor buildVisitor(final @NotNull ProblemsHolder holder, boolean isOnTheFly) { if(!Symfony2ProjectComponent.isEnabled(holder.getProject())) { return super.buildVisitor(holder, isOnTheFly); } return new PsiElementVisitor() { @Override public void visitFile(PsiFile psiFile) { if(psiFile.getFileType() == PhpFileType.INSTANCE) { phpVisitor(holder, psiFile); } else if(psiFile.getFileType() == YAMLFileType.YML) { yamlVisitor(holder, psiFile); } else if(psiFile.getFileType() == XmlFileType.INSTANCE) { xmlVisitor(holder, psiFile); } } }; }
Example #12
Source File: YamlHelperLightTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCallArgumentMethodIndex */ public void testVisitServiceCallArgumentMethodIndexForNamedServices() { myFixture.configureByText(YAMLFileType.YML, "services:\n" + " Foo\\Bar:\n" + " calls:\n" + " - [ 'setBar', ['@foo', @f<caret>oo] ]\n" ); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); YAMLScalar parent = (YAMLScalar) psiElement.getParent(); Collection<Parameter> parameters = new ArrayList<>(); YamlHelper.visitServiceCallArgumentMethodIndex(parent, parameters::add); assertNotNull(ContainerUtil.find(parameters, parameter -> "arg2".equals(parameter.getName()))); }
Example #13
Source File: ResourceReferenceContributorTest.java From idea-php-typo3-plugin with MIT License | 6 votes |
public void testResourceReferencesAreCreated() { myFixture.addFileToProject("foo/ext_emconf.php", ""); myFixture.addFileToProject("foo/Configuration/RTE/Processing.yaml", ""); myFixture.configureByText(YAMLFileType.YML, "imports:\n" + " - { resource: \"EXT:foo/Configuration/RTE/<caret>Processing.yaml\" }';"); PsiElement elementAtCaret = myFixture.getFile().findElementAt(myFixture.getCaretOffset()).getParent(); PsiReference[] references = elementAtCaret.getReferences(); for (PsiReference ref : references) { if (ref instanceof ResourceReference) { return; } } fail("No resource reference."); }
Example #14
Source File: YamlCompletionContributorTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testThatKeywordsAreNotCompletedInNewLine() { assertCompletionNotContains(YAMLFileType.YML, "" + "root:\n" + " <caret>" + " foo: bar\n", "true" ); assertCompletionNotContains(YAMLFileType.YML, "" + "root:\n" + " foo: bar\n" + "<caret>", "true" ); assertCompletionNotContains(YAMLFileType.YML, "" + "root:\n" + " foo: bar\n" + " <caret>", "true" ); }
Example #15
Source File: YamlGoToDeclarationHandlerTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testResourcesInsideSameDirectoryProvidesNavigation() { assertNavigationContainsFile(YAMLFileType.YML, "imports:\n" + " - { resource: config_<caret>foo.yml }", "config_foo.yml" ); assertNavigationContainsFile(YAMLFileType.YML, "imports:\n" + " - { resource: 'config_<caret>foo.yml' }", "config_foo.yml" ); assertNavigationContainsFile(YAMLFileType.YML, "imports:\n" + " - { resource: \"config_<caret>foo.yml\" }", "config_foo.yml" ); }
Example #16
Source File: YamlHelperLightTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#getServiceDefinitionClassFromTagMethod */ public void testGetServiceDefinitionClassFromTagMethod() { myFixture.configureByText(YAMLFileType.YML, "" + "services:\n" + " foobar:\n" + " class: ClassName\\Foo\n" + " tags:\n" + " - { method: cross<caret>Hint }" ); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertEquals("ClassName\\Foo", YamlHelper.getServiceDefinitionClassFromTagMethod(psiElement)); myFixture.configureByText(YAMLFileType.YML, "" + "services:\n" + " ClassName\\Foo:\n" + " tags:\n" + " - { method: cross<caret>Hint }" ); psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); assertEquals("ClassName\\Foo", YamlHelper.getServiceDefinitionClassFromTagMethod(psiElement)); }
Example #17
Source File: YamlHelperLightTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#insertKeyIntoFile */ public void testInsertKeyIntoFileOnRoot() { YAMLFile yamlFile = (YAMLFile) myFixture.configureByText(YAMLFileType.YML, "" + "foo:\n" + " bar:\n" + " car: test" ); YamlHelper.insertKeyIntoFile(yamlFile, "value", "car", "bar", "apple"); assertEquals("" + "foo:\n" + " bar:\n" + " car: test\n" + "car:\n" + " bar:\n" + " apple: value", yamlFile.getText() ); }
Example #18
Source File: YamlCompletionContributorTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testKeywordsCompletion() { assertCompletionContains(YAMLFileType.YML, "" + "root:\n" + " key: <caret>\n", "true", ".inf" ); assertCompletionContains(YAMLFileType.YML, "" + "root:\n" + " key: <caret>", "true", ".inf" ); assertCompletionContains(YAMLFileType.YML, "" + "root:\n" + " key: tr<caret>", "true" ); // assertCompletionContains(YAMLFileType.YML, "" + // "root:\n" + // " key: .i<caret>", // ".inf" // ); }
Example #19
Source File: YamlCompletionContributorTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testTagsCompletionContainsStandardTags() { assertCompletionContains(YAMLFileType.YML, "" + "root:\n" + " key: <caret>\n", "!!binary", "!!float", "!!str" ); assertCompletionContains(YAMLFileType.YML, "" + "root:\n" + " key: !<caret>\n", "!!binary", "!!float", "!!str" ); assertCompletionContains(YAMLFileType.YML, "" + "root:\n" + " key: !!<caret>\n", "!!binary", "!!float", "!!str" ); }
Example #20
Source File: YamlElementPatternHelper.java From idea-php-symfony2-plugin with MIT License | 6 votes |
@Override public boolean accepts(@NotNull PsiFile psiFile, ProcessingContext processingContext) { if (psiFile.getFileType() != YAMLFileType.YML) { return false; } if (psiFile.getName().matches("(security|config).*\\.(yml|yaml)")) { return true; } // psiFile.virtualFile is empty; check via folder structure PsiDirectory containingDirectory = psiFile.getContainingDirectory(); if (containingDirectory == null) { return false; } if ("packages".equals(containingDirectory.getName())) { return true; } VirtualFile virtualDirectoryFile = containingDirectory.getVirtualFile(); String relativePath = VfsExUtil.getRelativeProjectPath(psiFile.getProject(), virtualDirectoryFile); return relativePath != null && relativePath.contains("config/packages/"); }
Example #21
Source File: ServiceUtil.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * Get parameter def inside xml or yaml file */ public static Collection<PsiElement> getParameterDefinition(Project project, String parameterName) { if(parameterName.length() > 2 && parameterName.startsWith("%") && parameterName.endsWith("%")) { parameterName = parameterName.substring(1, parameterName.length() - 1); } Collection<PsiElement> psiElements = new ArrayList<>(); Collection<VirtualFile> fileCollection = FileBasedIndex.getInstance().getContainingFiles(ContainerParameterStubIndex.KEY, parameterName, GlobalSearchScope.getScopeRestrictedByFileTypes(GlobalSearchScope.allScope(project), XmlFileType.INSTANCE, YAMLFileType.YML)); for(VirtualFile virtualFile: fileCollection) { PsiFile psiFile = PsiManager.getInstance(project).findFile(virtualFile); if(psiFile != null) { psiElements.addAll(ServiceIndexUtil.findParameterDefinitions(psiFile, parameterName)); } } return psiElements; }
Example #22
Source File: YamlHelperLightTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
/** * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCallArgument */ public void testVisitServiceCallArgumentAsNamedService() { myFixture.configureByText(YAMLFileType.YML, "services:\n" + " Foo\\Bar:\n" + " calls:\n" + " - [ 'setBar', [@f<caret>oo] ]\n" ); PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset()); YAMLScalar parent = (YAMLScalar) psiElement.getParent(); Collection<String> values = new ArrayList<>(); YamlHelper.visitServiceCallArgument(parent, parameterVisitor -> values.add(parameterVisitor.getClassName() + ":" + parameterVisitor.getMethod() + ":" + parameterVisitor.getParameterIndex()) ); assertContainsElements(values, "Foo\\Bar:setBar:0"); }
Example #23
Source File: YamlDicNavigationContributorTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testFactoryClassMethodNavigation() { assertNavigationContains(YAMLFileType.YML, "services:\n" + " foo.factory:\n" + " class: Foo\\Name\\FooClass\n" + " foo.manager:\n" + " factory: [\"@foo.factory\", <caret>foo ]\n" , "Foo\\Name\\FooClass::foo" ); assertNavigationContains(YAMLFileType.YML, "services:\n" + " foo.factory:\n" + " class: Foo\\Name\\FooClass\n" + " foo.manager:\n" + " factory: [@foo.factory, <caret>foo ]\n" , "Foo\\Name\\FooClass::foo" ); assertNavigationContains(YAMLFileType.YML, "services:\n" + " foo.factory:\n" + " class: Foo\\Name\\FooClass\n" + " foo.manager:\n" + " factory: ['@foo.factory', <caret>foo ]\n" , "Foo\\Name\\FooClass::foo" ); }
Example #24
Source File: YamlCompletionContributorTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testThatMethodOfEventTagsAreCompleted() { assertCompletionContains(YAMLFileType.YML, "" + "services:\n" + " foobar:\n" + " class: Foo\\Bar\n" + " tags:\n" + " - { method: <caret> }\n", "setBar" ); assertCompletionContains(YAMLFileType.YML, "" + "services:\n" + " Foo\\Bar:\n" + " tags:\n" + " - { method: <caret> }\n", "setBar" ); }
Example #25
Source File: YamlCompletionContributorTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testCompletionForServiceKeyAsClass() { myFixture.configureByText(PhpFileType.INSTANCE, "<?php\n" + "namespace Foobar\n" + "{\n" + " class Bar {}\n" + "}\n" ); assertCompletionContains(YAMLFileType.YML, "" + "services:\n" + " Foo\\<caret>: ~\n", "Foo\\Bar" ); assertCompletionContains(YAMLFileType.YML, "" + "services:\n" + " <caret>: ~\n", "Bar" ); }
Example #26
Source File: ServiceLineMarkerProviderTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testYamlServiceLineMarkerForClassName() { myFixture.configureByText(YAMLFileType.YML, "services:\n" + " Service\\YamlBar: ~\n" ); assertLineMarker(PhpPsiElementFactory.createPsiFileFromText(getProject(), "<?php\n" + "namespace Service{\n" + " class YamlBar{}\n" + "}" ), new LineMarker.TargetAcceptsPattern("Navigate to definition", PlatformPatterns.psiElement(YAMLKeyValue.class).with(new PatternCondition<YAMLKeyValue>("KeyText") { @Override public boolean accepts(@NotNull YAMLKeyValue yamlKeyValue, ProcessingContext processingContext) { return yamlKeyValue.getKeyText().equals("Service\\YamlBar"); } }))); }
Example #27
Source File: YamlDicCompletionContributorTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testClassesCompletion() { assertCompletionContains(YAMLFileType.YML, "services:\n" + " espend_container_service.yaml:\n" + " class: <caret>\n" , "FooClass" ); /* todo: contains check; char switch expected "(" "[" assertCompletionLookupTailEquals(YAMLFileType.YML, "services:\n" + " espend_container_service.yaml:\n" + " class: <caret>\n" , "FooClass", " (Foo\\Name)" ); */ assertCompletionContains(YAMLFileType.YML, "services:\n" + " newsletter_manager:\n" + " factory_class: <caret>\n" , "FooClass" ); }
Example #28
Source File: YamlHelperLightTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testGetTaggedServices() { PsiFile psiFile = myFixture.configureByText(YAMLFileType.YML, "" + "services:\n" + " foobar:\n" + " class: ClassName\\Foo\n" + " tags:\n" + " - { name: crossHint.test_222 }\n" + " foobar2:\n" + " class: ClassName\\Foo\n" + " tags: [ 'test.11' ]\n" ); Collection<YAMLKeyValue> taggedServices1 = YamlHelper.getTaggedServices((YAMLFile) psiFile, "crossHint.test_222"); assertTrue(taggedServices1.stream().anyMatch(yamlKeyValue -> "foobar".equals(yamlKeyValue.getKey().getText()))); Collection<YAMLKeyValue> taggedServices2 = YamlHelper.getTaggedServices((YAMLFile) psiFile, "test.11"); assertTrue(taggedServices2.stream().anyMatch(yamlKeyValue -> "foobar2".equals(yamlKeyValue.getKey().getText()))); }
Example #29
Source File: YamlCompletionContributorTest.java From idea-php-symfony2-plugin with MIT License | 6 votes |
public void testKeywordsCompletionInsideArray() { assertCompletionContains(YAMLFileType.YML, "" + "root:\n" + " key: [<caret>]\n", "true", ".inf" ); assertCompletionContains(YAMLFileType.YML, "" + "root:\n" + " key: [FOO, <caret>]\n", "true", ".inf" ); assertCompletionContains(YAMLFileType.YML, "" + "root:\n" + " key: [FOO, tr<caret>]\n", "true" ); }
Example #30
Source File: TaggedParameterGotoCompletionRegistrarTest.java From idea-php-symfony2-plugin with MIT License | 5 votes |
public void testThatYamlTaggedParameterProvidesNavigation() { assertNavigationMatch( YAMLFileType.YML, "arguments: [!tagged foo<caret>bar]", PlatformPatterns.psiElement() ); }