Java Code Examples for fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCall()

The following examples show how to use fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCall() . 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: YamlCompletionContributor.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
protected void addCompletions(@NotNull CompletionParameters completionParameters, ProcessingContext processingContext, @NotNull CompletionResultSet completionResultSet) {
    if(!Symfony2ProjectComponent.isEnabled(completionParameters.getPosition())) {
        return;
    }

    // - [ setContainer, [ @service_container ] ]
    PsiElement psiElement = completionParameters.getPosition();

    PsiElement yamlScalar = psiElement.getParent();
    if(yamlScalar instanceof YAMLScalar) {
        YamlHelper.visitServiceCall((YAMLScalar) yamlScalar, clazz -> {
            PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(), clazz);
            if(phpClass != null) {
                PhpElementsUtil.addClassPublicMethodCompletion(completionResultSet, phpClass);
            }
        });
    }
}
 
Example 2
Source File: YamlGoToDeclarationHandler.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
@NotNull
private Collection<PsiElement> getMethodGoto(@NotNull PsiElement psiElement) {
    Collection<PsiElement> results = new ArrayList<>();

    PsiElement parent = psiElement.getParent();

    if(parent instanceof YAMLScalar) {
        YamlHelper.visitServiceCall((YAMLScalar) parent, clazz -> {
            PhpClass phpClass = ServiceUtil.getResolvedClassDefinition(psiElement.getProject(),clazz);
            if(phpClass != null) {
                for(Method method: PhpElementsUtil.getClassPublicMethod(phpClass)) {
                    if(method.getName().equals(PsiElementUtils.trimQuote(psiElement.getText()))) {
                        results.add(method);
                    }
                }
            }
        });
    }

    return results;
}
 
Example 3
Source File: YamlHelperLightTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCall
 */
public void testVisitServiceCall() {
    myFixture.configureByText(YAMLFileType.YML, "services:\n" +
        "    foobar:\n" +
        "       class: Foo\\Bar\n" +
        "       calls:\n" +
        "           - [ '<caret>' ]\n"
    );

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

    Collection<String> values = new ArrayList<>();
    YamlHelper.visitServiceCall(parent, values::add);

    assertContainsElements(values, "Foo\\Bar");
}
 
Example 4
Source File: YamlHelperLightTest.java    From idea-php-symfony2-plugin with MIT License 6 votes vote down vote up
/**
 * @see fr.adrienbrault.idea.symfony2plugin.util.yaml.YamlHelper#visitServiceCall
 */
public void testVisitServiceCallForNamedServices() {
    myFixture.configureByText(YAMLFileType.YML, "services:\n" +
        "    Foo\\Bar:\n" +
        "       calls:\n" +
        "           - [ '<caret>' ]\n"
    );

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

    Collection<String> values = new ArrayList<>();
    YamlHelper.visitServiceCall(parent, values::add);

    assertContainsElements(values, "Foo\\Bar");
}
 
Example 5
Source File: EventMethodCallInspection.java    From idea-php-symfony2-plugin with MIT License 5 votes vote down vote up
private void visitYamlMethod(PsiElement psiElement, ProblemsHolder holder, ContainerCollectionResolver.LazyServiceCollector collector) {
    if(YamlElementPatternHelper.getInsideKeyValue("calls").accepts(psiElement)) {
        PsiElement parent = psiElement.getParent();
        if ((parent instanceof YAMLScalar)) {
            YamlHelper.visitServiceCall((YAMLScalar) parent, s ->
                registerMethodProblem(psiElement, holder, YamlHelper.trimSpecialSyntaxServiceName(s), collector)
            );
        }
    }
}