com.intellij.ide.highlighter.XmlFileType Java Examples

The following examples show how to use com.intellij.ide.highlighter.XmlFileType. 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: CaseSensitivityServiceInspection.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@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 #2
Source File: IdeaUtils.java    From camel-idea-plugin with Apache License 2.0 6 votes vote down vote up
public void iterateXmlDocumentRoots(Module module, Consumer<XmlTag> rootTag) {
    final GlobalSearchScope moduleScope = module.getModuleContentScope();
    final GlobalSearchScope xmlFiles = GlobalSearchScope.getScopeRestrictedByFileTypes(moduleScope, XmlFileType.INSTANCE);

    ModuleFileIndex fileIndex = ModuleRootManager.getInstance(module).getFileIndex();
    fileIndex.iterateContent(f -> {
        if (xmlFiles.contains(f)) {
            PsiFile file = PsiManager.getInstance(module.getProject()).findFile(f);
            if (file instanceof XmlFile) {
                XmlFile xmlFile = (XmlFile) file;
                XmlTag root = xmlFile.getRootTag();
                if (root != null) {
                    rootTag.accept(xmlFile.getRootTag());
                }
            }
        }
        return true;
    });
}
 
Example #3
Source File: XmlHelperTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * @see XmlHelper#visitServiceCallArgumentMethodIndex
 */
