com.intellij.patterns.XmlPatterns Java Examples

The following examples show how to use com.intellij.patterns.XmlPatterns. 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: DoctrineMetadataPattern.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * <doctrine-mapping|doctrine-*-mapping>
 *   <document><field name="Foo"/></document>
 *   <document><id name="Foo"/></document>
 * </doctrine-mapping>
 */
public static XmlAttributeValuePattern getFieldName() {
    return XmlPatterns
        .xmlAttributeValue()
        .withParent(XmlPatterns
            .xmlAttribute("name")
            .withParent(XmlPatterns
                .xmlTag().withName(XmlPatterns.string().oneOf("field", "id"))
                .withParent(
                    XmlPatterns.xmlTag().withName(XmlPatterns.string().oneOf("entity", "document", "embedded-document", "embedded")).withParent(
                        XmlPatterns.xmlTag().withName(PlatformPatterns.string().matches(DOCTRINE_MAPPING))
                    )
                )
            )
        );
}
 
Example #2
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 #3
Source File: ServiceLineMarkerProviderTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
public void testXmlServiceLineMarker() {
    myFixture.configureByText(XmlFileType.INSTANCE,
        "<container>\n" +
        "  <services>\n" +
        "      <service class=\"Service\\Bar\" 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 #4
Source File: DoctrineDbalQbGotoCompletionRegistrarTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * @see fr.adrienbrault.idea.symfony2plugin.doctrine.querybuilder.dbal.DoctrineDbalQbGotoCompletionRegistrar
 */
public void testDBALConnectionFieldArrayNavigation() {
    for (String s : new String[]{"insert", "update"}) {
        assertNavigationMatch(PhpFileType.INSTANCE, "<?php" +
                "/** @var $foo \\Doctrine\\DBAL\\Connection */\n" +
                "$foo->" + s + "('cms_users', ['name<caret>']);",
            XmlPatterns.xmlTag().withName("field")
        );

        assertNavigationMatch(PhpFileType.INSTANCE, "<?php" +
                "/** @var $foo \\Doctrine\\DBAL\\Connection */\n" +
                "$foo->" + s + "('cms_users', ['' => '', 'user_email<caret>' => '']);",
            XmlPatterns.xmlTag().withName("field")
        );
    }
}
 
Example #5
Source File: XmlReferenceContributor.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@NotNull
@Override
public PsiReference[] getReferencesByElement(@NotNull PsiElement psiElement, @NotNull ProcessingContext context) {

    if(!Symfony2ProjectComponent.isEnabled(psiElement)) {
        return new PsiReference[0];
    }

    // check for valid xml file and services container
    if(!XmlPatterns.psiElement().inside(XmlHelper.getInsideTagPattern("services")).inFile(XmlHelper.getXmlFilePattern()).accepts(psiElement)) {
        return new PsiReference[0];
    }

    String serviceDefinitionClass = XmlHelper.getServiceDefinitionClass(psiElement);
    if(serviceDefinitionClass == null) {
        return new PsiReference[0];
    }

    return new PsiReference[] { new ClassPublicMethodReference(psiElement, serviceDefinitionClass)};
}
 
Example #6
Source File: DoctrineMetadataPattern.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * <doctrine-mapping|doctrine-*-mapping>
 *   <document><embed-one field="Foo"/></document>
 * </doctrine-mapping>
 */
public static XmlAttributeValuePattern getFieldNameRelation() {
    return XmlPatterns
        .xmlAttributeValue()
        .withParent(XmlPatterns
            .xmlAttribute("field")
            .withParent(XmlPatterns
                .xmlTag().withName(XmlPatterns.string().oneOf("embed-one", "embed-many", "reference-one", "reference-many", "one-to-one", "one-to-many", "many-to-one", "many-to-many"))
                .withParent(
                    XmlPatterns.xmlTag().withName(XmlPatterns.string().oneOf("entity", "document", "embedded-document", "embedded")).withParent(
                        XmlPatterns.xmlTag().withName(PlatformPatterns.string().matches(DOCTRINE_MAPPING))
                    )
                )
            )
        );
}
 
Example #7
Source File: DoctrineMetadataPattern.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * <doctrine-mapping|doctrine-*-mapping>
 *   <field type="Class\Name"/>
 * </doctrine-mapping>
 */
public static XmlAttributeValuePattern getFieldType() {
    return XmlPatterns
        .xmlAttributeValue()
        .withParent(XmlPatterns
            .xmlAttribute("type")
            .withParent(XmlPatterns
                .xmlTag().withName("field")
                .withParent(
                    XmlPatterns.xmlTag().withName(XmlPatterns.string().oneOf("entity", "document", "embedded-document", "embedded")).withParent(
                        XmlPatterns.xmlTag().withName(PlatformPatterns.string().matches(DOCTRINE_MAPPING))
                    )
                )
            )
        );
}
 
Example #8
Source File: DoctrineMetadataPattern.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * <one-to-one target-entity="Foo">
 * <one-to-many target-entity="Foo">
 * <many-to-one target-entity="Foo">
 * <many-to-many target-entity="Foo">
 */
public static XmlAttributeValuePattern getXmlTargetEntityClass() {
    return XmlPatterns
        .xmlAttributeValue()
        .withParent(XmlPatterns
            .xmlAttribute("target-entity")
            .withParent(XmlPatterns
                .xmlTag().withName(PlatformPatterns.string().oneOf("one-to-one", "one-to-many", "many-to-one", "many-to-many"))
                .withParent(
                    XmlPatterns.xmlTag().withName("entity").withParent(
                        XmlPatterns.xmlTag().withName(PlatformPatterns.string().matches(DOCTRINE_MAPPING))
                    )
                )
            )
        );
}
 
Example #9
Source File: DoctrineMetadataPattern.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * <reference-one target-document="Foo"/>
 * <reference-many target-document="Foo"/>
 * <embed-many target-document="Foo"/>
 * <embed-one target-document="Foo"/>
 */
public static XmlAttributeValuePattern getXmlTargetDocumentClass() {
    return XmlPatterns
        .xmlAttributeValue()
        .withParent(XmlPatterns
            .xmlAttribute("target-document")
            .withParent(XmlPatterns
                .xmlTag().withName(PlatformPatterns.string().oneOf("reference-one", "reference-many", "embed-many", "embed-one"))
                .withParent(
                    XmlPatterns.xmlTag().withName(XmlPatterns.string().oneOf("embedded-document", "embedded", "document")).withParent(
                        XmlPatterns.xmlTag().withName(PlatformPatterns.string().matches(DOCTRINE_MAPPING))
                    )
                )
            )
        );
}
 
Example #10
Source File: XmlHaxelibCompletionContributor.java    From intellij-haxe with Apache License 2.0 6 votes vote down vote up
public XmlHaxelibCompletionContributor() {
  HaxelibCache haxelibCache = HaxelibCache.getInstance();
  availableHaxelibs = haxelibCache.getAvailableHaxelibs();
  localHaxelibs = haxelibCache.getLocalHaxelibs();

  extend(CompletionType.BASIC, PlatformPatterns.psiElement().inside(
    XmlPatterns.xmlAttributeValue().withParent(XmlPatterns.xmlAttribute("name"))
      .withSuperParent(2, XmlPatterns.xmlTag().withName("haxelib")).withLanguage(XMLLanguage.INSTANCE)),
         new CompletionProvider<CompletionParameters>() {
           @Override
           protected void addCompletions(@NotNull CompletionParameters parameters,
                                         ProcessingContext context,
                                         @NotNull CompletionResultSet result) {
             for (int i = 0; i < availableHaxelibs.size(); i++) {
               result.addElement(LookupElementBuilder.create(availableHaxelibs.get(i))
                                   .withTailText(" available at haxelib", true));
             }

             for (int i = 0; i < localHaxelibs.size(); i++) {
               result.addElement(LookupElementBuilder.create(localHaxelibs.get(i))
                                   .withTailText(" installed", true));
             }
           }
         });
}
 
Example #11
Source File: DoctrineMetadataPattern.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public static XmlAttributeValuePattern getEmbeddableNameClassPattern() {
    return XmlPatterns
        .xmlAttributeValue()
        .withParent(XmlPatterns
            .xmlAttribute("name")
            .withParent(XmlPatterns
                .xmlTag().withName("embeddable")
                .withParent(XmlPatterns
                    .xmlTag().withName(PlatformPatterns.string().matches(DOCTRINE_MAPPING))
                )
            )
        );
}
 
Example #12
Source File: FlexFormCompletionContributionProvider.java    From idea-php-typo3-plugin with MIT License 5 votes vote down vote up
@NotNull
private static PsiElementPattern.Capture<PsiElement> parentWithName(@NotNull String parentTag, @NotNull String... names) {
    return XmlPatterns
        .psiElement(XmlTokenType.XML_DATA_CHARACTERS)
        .withParent(
            XmlPatterns.xmlText().withParent(
                XmlPatterns.xmlTag().withName(XmlPatterns.string().oneOf(names))
            )
        ).inside(XmlPatterns.xmlTag().withName(parentTag));
}
 
Example #13
Source File: ServiceLineMarkerProviderTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testThatResourceProvidesLineMarker() {
    myFixture.copyFileToProject("BundleScopeLineMarkerProvider.php");

    Collection<String[]> providers = new ArrayList<String[]>() {{
        add(new String[] {"@FooBundle/foo.php"});
        add(new String[] {"@FooBundle"});
        add(new String[] {"@FooBundle/"});
    }};

    for (String[] provider : providers) {
        myFixture.configureByText(
            XmlFileType.INSTANCE,
           String.format("<routes><import resource=\"%s\" /></routes>", provider[0] )
        );

        PsiFile psiFile = myFixture.configureByText("foo.php", "");
        assertLineMarker(
            psiFile,
            new LineMarker.ToolTipEqualsAssert("Navigate to resource")
        );

        assertLineMarker(
            psiFile,
            new LineMarker.TargetAcceptsPattern("Navigate to resource", XmlPatterns.xmlTag().withName("import").withAttributeValue("resource", provider[0]))
        );
    }
}
 
Example #14
Source File: XmlLineMarkerProviderTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testThatResourceProvidesLineMarkerLineMarker() {
    PsiFile psiFile = myFixture.configureByText("foo.xml", "<foo/>");
    assertLineMarker(
        psiFile,
        new LineMarker.ToolTipEqualsAssert("Navigate to resource")
    );

    assertLineMarker(
        psiFile,
        new LineMarker.TargetAcceptsPattern("Navigate to resource", XmlPatterns.xmlTag().withName("import").withAttributeValue("resource", "@FooBundle/foo.xml"))
    );
}
 
Example #15
Source File: YamlLineMarkerProviderTest.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public void testThatResourceProvidesLineMarkerLineMarker() {
    PsiFile psiFile = myFixture.configureByText("foo.yml", "");
    assertLineMarker(
        psiFile,
        new LineMarker.ToolTipEqualsAssert("Navigate to resource")
    );

    assertLineMarker(
        psiFile,
        new LineMarker.TargetAcceptsPattern("Navigate to resource", XmlPatterns.xmlTag().withName("import").withAttributeValue("resource", "@FooBundle/foo.yml"))
    );
}
 
Example #16
Source File: MuleConfigurationReferenceContributor.java    From mule-intellij-plugins with Apache License 2.0 5 votes vote down vote up
@Override
    public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
        registrar.registerReferenceProvider(
                XmlPatterns.xmlAttributeValue(MuleConfigConstants.NAME_ATTRIBUTE)
                        .withAncestor(2, XmlPatterns.xmlTag().withLocalName(MuleConfigConstants.FLOW_REF_TAG_NAME)
                        ),
                new FlowRefProvider());

//        registrar.registerReferenceProvider(
//                XmlPatterns.xmlAttributeValue(MuleConfigConstants.NAME_ATTRIBUTE)
//                        .withAncestor(2, XmlPatterns.xmlTag().withLocalName(MuleConfigConstants.FLOW_TAG_NAME)
//                        ),
//                new FlowProvider());

        registrar.registerReferenceProvider(
                XmlPatterns.xmlAttributeValue(MuleConfigConstants.NAME_ATTRIBUTE)
                        .withAncestor(2, XmlPatterns.xmlTag().withLocalName(MuleConfigConstants.FLOW_TAG_NAME)
                        ),
                new FlowRefProvider());
        registrar.registerReferenceProvider(
                XmlPatterns.xmlAttributeValue(MuleConfigConstants.NAME_ATTRIBUTE)
                        .withAncestor(2, XmlPatterns.xmlTag().withLocalName(MuleConfigConstants.SUB_FLOW_TAG_NAME)
                        ),
                new FlowRefProvider());

        registrar.registerReferenceProvider(
                XmlPatterns.xmlAttributeValue(MuleConfigConstants.CONFIG_REF_ATTRIBUTE),
                new ConfigRefProvider());
    }
 
Example #17
Source File: XmlCompletionContributor.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
public XmlCompletionContributor() {
    extend(CompletionType.BASIC, XmlHelper.getTagPattern("class").inside(XmlHelper.getInsideTagPattern("services")), new PhpClassAndParameterCompletionProvider());
    extend(CompletionType.BASIC, XmlHelper.getTagPattern("factory-service").inside(XmlHelper.getInsideTagPattern("services")), new ServiceCompletionProvider());
    extend(CompletionType.BASIC, XmlHelper.getTagPattern("factory-class").inside(XmlHelper.getInsideTagPattern("services")), new PhpClassAndParameterCompletionProvider());
    extend(CompletionType.BASIC, XmlHelper.getAutowiringTypePattern(), new PhpClassAndParameterCompletionProvider());
    extend(CompletionType.BASIC, XmlHelper.getTagPattern("parent").inside(XmlHelper.getInsideTagPattern("services")), new ServiceCompletionProvider());

    // <argument type="service" id="<caret>" />
    // <factory service="<caret>" />
    extend(CompletionType.BASIC, PlatformPatterns.psiElement().withParent(PlatformPatterns.or(
        XmlHelper.getArgumentServiceIdPattern(),
        XmlHelper.getFactoryServiceCompletionPattern(),
        XmlHelper.getArgumentServiceIdForArgumentPattern()
    )), new ServiceCompletionProvider());

    extend(CompletionType.BASIC, XmlHelper.getTagAttributePattern("tag", "alias").inside(XmlHelper.getInsideTagPattern("services")), new FormAliasParametersCompletionProvider());
    extend(CompletionType.BASIC, XmlHelper.getArgumentValuePattern(), new ArgumentParameterCompletionProvider());

    extend(
        CompletionType.BASIC,
        XmlPatterns.psiElement().withParent(XmlHelper.getImportResourcePattern()),
        new SymfonyBundleFileCompletionProvider("Resources/config", "Controller")
    );

    extend(
        CompletionType.BASIC,
        XmlPatterns.psiElement().withParent(XmlHelper.getImportResourcePattern()),
        new YamlCompletionContributor.DirectoryScopeCompletionProvider()
    );
}
 
Example #18
Source File: XmlLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
/**
 * <service id="%foo.class%"/>
 */
private static XmlTagPattern.Capture getServiceIdPattern() {
    return XmlPatterns.xmlTag().withName("service")
        .withChild(XmlPatterns.xmlAttribute().withName("id")).inside(
            XmlHelper.getInsideTagPattern("services")
        ).inFile(XmlHelper.getXmlFilePattern());
}
 
Example #19
Source File: TaggedParameterGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    // arguments: [!tagged twig.extension]
    // <argument type="tagged" tag="foobar" />
    registrar.register(
        PlatformPatterns.or(
            YamlElementPatternHelper.getTaggedServicePattern(),
            XmlPatterns.psiElement().withParent(XmlHelper.getTypeTaggedTagAttribute())
        ),
        new MyTagGotoCompletionContributor()
    );
}
 
