当前位置: 首页>>代码示例>>Java>>正文


Java GotoCompletionProvider类代码示例

本文整理汇总了Java中fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionProvider的典型用法代码示例。如果您正苦于以下问题:Java GotoCompletionProvider类的具体用法?Java GotoCompletionProvider怎么用?Java GotoCompletionProvider使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


GotoCompletionProvider类属于fr.adrienbrault.idea.symfony2plugin.codeInsight包,在下文中一共展示了GotoCompletionProvider类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getProvider

import fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionProvider; //导入依赖的package包/类
@Nullable
@Override
public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) {
    if (!Symfony2ProjectComponent.isEnabled(psiElement)) {
        return null;
    }

    ArrayCreationExpression arrayCreationExpression = PhpElementsUtil.getCompletableArrayCreationElement(psiElement.getParent());
    if(arrayCreationExpression != null) {
        PsiElement parameterList = arrayCreationExpression.getParent();
        if (parameterList instanceof ParameterList) {
            PsiElement context = parameterList.getContext();
            if(context instanceof MethodReference) {
                ParameterBag currentIndex = PsiElementUtils.getCurrentParameterIndex(arrayCreationExpression);
                if(currentIndex != null && currentIndex.getIndex() == 2) {
                    if (PhpElementsUtil.isMethodReferenceInstanceOf((MethodReference) context, FormUtil.PHP_FORM_BUILDER_SIGNATURES)) {
                        return getMatchingOption((ParameterList) parameterList, psiElement);
                    }
                }
            }
        }
    }

    return null;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:26,代码来源:FormOptionGotoCompletionRegistrar.java

示例2: getMatchingOption

import fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionProvider; //导入依赖的package包/类
@Nullable
private GotoCompletionProvider getMatchingOption(ParameterList parameterList, @NotNull PsiElement psiElement) {

    // form name can be a string alias; also resolve on constants, properties, ...
    PsiElement psiElementAt = PsiElementUtils.getMethodParameterPsiElementAt(parameterList, 1);

    String formTypeName = null;
    if(psiElementAt != null) {
        PhpClass phpClass = FormUtil.getFormTypeClassOnParameter(psiElementAt);
        if(phpClass != null) {
            formTypeName = phpClass.getFQN();
        }
    }

    // fallback to form
    if(formTypeName == null) {
        formTypeName = "form";
    }

    return new FormReferenceCompletionProvider(psiElement, formTypeName);
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:22,代码来源:FormOptionGotoCompletionRegistrar.java

示例3: createTranslationGotoCompletion

import fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionProvider; //导入依赖的package包/类
@Nullable
private GotoCompletionProvider createTranslationGotoCompletion(@NotNull PsiElement psiElement, @NotNull PsiElement arrayCreation) {
    int parameterIndexValue = PsiElementUtils.getParameterIndexValue(arrayCreation);
    if(parameterIndexValue != 2) {
        return null;
    }

    PsiElement parameterList = arrayCreation.getParent();
    if(parameterList instanceof ParameterList) {
        PsiElement methodReference = parameterList.getParent();
        if(methodReference instanceof MethodReference) {
            if(PhpElementsUtil.isMethodReferenceInstanceOf((MethodReference) methodReference, "\\Symfony\\Component\\Form\\FormBuilderInterface", "add") ||
                PhpElementsUtil.isMethodReferenceInstanceOf((MethodReference) methodReference, "\\Symfony\\Component\\Form\\FormBuilderInterface", "create")
                ) {
                return new TranslationGotoCompletionProvider(psiElement, extractTranslationDomainFromScope((ArrayCreationExpression) arrayCreation));
            }
        }
    }

    return null;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:22,代码来源:FormGotoCompletionRegistrar.java

示例4: getProvider

import fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionProvider; //导入依赖的package包/类
@Override
public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) {
    return new GotoCompletionProvider(psiElement) {
        @NotNull
        @Override
        public Collection<LookupElement> getLookupElements() {
            return TagNameCompletionProvider.getTagLookupElements(getProject());
        }

        @NotNull
        @Override
        public Collection<PsiElement> getPsiTargets(PsiElement element) {
            String tagName = GotoCompletionUtil.getTextValueForElement(element);
            if(tagName == null) {
                return Collections.emptyList();
            }

            return new ArrayList<>(ServiceUtil.getTaggedClasses(element.getProject(), tagName));
        }
    };
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:22,代码来源:TaggedParameterGotoCompletionRegistrar.java

示例5: createTranslationGotoCompletionWithLabelSwitch

import fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionProvider; //导入依赖的package包/类
@Nullable
private GotoCompletionProvider createTranslationGotoCompletionWithLabelSwitch(@NotNull PsiElement origin, @NotNull ArrayCreationExpression choices, Processor<ArrayCreationExpression> processor) {
    PsiElement choicesArrayValue = choices.getParent();
    if(choicesArrayValue.getNode().getElementType() == PhpElementTypes.ARRAY_VALUE) {
        PsiElement choicesValueHash = choicesArrayValue.getParent();
        if(choicesValueHash instanceof ArrayHashElement) {
            PhpPsiElement transKey = ((ArrayHashElement) choicesValueHash).getKey();
            String stringValue = PhpElementsUtil.getStringValue(transKey);

            if("choices".equals(stringValue)) {
                PsiElement choicesKey = transKey.getParent();
                if(choicesKey.getNode().getElementType() == PhpElementTypes.ARRAY_KEY) {
                    PsiElement formOptionsHash = choicesKey.getParent();
                    if(formOptionsHash instanceof ArrayHashElement) {
                        PsiElement arrayCreation = formOptionsHash.getParent();
                        if(arrayCreation instanceof ArrayCreationExpression) {
                            if(processor.process((ArrayCreationExpression) arrayCreation)) {
                                return createTranslationGotoCompletion(origin, arrayCreation);
                            }
                        }
                    }
                }
            }
        }
    }

    return null;
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:29,代码来源:FormGotoCompletionRegistrar.java

示例6: getProvider

import fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionProvider; //导入依赖的package包/类
@Nullable
@Override
public GotoCompletionProvider getProvider(@NotNull PsiElement psiElement) {
    PsiElement context = psiElement.getContext();
    if (!(context instanceof StringLiteralExpression)) {
        return null;
    }

    MethodMatcher.MethodMatchParameter match = new MethodMatcher.ArrayParameterMatcher(context, placeHolderParameter)
        .withSignature("Symfony\\Component\\Translation\\TranslatorInterface", method)
        .match();

    if (match == null) {
        return null;
    }

    PsiElement[] parameters = match.getMethodReference().getParameters();
    String key = PhpElementsUtil.getStringValue(parameters[0]);
    if(key == null) {
        return null;
    }

    String domain = "messages";
    if(parameters.length > domainParameter) {
        domain = PhpElementsUtil.getStringValue(parameters[domainParameter]);
        if(domain == null) {
            return null;
        }
    }

    return new MyTranslationPlaceholderGotoCompletionProvider(psiElement, key, domain);
}
 
开发者ID:Haehnchen,项目名称:idea-php-symfony2-plugin,代码行数:33,代码来源:TranslationPlaceholderGotoCompletionRegistrar.java


注:本文中的fr.adrienbrault.idea.symfony2plugin.codeInsight.GotoCompletionProvider类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。