Search in sources :

Example 1 with PostfixTemplateLookupElement

use of com.intellij.codeInsight.template.postfix.completion.PostfixTemplateLookupElement in project intellij-community by JetBrains.

the class PostfixLiveTemplate method getLookupElements.

@NotNull
@Override
public Collection<? extends CustomLiveTemplateLookupElement> getLookupElements(@NotNull PsiFile file, @NotNull Editor editor, int offset) {
    Collection<CustomLiveTemplateLookupElement> result = ContainerUtil.newHashSet();
    CustomTemplateCallback callback = new CustomTemplateCallback(editor, file);
    for (PostfixTemplateProvider provider : LanguagePostfixTemplate.LANG_EP.allForLanguage(getLanguage(callback))) {
        String key = computeTemplateKeyWithoutContextChecking(callback);
        if (key != null && editor.getCaretModel().getCaretCount() == 1) {
            Condition<PostfixTemplate> isApplicationTemplateFunction = createIsApplicationTemplateFunction(provider, key, file, editor);
            for (PostfixTemplate postfixTemplate : provider.getTemplates()) {
                if (isApplicationTemplateFunction.value(postfixTemplate)) {
                    result.add(new PostfixTemplateLookupElement(this, postfixTemplate, postfixTemplate.getKey(), provider, false));
                }
            }
        }
    }
    return result;
}
Also used : CustomLiveTemplateLookupElement(com.intellij.codeInsight.template.impl.CustomLiveTemplateLookupElement) PostfixTemplateLookupElement(com.intellij.codeInsight.template.postfix.completion.PostfixTemplateLookupElement) CustomTemplateCallback(com.intellij.codeInsight.template.CustomTemplateCallback) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CustomTemplateCallback (com.intellij.codeInsight.template.CustomTemplateCallback)1 CustomLiveTemplateLookupElement (com.intellij.codeInsight.template.impl.CustomLiveTemplateLookupElement)1 PostfixTemplateLookupElement (com.intellij.codeInsight.template.postfix.completion.PostfixTemplateLookupElement)1 NotNull (org.jetbrains.annotations.NotNull)1