Example #20
Source File: DoctrineXmlGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    registrar.register(XmlPatterns.psiElement().withParent(PlatformPatterns.or(
        DoctrineMetadataPattern.getXmlModelClass(),
        DoctrineMetadataPattern.getXmlRepositoryClass(),
        DoctrineMetadataPattern.getXmlTargetDocumentClass(),
        DoctrineMetadataPattern.getXmlTargetEntityClass(),
        DoctrineMetadataPattern.getEmbeddableNameClassPattern()
    )), ClassGotoCompletionProvider::new);
}
 
Example #21
Source File: XmlPatternUtil.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
/**
 * <controller>SwagBackendExample</controller>
 */
public static PsiElementPattern.Capture<PsiElement> getMenuControllerPattern() {
    return XmlPatterns
            .psiElement(XmlTokenType.XML_DATA_CHARACTERS)
            .withParent(XmlPatterns
                    .xmlText()
                    .withParent(XmlPatterns
                            .xmlTag()
                            .withName("controller")
                    )
            ).inside(XmlHelper.getInsideTagPattern("menu"));
}
 
Example #22
Source File: XmlPatternUtil.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
/**
 * <parent identifiedBy="controller">SwagBackendExample</parent>
 */
public static PsiElementPattern.Capture<PsiElement> getMenuControllerByParentPattern() {
    return XmlPatterns
        .psiElement(XmlTokenType.XML_DATA_CHARACTERS)
        .withParent(XmlPatterns
            .xmlText()
            .withParent(XmlPatterns
                .xmlTag()
                .withName("parent").withAttributeValue("identifiedBy", "controller")
            )
        ).inside(XmlHelper.getInsideTagPattern("menu"));
}
 
