Search in sources :

Example 6 with PostfixTemplatesSettings

use of com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesSettings in project intellij-community by JetBrains.

the class PostfixLiveTemplate method isApplicable.

@Override
public boolean isApplicable(PsiFile file, int offset, boolean wrapping) {
    PostfixTemplatesSettings settings = PostfixTemplatesSettings.getInstance();
    if (wrapping || file == null || settings == null || !settings.isPostfixTemplatesEnabled()) {
        return false;
    }
    Language language = PsiUtilCore.getLanguageAtOffset(file, offset);
    for (PostfixTemplateProvider provider : LanguagePostfixTemplate.LANG_EP.allForLanguage(language)) {
        if (StringUtil.isNotEmpty(computeTemplateKeyWithoutContextChecking(provider, file.getText(), offset + 1))) {
            return true;
        }
    }
    return false;
}
Also used : Language(com.intellij.lang.Language) PostfixTemplatesSettings(com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesSettings)

Aggregations

PostfixTemplatesSettings (com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesSettings)6 LookupElementAction (com.intellij.codeInsight.lookup.LookupElementAction)1 PostfixTemplatesCheckboxTree (com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesCheckboxTree)1 PostfixTemplatesConfigurable (com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesConfigurable)1 PostfixTemplate (com.intellij.codeInsight.template.postfix.templates.PostfixTemplate)1 Language (com.intellij.lang.Language)1 Project (com.intellij.openapi.project.Project)1