當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。