Example #23
Source File: XmlPatternUtil.java    From idea-php-shopware-plugin with MIT License 5 votes vote down vote up
/**
 * <action>SwagBackendExample</action>
 */
public static PsiElementPattern.Capture<PsiElement> getMenuControllerActionPattern() {
    return XmlPatterns
        .psiElement(XmlTokenType.XML_DATA_CHARACTERS)
        .withParent(XmlPatterns
            .xmlText()
            .withParent(XmlPatterns
                .xmlTag()
                .withName("action")
            )
        ).inside(XmlHelper.getInsideTagPattern("menu"));
}
 
Example #24
Source File: DoctrineMetadataPattern.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
/**
 * <doctrine-mapping|doctrine-*-mapping>
 *   <document repository-class="Class\Name"/>
 *   <entity repository-class="Class\Name"/>
 * </doctrine-mapping>
 */
public static XmlAttributeValuePattern getXmlRepositoryClass() {
    return XmlPatterns
        .xmlAttributeValue()
        .withParent(XmlPatterns
            .xmlAttribute("repository-class")
            .withParent(XmlPatterns
                .xmlTag().withName(PlatformPatterns.string().oneOf("document", "entity"))
                .withParent(XmlPatterns
                    .xmlTag().withName(PlatformPatterns.string().matches(DOCTRINE_MAPPING))
                )
            )
        );
}
 
