本文整理汇总了Java中com.intellij.codeInsight.template.postfix.templates.PostfixLiveTemplate类的典型用法代码示例。如果您正苦于以下问题:Java PostfixLiveTemplate类的具体用法?Java PostfixLiveTemplate怎么用?Java PostfixLiveTemplate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
PostfixLiveTemplate类属于com.intellij.codeInsight.template.postfix.templates包,在下文中一共展示了PostfixLiveTemplate类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addCompletions
import com.intellij.codeInsight.template.postfix.templates.PostfixLiveTemplate; //导入依赖的package包/类
@Override
protected void addCompletions(@NotNull CompletionParameters parameters, ProcessingContext context, @NotNull CompletionResultSet result) {
Editor editor = parameters.getEditor();
if (!isCompletionEnabled(parameters) || LiveTemplateCompletionContributor.shouldShowAllTemplates() ||
editor.getCaretModel().getCaretCount() != 1) {
/**
* disabled or covered with {@link com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor}
*/
return;
}
PsiFile originalFile = parameters.getOriginalFile();
PostfixLiveTemplate postfixLiveTemplate = getPostfixLiveTemplate(originalFile, editor);
if (postfixLiveTemplate != null) {
postfixLiveTemplate.addCompletions(parameters, result.withPrefixMatcher(new MyPrefixMatcher(result.getPrefixMatcher().getPrefix())));
String possibleKey = postfixLiveTemplate.computeTemplateKeyWithoutContextChecking(new CustomTemplateCallback(editor, originalFile));
if (possibleKey != null) {
result = result.withPrefixMatcher(possibleKey);
result.restartCompletionOnPrefixChange(
StandardPatterns.string().oneOf(postfixLiveTemplate.getAllTemplateKeys(originalFile, parameters.getOffset())));
}
}
}
示例2: PostfixTemplateLookupElement
import com.intellij.codeInsight.template.postfix.templates.PostfixLiveTemplate; //导入依赖的package包/类
public PostfixTemplateLookupElement(@NotNull PostfixLiveTemplate liveTemplate,
@NotNull PostfixTemplate postfixTemplate,
@NotNull String templateKey,
@NotNull PostfixTemplateProvider provider,
boolean sudden) {
super(liveTemplate, templateKey, StringUtil.trimStart(templateKey, "."), postfixTemplate.getDescription(), sudden, true);
myTemplate = postfixTemplate;
myProvider = provider;
}
示例3: PostfixTemplateCompletionContributor
import com.intellij.codeInsight.template.postfix.templates.PostfixLiveTemplate; //导入依赖的package包/类
public PostfixTemplateCompletionContributor() {
extend(CompletionType.BASIC, PlatformPatterns.psiElement(), new CompletionProvider() {
@RequiredReadAction
@Override
public void addCompletions(@Nonnull CompletionParameters parameters, ProcessingContext context, @Nonnull CompletionResultSet result) {
Editor editor = parameters.getEditor();
if (!isCompletionEnabled(parameters) || LiveTemplateCompletionContributor.shouldShowAllTemplates() ||
editor.getCaretModel().getCaretCount() != 1) {
/**
* disabled or covered with {@link com.intellij.codeInsight.template.impl.LiveTemplateCompletionContributor}
*/
return;
}
PsiFile originalFile = parameters.getOriginalFile();
PostfixLiveTemplate postfixLiveTemplate = PostfixTemplateCompletionContributor.getPostfixLiveTemplate(originalFile, editor);
if (postfixLiveTemplate != null) {
postfixLiveTemplate.addCompletions(parameters, result.withPrefixMatcher(new MyPrefixMatcher(result.getPrefixMatcher().getPrefix())));
String possibleKey = postfixLiveTemplate.computeTemplateKeyWithoutContextChecking(new CustomTemplateCallback(editor, originalFile));
if (possibleKey != null) {
result = result.withPrefixMatcher(possibleKey);
result.restartCompletionOnPrefixChange(
StandardPatterns.string().oneOf(postfixLiveTemplate.getAllTemplateKeys(originalFile, parameters.getOffset())));
}
}
}
});
}
示例4: PostfixTemplateLookupElement
import com.intellij.codeInsight.template.postfix.templates.PostfixLiveTemplate; //导入依赖的package包/类
public PostfixTemplateLookupElement(@Nonnull PostfixLiveTemplate liveTemplate,
@Nonnull PostfixTemplate postfixTemplate,
@Nonnull String templateKey,
@Nonnull PostfixTemplateProvider provider,
boolean sudden) {
super(liveTemplate, templateKey, StringUtil.trimStart(templateKey, "."), postfixTemplate.getDescription(), sudden, true);
myTemplate = postfixTemplate;
myProvider = provider;
}
示例5: getPostfixLiveTemplate
import com.intellij.codeInsight.template.postfix.templates.PostfixLiveTemplate; //导入依赖的package包/类
@Nullable
public static PostfixLiveTemplate getPostfixLiveTemplate(@NotNull PsiFile file, @NotNull Editor editor) {
PostfixLiveTemplate postfixLiveTemplate = CustomLiveTemplate.EP_NAME.findExtension(PostfixLiveTemplate.class);
return postfixLiveTemplate != null && TemplateManagerImpl.isApplicable(postfixLiveTemplate, editor, file) ? postfixLiveTemplate : null;
}
示例6: getPostfixLiveTemplate
import com.intellij.codeInsight.template.postfix.templates.PostfixLiveTemplate; //导入依赖的package包/类
@Nullable
public static PostfixLiveTemplate getPostfixLiveTemplate(@Nonnull PsiFile file, @Nonnull Editor editor) {
PostfixLiveTemplate postfixLiveTemplate = CustomLiveTemplate.EP_NAME.findExtension(PostfixLiveTemplate.class);
return postfixLiveTemplate != null && TemplateManagerImpl.isApplicable(postfixLiveTemplate, editor, file) ? postfixLiveTemplate : null;
}