Search in sources :

Example 1 with CustomLiveTemplateBase

use of com.intellij.codeInsight.template.CustomLiveTemplateBase in project intellij-community by JetBrains.

the class ListTemplatesHandler method getCustomTemplatesLookupItems.

public static MultiMap<String, CustomLiveTemplateLookupElement> getCustomTemplatesLookupItems(@NotNull Editor editor, @NotNull PsiFile file, int offset) {
    final MultiMap<String, CustomLiveTemplateLookupElement> result = MultiMap.create();
    CustomTemplateCallback customTemplateCallback = new CustomTemplateCallback(editor, file);
    for (CustomLiveTemplate customLiveTemplate : TemplateManagerImpl.listApplicableCustomTemplates(editor, file, false)) {
        if (customLiveTemplate instanceof CustomLiveTemplateBase) {
            String customTemplatePrefix = ((CustomLiveTemplateBase) customLiveTemplate).computeTemplateKeyWithoutContextChecking(customTemplateCallback);
            if (customTemplatePrefix != null) {
                result.putValues(customTemplatePrefix, ((CustomLiveTemplateBase) customLiveTemplate).getLookupElements(file, editor, offset));
            }
        }
    }
    return result;
}
Also used : CustomLiveTemplate(com.intellij.codeInsight.template.CustomLiveTemplate) CustomTemplateCallback(com.intellij.codeInsight.template.CustomTemplateCallback) CustomLiveTemplateBase(com.intellij.codeInsight.template.CustomLiveTemplateBase)

Example 2 with CustomLiveTemplateBase

use of com.intellij.codeInsight.template.CustomLiveTemplateBase in project intellij-community by JetBrains.

the class LiveTemplateCompletionContributor method showCustomLiveTemplates.

private static void showCustomLiveTemplates(@NotNull CompletionParameters parameters, @NotNull CompletionResultSet result) {
    PsiFile file = parameters.getPosition().getContainingFile();
    Editor editor = parameters.getEditor();
    for (CustomLiveTemplate customLiveTemplate : TemplateManagerImpl.listApplicableCustomTemplates(editor, file, false)) {
        if (customLiveTemplate instanceof CustomLiveTemplateBase) {
            ((CustomLiveTemplateBase) customLiveTemplate).addCompletions(parameters, result);
        }
    }
}
Also used : CustomLiveTemplate(com.intellij.codeInsight.template.CustomLiveTemplate) PsiFile(com.intellij.psi.PsiFile) CustomLiveTemplateBase(com.intellij.codeInsight.template.CustomLiveTemplateBase) Editor(com.intellij.openapi.editor.Editor)

Aggregations

CustomLiveTemplate (com.intellij.codeInsight.template.CustomLiveTemplate)2 CustomLiveTemplateBase (com.intellij.codeInsight.template.CustomLiveTemplateBase)2 CustomTemplateCallback (com.intellij.codeInsight.template.CustomTemplateCallback)1 Editor (com.intellij.openapi.editor.Editor)1 PsiFile (com.intellij.psi.PsiFile)1