Example #25
Source File: DoctrineMetadataPattern.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
/**
 * <doctrine-mapping|doctrine-*-mapping>
 *   <entity name="Class\Name"/>
 * </doctrine-mapping>
 *
 * <doctrine-mapping|doctrine-*-mapping>
 *   <document name="Class\Name"/>
 * </doctrine-mapping>
 */
public static XmlAttributeValuePattern getXmlModelClass() {
    return XmlPatterns
        .xmlAttributeValue()
        .withParent(XmlPatterns
            .xmlAttribute("name")
            .withParent(XmlPatterns
                .xmlTag().withName(PlatformPatterns.string().oneOf("document", "entity", "embedded-document", "embedded"))
                .withParent(XmlPatterns
                    .xmlTag().withName(PlatformPatterns.string().matches(DOCTRINE_MAPPING))
                )
            )
        );
}
 
Example #26
Source File: XmlLineMarkerProvider.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
public static XmlTagPattern.Capture getRouteTag() {
    return XmlPatterns.xmlTag().withName("route").withParent(
        XmlPatterns.xmlTag().withName("routes")
    ).inFile(XmlHelper.getXmlFilePattern());
}
 
Example #27
Source File: XmlGotoCompletionRegistrar.java    From idea-php-symfony2-plugin with MIT License 4 votes vote down vote up
@Override
public void register(@NotNull GotoCompletionRegistrarParameter registrar) {
    // <import resource="config_foo.xml"/>
    registrar.register(
        XmlPatterns.psiElement().withParent(XmlHelper.getImportResourcePattern()),
        ImportResourceGotoCompletionProvider::new
    );

    // <service id="<caret>" class="MyFoo\Foo\Apple"/>
    registrar.register(
        XmlPatterns.psiElement().withParent(XmlHelper.getServiceIdAttributePattern()),
        ServiceIdCompletionProvider::new
    );

    // <service alias="<caret>"/>
    registrar.register(
        XmlPatterns.psiElement().withParent(XmlHelper.getServiceAliasPattern()),
        ServiceAliasCompletionProvider::new
    );

    // <factory class="AppBundle\Trivago\ConfigFactory" method="create"/>
    // <factory service="foo" method="create"/>
    registrar.register(
        XmlPatterns.psiElement().withParent(XmlHelper.getTagAttributePattern("factory", "method")
            .inside(XmlHelper.getInsideTagPattern("services"))
            .inFile(XmlHelper.getXmlFilePattern())),
        ServiceFactoryMethodCompletionProvider::new
    );

    // <default key="route">sonata_admin_dashboard</default>
    registrar.register(
        XmlHelper.getRouteDefaultWithKeyAttributePattern("route"),
        RouteGotoCompletionProvider::new
    );

    // <default key="template">foobar.html.twig</default>
    registrar.register(
        XmlHelper.getRouteDefaultWithKeyAttributePattern("template"),
        TemplateGotoCompletionRegistrar::new
    );

    // <service decorates="<caret>"/>
    registrar.register(
        XmlPatterns.psiElement().withParent(XmlHelper.getTagAttributePattern("service", "decorates")
            .inside(XmlHelper.getInsideTagPattern("services"))
            .inFile(XmlHelper.getXmlFilePattern())),
        MyDecoratedServiceCompletionProvider::new
    );

    // <foobar="@Foobar/profiler.html.twig" />
    registrar.register(
        XmlPatterns.psiElement().withParent(XmlHelper.getGlobalStringAttributePattern()),
        new MyGlobalStringTemplateGotoCompletionContributor()
    );

    // <foo template="@Foobar/profiler.html.twig" />
    registrar.register(
        XmlPatterns.psiElement().withParent(XmlHelper.getAttributePattern("template")),
        MyTemplateCompletionRegistrar::new
    );

    // <argument key="$foobar"/>
    registrar.register(
        XmlHelper.getTagAttributePattern("argument", "key"),
        MyKeyArgumentGotoCompletionProvider::new
    );
}
 