public void testVisitServiceCallArgumentParameter() {
    myFixture.configureByText(XmlFileType.INSTANCE, "" +
        "<service class=\"Foo\\Bar\">\n" +
        "   <call method=\"setBar\">\n" +
        "      <argument/>\n" +
        "      <argument type=\"service\" id=\"ma<caret>iler\" />\n" +
        "   </call>\n" +
        "</service>"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    PsiElement parent = psiElement.getParent();

    Collection<Parameter> results = new ArrayList<>();

    XmlHelper.visitServiceCallArgumentMethodIndex((XmlAttributeValue) parent, results::add);

    assertNotNull(
        ContainerUtil.find(results, parameter -> "arg2".equals(parameter.getName()))
    );
}
 
Example #4
Source File: XmlHelperTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * @see XmlHelper#getServiceDefinitionClass
 */
public void testGetServiceDefinitionClass() {
    myFixture.configureByText(XmlFileType.INSTANCE, "" +
        "<service class=\"Foo\\Bar\">\n" +
        "      <tag type=\"service\" method=\"ma<caret>iler\" />\n" +
        "</service>"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    assertEquals("Foo\\Bar", XmlHelper.getServiceDefinitionClass(psiElement));

    myFixture.configureByText(XmlFileType.INSTANCE, "" +
        "<service id=\"Foo\\Bar\">\n" +
        "      <tag type=\"service\" method=\"ma<caret>iler\" />\n" +
        "</service>"
    );

    psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    assertEquals("Foo\\Bar", XmlHelper.getServiceDefinitionClass(psiElement));
}
 
Example #5
Source File: XmlHelperTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * @see XmlHelper#visitServiceCallArgumentMethodIndex
 */
public void testVisitServiceCallArgument() {
    myFixture.configureByText(XmlFileType.INSTANCE, "" +
        "<service class=\"Foo\\Bar\">\n" +
        "   <call method=\"setBar\">\n" +
        "      <argument/>\n" +
        "      <argument type=\"service\" id=\"ma<caret>iler\" />\n" +
        "   </call>\n" +
        "</service>"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    PsiElement parent = psiElement.getParent();

    Collection<String> results = new ArrayList<>();

    XmlHelper.visitServiceCallArgument((XmlAttributeValue) parent, visitor ->
        results.add(visitor.getClassName() + ":" + visitor.getMethod() + ":" + visitor.getParameterIndex())
    );

    assertContainsElements(results, "Foo\\Bar:setBar:1");
}
 
Example #6
Source File: XmlHelperTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * @see XmlHelper#getArgumentIndex
 */
public void testGetArgumentIndexOnIndex() {
    myFixture.configureByText(XmlFileType.INSTANCE, "" +
        "<service class=\"Foo\\Bar\">\n" +
        "      <argum<caret>ent index=\"2\" />\n" +
        "</service>"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    assertEquals(2, XmlHelper.getArgumentIndex((XmlTag) psiElement.getParent()));

    myFixture.configureByText(XmlFileType.INSTANCE, "" +
        "<service class=\"Foo\\Bar\">\n" +
        "      <argum<caret>ent index=\"foobar\" />\n" +
        "</service>"
    );

    psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    assertEquals(-1, XmlHelper.getArgumentIndex((XmlTag) psiElement.getParent()));
}
 
Example #7
Source File: XmlGotoCompletionRegistrarTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void testIdInsideServiceTagShouldCompleteWithClassName() {
    assertCompletionContains(
        XmlFileType.INSTANCE,
        "<services><service id=\"<caret>\" class=\"MyFoo\\Foo\\Apple\"/></services>",
        "my_foo.foo.apple"
    );

    assertCompletionNotContains(
        XmlFileType.INSTANCE,
        "<service id=\"<caret>\" class=\"MyFoo\\Foo\\Apple\"/>",
        "my_foo.foo.apple"
    );

    assertCompletionNotContains(
        XmlFileType.INSTANCE,
        "<service id=\"<caret>\"/>",
        "my_foo.foo.apple"
    );
}
 
Example #8
Source File: XmlGotoCompletionRegistrarTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void testThatDecoratesServiceTagProvidesReferences() {
    assertCompletionContains(XmlFileType.INSTANCE, "" +
            "<?xml version=\"1.0\"?>\n" +
            "<container>\n" +
            "    <services>\n" +
            "        <service class=\"Foo\\Foobar\" decorates=\"<caret>\"/>\n" +
            "    </services>\n" +
            "</container>\n",
        "service_container"
    );

    assertNavigationMatch(XmlFileType.INSTANCE, "" +
            "<?xml version=\"1.0\"?>\n" +
            "<container>\n" +
            "    <services>\n" +
            "        <service class=\"Foo\\Foobar\" decorates=\"foo.bar_<caret>factory\"/>\n" +
            "    </services>\n" +
            "</container>\n",
        PlatformPatterns.psiElement(PhpClass.class)
    );
}
 
Example #9
Source File: XmlGotoCompletionRegistrarTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void testThatTemplateInsideRouteDefaultKeyCompletedAndNavigable() {
    if(System.getenv("PHPSTORM_ENV") != null) return;

    try {
        myFixture.addFileToProject("app/Resources/views/foo.html.twig", "");
    } catch (Exception e) {
        e.printStackTrace();
    }

    assertCompletionContains(XmlFileType.INSTANCE, "" +
            "    <route id=\"root\" path=\"/wp-admin\">\n" +
            "        <default key=\"template\"><caret></default>\n" +
            "    </route>",
        "foo.html.twig"
    );

    assertNavigationMatch(XmlFileType.INSTANCE, "" +
        "    <route id=\"root\" path=\"/wp-admin\">\n" +
        "        <default key=\"template\">foo.ht<caret>ml.twig</default>\n" +
        "    </route>"
    );
}
 
Example #10
Source File: ServiceLineMarkerProviderTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void testXmlServiceLineMarkerForClassName() {
    myFixture.configureByText(XmlFileType.INSTANCE,
        "<container>\n" +
            "  <services>\n" +
            "      <service id=\"Service\\Bar\"/>\n" +
            "  </services>\n" +
            "</container>"
    );

    assertLineMarker(PhpPsiElementFactory.createPsiFileFromText(getProject(), "<?php\n" +
        "namespace Service{\n" +
        "    class Bar{}\n" +
        "}"
    ), new LineMarker.ToolTipEqualsAssert("Navigate to definition"));

    assertLineMarker(PhpPsiElementFactory.createPsiFileFromText(getProject(), "<?php\n" +
        "namespace Service{\n" +
        "    class Bar{}\n" +
        "}"
    ), new LineMarker.TargetAcceptsPattern("Navigate to definition", XmlPatterns.xmlTag().withName("service").withAttributeValue("id", "Service\\Bar")));
}
 
Example #11
Source File: ServiceUtil.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * 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 #12
Source File: XmlServiceArgumentIntention.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@Override
public boolean isAvailable(@NotNull Project project, Editor editor, @NotNull PsiElement psiElement) {

    if(psiElement.getContainingFile().getFileType() != XmlFileType.INSTANCE || !Symfony2ProjectComponent.isEnabled(psiElement.getProject())) {
        return false;
    }

    XmlTag serviceTagValid = getServiceTagValid(psiElement);
    if(serviceTagValid == null) {
        return false;
    }

    if(!ServiceActionUtil.isValidXmlParameterInspectionService(serviceTagValid)) {
        return false;
    }

    return ServiceActionUtil.getXmlMissingArgumentTypes(serviceTagValid, true, new ContainerCollectionResolver.LazyServiceCollector(project)).size() > 0;
}
 
Example #13
Source File: ServiceLineMarkerProviderTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void testDoctrineRepositoryDefinitionLineMarker() {
    myFixture.configureByText(XmlFileType.INSTANCE, "" +
            "<doctrine-mapping>\n" +
            "    <document name=\"Foo\" repository-class=\"Entity\\Bar\"/>\n" +
            "</doctrine-mapping>"
    );

    myFixture.configureByText(PhpFileType.INSTANCE, "<?php\n" +
            "namespace Entity{\n" +
            "    class Bar{}\n" +
            "}"
    );

    assertLineMarker(PhpPsiElementFactory.createPsiFileFromText(getProject(), "<?php\n" +
            "namespace Entity{\n" +
            "    class Bar{}\n" +
            "}"
    ), new LineMarker.ToolTipEqualsAssert("Navigate to metadata"));
}
 
Example #14
Source File: DoctrineXmlCompletionContributorTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void testDocumentNameCompletion() {
    assertCompletionContains(
        XmlFileType.INSTANCE,
        "<doctrine-mapping><document name=\"<caret>\"/></doctrine-mapping>",
        "MyDateTime"
    );

    assertCompletionContains(
        XmlFileType.INSTANCE,
        "<doctrine-mongo-mapping><document name=\"<caret>\"/></doctrine-mongo-mapping>",
        "MyDateTime"
    );

    assertCompletionContains(
        XmlFileType.INSTANCE,
        "<doctrine-foo-mapping><document name=\"<caret>\"/></doctrine-foo-mapping>",
        "MyDateTime"
    );
}
 
Example #15
Source File: XLFFileTypeListener.java    From idea-php-typo3-plugin with MIT License 6 votes vote down vote up
@Override
public void projectOpened(@NotNull Project project) {
    if (!(FileTypeManager.getInstance().getFileTypeByExtension("xlf") instanceof XmlFileType)) {
        WriteCommandAction.runWriteCommandAction(ProjectManager.getInstance().getOpenProjects()[0], () -> {
            FileTypeManager.getInstance().associateExtension(XmlFileType.INSTANCE, "xlf");

            ApplicationManager.getApplication().invokeLater(() -> {
                Notification notification = GROUP_DISPLAY_ID_INFO.createNotification(
                    "TYPO3 CMS Plugin",
                    "XLF File Type Association",
                    "The XLF File Type was re-assigned to XML to prevent errors with the XLIFF Plugin and allow autocompletion. Please re-index your projects.",
                    NotificationType.INFORMATION
                );
                Project[] projects = ProjectManager.getInstance().getOpenProjects();
                Notifications.Bus.notify(notification, projects[0]);
            });
        });
    }
}
 
Example #16
Source File: DoctrineXmlGotoCompletionRegistrarTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * @see DoctrineMetadataPattern#getXmlTargetDocumentClass()
 */
public void testTargetDocumentNavigation() {
    for(String s : new String[] {"reference-one", "reference-many", "embed-many", "embed-one"}) {
        assertNavigationMatch(
            XmlFileType.INSTANCE,
            "<doctrine-mapping><document><" + s + " target-document=\"Foo\\Bar\\Ns<caret>\\BarRepo\"/></document></doctrine-mapping>",
            PlatformPatterns.psiElement(PhpClass.class)
        );

        assertNavigationMatch(
            XmlFileType.INSTANCE,
            "<doctrine-foo-mapping><document><" + s + " target-document=\"Foo\\Bar\\Ns<caret>\\BarRepo\"/></document></doctrine-foo-mapping>",
            PlatformPatterns.psiElement(PhpClass.class)
        );

        assertNavigationMatch(
            XmlFileType.INSTANCE,
            "<doctrine-foo-mapping><document name=\"Foo\\Bar\\Ns\\Foo\"><" + s + " target-document=\"Foo\\Bar\\Ns<caret>\\BarRepo\"/></document></doctrine-foo-mapping>",
            PlatformPatterns.psiElement(PhpClass.class)
        );
    }
}
 
Example #17
Source File: XmlGotoCompletionRegistrarTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testThatServiceFactoryMethodAttributeProvidesCompletion() {
    assertCompletionContains(XmlFileType.INSTANCE, "" +
            "<?xml version=\"1.0\"?>\n" +
            "<container>\n" +
            "    <services>\n" +
            "        <service>\n" +
            "            <factory service=\"foo.bar_factory\" method=\"<caret>\"/>\n" +
            "        </service>\n" +
            "    </services>\n" +
            "</container>\n",
        "create"
    );
}
 
Example #18
Source File: TaggedParameterGotoCompletionRegistrarTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testThatXmlTaggedParameterProvidesCompletion() {
    assertCompletionContains(
        XmlFileType.INSTANCE,
        "<services>\n" +
            "    <service>\n" +
            "        <argument type=\"tagged\" tag=\"<caret>\" />\n" +
            "    </service>\n" +
            "</services>",
        "foobar"
    );
}
 
Example #19
Source File: TaggedParameterGotoCompletionRegistrarTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testThatXmlTaggedParameterProvidesNavigation() {
    assertNavigationMatch(
        XmlFileType.INSTANCE,
        "<services>\n" +
            "    <service>\n" +
            "        <argument type=\"tagged\" tag=\"foo<caret>bar\" />\n" +
            "    </service>\n" +
            "</services>",
        PlatformPatterns.psiElement()
    );
}
 
Example #20
Source File: XmlConstructServiceSuggestionCollectorTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testServiceSuggestionForCallArguments() {
    assertCompletionLookupContainsPresentableItem(XmlFileType.INSTANCE, "" +
            "<services>" +
            "  <service class=\"Foo\\Bar\\Car\">\n" +
            "    <argument type=\"service\" id=\"<caret>\" />\n" +
            "  </service>" +
            "</services>",
        lookupElement -> "foo_bar_apple".equals(lookupElement.getItemText()) && lookupElement.isItemTextBold()
    );

    assertCompletionLookupContainsPresentableItem(XmlFileType.INSTANCE, "" +
            "<services>" +
            "  <service class=\"Foo\\Bar\\Car\">\n" +
            "    <argument/>\n" +
            "    <argument type=\"service\" id=\"<caret>\" />\n" +
            "  </service>" +
            "</services>",
        lookupElement -> "foo_bar_car".equals(lookupElement.getItemText()) && lookupElement.isItemTextBold()
    );

    assertCompletionLookupContainsPresentableItem(XmlFileType.INSTANCE, "" +
            "<services>" +
            "  <service id=\"Foo\\Bar\\Car\">\n" +
            "    <argument type=\"service\" id=\"<caret>\" />\n" +
            "  </service>" +
            "</services>",
        lookupElement -> "foo_bar_apple".equals(lookupElement.getItemText()) && lookupElement.isItemTextBold()
    );
}
 
Example #21
Source File: XmlReferenceContributorTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testThatFactoryClassAttributeProvidesReference() {
    assertReferenceMatchOnParent(XmlFileType.INSTANCE, "" +
            "<?xml version=\"1.0\"?>\n" +
            "<container>\n" +
            "    <services>\n" +
            "        <service>\n" +
            "            <factory class=\"Foo\\<caret>Bar\" method=\"create\"/>\n" +
            "        </service>\n" +
            "    </services>\n" +
            "</container>\n",
        PlatformPatterns.psiElement(PhpClass.class).withName("Bar")
    );
}
 
Example #22
Source File: XmlDicCompletionContributorTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testServiceCompletionOfFactoryService() {
    assertCompletionContains(XmlFileType.INSTANCE, "" +
            "<services>\n" +
            "    <service>\n" +
            "        <factory service=\"<caret>\" />\n" +
            "    </service>\n" +
            "</services>",
        "foo_bar_apple"
    );
}
 
Example #23
Source File: XmlReferenceContributorTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testThatAutowiringTypeReferenceToPhpClass() {
    assertReferenceMatch(XmlFileType.INSTANCE, "" +
        "<?xml version=\"1.0\"?>\n" +
        "<container>\n" +
        "    <services>\n" +
        "        <service>\n" +
        "            <autowiring-type>Foo<caret>\\Bar</autowiring-type>\n" +
        "        </service>\n" +
        "    </services>\n" +
        "</container>\n",
        PlatformPatterns.psiElement(PhpClass.class).withName("Bar")
    );
}
 
Example #24
Source File: XmlDicCompletionContributorTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testServiceInstanceHighlightCompletion() {
    assertCompletionLookupContainsPresentableItem(XmlFileType.INSTANCE, "" +
            "<services>" +
            "   <service class=\"Foo\\Bar\\Car\">" +
            "       <argument type=\"service\" id=\"<caret>\"/>" +
            "   </service>" +
            "</services>",
        lookupElement -> "foo_bar_apple".equals(lookupElement.getItemText()) && lookupElement.isItemTextBold() && lookupElement.isItemTextUnderlined()
    );
}
 
Example #25
Source File: XmlReferenceContributorTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testEnvironmentParameter() {
    // skip for 2019.x build
    // reference XmlText:null was created for XmlToken:XML_DATA_CHARACTERS but target XmlText, provider
    if(true) {
        return;
    }

    assertReferenceMatch(XmlFileType.INSTANCE, "" +
            "<?xml version=\"1.0\"?>\n" +
            "<container>\n" +
            "    <services>\n" +
            "        <service>\n" +
            "            <argument>%env(FOOB<caret>AR_ENV)%</argument>\n" +
            "        </service>\n" +
            "    </services>\n" +
            "</container>\n",
        PlatformPatterns.psiElement()
    );

    assertReferenceMatch(XmlFileType.INSTANCE, "" +
            "<?xml version=\"1.0\"?>\n" +
            "<container>\n" +
            "    <services>\n" +
            "        <service>\n" +
            "            <argument>%env(int:FOOB<caret>AR_ENV)%</argument>\n" +
            "        </service>\n" +
            "    </services>\n" +
            "</container>\n",
        PlatformPatterns.psiElement()
    );
}
 
Example #26
Source File: DoctrineXmlGotoCompletionRegistrarTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testEmbeddedNameNavigation() {
    assertNavigationMatch(
        XmlFileType.INSTANCE,
        "<doctrine-mapping><embedded name=\"Foo\\Bar\\Ns<caret>\\Bar\"/></doctrine-mapping>",
        PlatformPatterns.psiElement(PhpClass.class)
    );
}
 
Example #27
Source File: TranslationInsertUtilTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testInsertTranslationForXlf20() {
    PsiFile xmlFile = PsiFileFactory.getInstance(getProject()).createFileFromText("foo.xml", XmlFileType.INSTANCE, "" +
        "<?xml version=\"1.0\"?>\n" +
        "<xliff xmlns=\"urn:oasis:names:tc:xliff:document:2.0\"\n" +
        "       version=\"2.0\" srcLang=\"en-US\" trgLang=\"ja-JP\">\n" +
        "    <file id=\"f1\" original=\"Graphic Example.psd\">\n" +
        "        <skeleton href=\"Graphic Example.psd.skl\"/>\n" +
        "        <group id=\"1\">\n" +
        "            <unit id=\"1\">\n" +
        "                <segment>\n" +
        "                    <source>foo</source>\n" +
        "                </segment>\n" +
        "            </unit>\n" +
        "            <unit id=\"foobar\">\n" +
        "                <segment>\n" +
        "                    <source>foo</source>\n" +
        "                </segment>\n" +
        "            </unit>\n" +
        "        </group>\n" +
        "    </file>\n" +
        "</xliff>"
    );

    CommandProcessor.getInstance().executeCommand(getProject(), () -> ApplicationManager.getApplication().runWriteAction(() -> {
        TranslationInsertUtil.invokeTranslation((XmlFile) xmlFile, "foobar", "value");
    }), null, null);

    String text = xmlFile.getText();

    assertTrue(text.contains("<unit id=\"2\">"));
    assertTrue(text.contains("<source>foobar</source>"));
    assertTrue(text.contains("<target>value</target>"));
}
 
Example #28
Source File: XmlHelperTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
/**
 * @see XmlHelper#getArgumentIndex
 */
public void testGetArgumentIndexCallOnNamedArgument() {
    myFixture.configureByText(XmlFileType.INSTANCE, "" +
        "<service class=\"Foo\\Bar\">\n" +
        "   <call method=\"setBar\">\n" +
        "       <arg<caret>ument type=\"service\" key=\"$arg2\" id=\"args_bar\"/>\n" +
        "   </call>\n" +
        "</service>"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    assertEquals(1, XmlHelper.getArgumentIndex((XmlTag) psiElement.getParent()));
}
 
Example #29
Source File: XmlGotoCompletionRegistrarTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testThatDecoratesPrioritizeLookupElementOnInstance() {
    assertCompletionLookupContainsPresentableItem(XmlFileType.INSTANCE, "" +
            "<?xml version=\"1.0\"?>\n" +
            "<container>\n" +
            "    <services>\n" +
            "        <service class=\"Foo\\Foobar\" decorates=\"<caret>\"/>\n" +
            "    </services>\n" +
            "</container>\n",
        lookupElement -> "foo.bar_factory".equals(lookupElement.getItemText()) && lookupElement.isItemTextBold() && lookupElement.isItemTextBold()
    );
}
 
Example #30
Source File: XmlHelperTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
/**
 * @see XmlHelper#getArgumentIndex
 */
public void testGetArgumentIndexOnArgumentCount() {
    myFixture.configureByText(XmlFileType.INSTANCE, "" +
        "<service class=\"Foo\\Bar\">\n" +
        "      <argument/>\n" +
        "      <argument index=\"\"/>\n" +
        "      <argument key=\"\"/>\n" +
        "      <argum<caret>ent/>\n" +
        "</service>"
    );

    PsiElement psiElement = myFixture.getFile().findElementAt(myFixture.getCaretOffset());
    assertEquals(1, XmlHelper.getArgumentIndex((XmlTag) psiElement.getParent()));
}