use of com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesSettings in project intellij-community by JetBrains.
the class TemplatesCompletionTest method tearDown.
@Override
public void tearDown() throws Exception {
try {
PostfixTemplatesSettings settings = PostfixTemplatesSettings.getInstance();
assertNotNull(settings);
settings.setLangDisabledTemplates(ContainerUtil.newHashMap());
settings.setPostfixTemplatesEnabled(true);
settings.setTemplatesCompletionEnabled(true);
} finally {
super.tearDown();
}
}
use of com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesSettings in project intellij-community by JetBrains.
the class PostfixTemplateLookupActionProvider method fillActions.
@Override
public void fillActions(LookupElement element, final Lookup lookup, Consumer<LookupElementAction> consumer) {
if (element instanceof PostfixTemplateLookupElement) {
final PostfixTemplateLookupElement templateLookupElement = (PostfixTemplateLookupElement) element;
final PostfixTemplate template = templateLookupElement.getPostfixTemplate();
consumer.consume(new LookupElementAction(PlatformIcons.EDIT, "Edit postfix templates settings") {
@Override
public Result performLookupAction() {
final Project project = lookup.getProject();
ApplicationManager.getApplication().invokeLater(() -> {
if (project.isDisposed())
return;
final PostfixTemplatesConfigurable configurable = new PostfixTemplatesConfigurable();
ShowSettingsUtil.getInstance().editConfigurable(project, configurable, () -> {
PostfixTemplatesCheckboxTree templatesTree = configurable.getTemplatesTree();
if (templatesTree != null) {
templatesTree.selectTemplate(template, PostfixTemplatesUtils.getLangForProvider(templateLookupElement.getProvider()));
}
});
});
return Result.HIDE_LOOKUP;
}
});
final PostfixTemplatesSettings settings = PostfixTemplatesSettings.getInstance();
if (settings != null && settings.isTemplateEnabled(template, templateLookupElement.getProvider())) {
consumer.consume(new LookupElementAction(AllIcons.Actions.Delete, String.format("Disable '%s' template", template.getKey())) {
@Override
public Result performLookupAction() {
ApplicationManager.getApplication().invokeLater(() -> settings.disableTemplate(template, templateLookupElement.getProvider()));
return Result.HIDE_LOOKUP;
}
});
}
}
}
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;
}
use of com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesSettings in project intellij-community by JetBrains.
the class TemplatesCompletionTest method testDoNotShowTemplateIfTemplateCompletionIsDisabled.
public void testDoNotShowTemplateIfTemplateCompletionIsDisabled() {
PostfixTemplatesSettings settings = PostfixTemplatesSettings.getInstance();
assertNotNull(settings);
settings.setTemplatesCompletionEnabled(false);
doAutoPopupTest("instanceof", null);
}
use of com.intellij.codeInsight.template.postfix.settings.PostfixTemplatesSettings in project intellij-community by JetBrains.
the class TemplatesCompletionTest method testDoNotShowTemplateIfPluginIsDisabled.
public void testDoNotShowTemplateIfPluginIsDisabled() {
PostfixTemplatesSettings settings = PostfixTemplatesSettings.getInstance();
assertNotNull(settings);
settings.setPostfixTemplatesEnabled(false);
doAutoPopupTest("instanceof", null);
}
Aggregations