Example #28
Source File: DirectEndpointReferenceContributor.java    From camel-idea-plugin with Apache License 2.0 4 votes vote down vote up
@Override
public void registerReferenceProviders(@NotNull PsiReferenceRegistrar registrar) {
    CamelEndpointPsiReferenceProvider provider = createProvider();
    registrar.registerReferenceProvider(PsiJavaPatterns.literalExpression(), provider);
    registrar.registerReferenceProvider(XmlPatterns.xmlAttributeValue("uri"), provider);
}
 
Example #29
Source File: JavaScriptInjector.java    From idea-php-typo3-plugin with MIT License 4 votes vote down vote up
@NotNull
private PsiElementPattern.Capture<PsiElement> getXmlFAssetJsContentPattern() {
    return PlatformPatterns.psiElement(XmlElementType.XML_TEXT).withParent(
        XmlPatterns.xmlTag().withName("f:asset.script")
    );
}
 
Example #30
Source File: CssInjector.java    From idea-php-typo3-plugin with MIT License 4 votes vote down vote up
@NotNull
private PsiElementPattern.Capture<PsiElement> getXmlFAssetCssContentPattern() {
    return PlatformPatterns.psiElement(XmlElementType.XML_TEXT).withParent(
        XmlPatterns.xmlTag().withName("f:asset.css")
    );
}