本文整理汇总了Java中com.intellij.codeInsight.template.impl.SurroundWithTemplateHandler类的典型用法代码示例。如果您正苦于以下问题:Java SurroundWithTemplateHandler类的具体用法?Java SurroundWithTemplateHandler怎么用?Java SurroundWithTemplateHandler使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
SurroundWithTemplateHandler类属于com.intellij.codeInsight.template.impl包,在下文中一共展示了SurroundWithTemplateHandler类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: isValidForFile
import com.intellij.codeInsight.template.impl.SurroundWithTemplateHandler; //导入依赖的package包/类
@Override
protected boolean isValidForFile(@NotNull Project project, @NotNull Editor editor, @NotNull final PsiFile file) {
final Language language = file.getLanguage();
if (!LanguageSurrounders.INSTANCE.allForLanguage(language).isEmpty()) {
return true;
}
final PsiFile baseFile = PsiUtilCore.getTemplateLanguageFile(file);
if (baseFile != null && baseFile != file && !LanguageSurrounders.INSTANCE.allForLanguage(baseFile.getLanguage()).isEmpty()) {
return true;
}
if (!SurroundWithTemplateHandler.getApplicableTemplates(editor, file, true).isEmpty()) {
return true;
}
return false;
}
示例2: getHandler
import com.intellij.codeInsight.template.impl.SurroundWithTemplateHandler; //导入依赖的package包/类
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
return new SurroundWithTemplateHandler();
}
示例3: doBuildSurroundActions
import com.intellij.codeInsight.template.impl.SurroundWithTemplateHandler; //导入依赖的package包/类
@Nullable
private static List<AnAction> doBuildSurroundActions(Project project,
Editor editor,
PsiFile file,
Map<Surrounder, PsiElement[]> surrounders) {
final List<AnAction> applicable = new ArrayList<AnAction>();
boolean hasEnabledSurrounders = false;
Set<Character> usedMnemonicsSet = new HashSet<Character>();
int index = 0;
for (Map.Entry<Surrounder, PsiElement[]> entry : surrounders.entrySet()) {
Surrounder surrounder = entry.getKey();
PsiElement[] elements = entry.getValue();
if (surrounder.isApplicable(elements)) {
char mnemonic;
if (index < 9) {
mnemonic = (char)('0' + index + 1);
}
else if (index == 9) {
mnemonic = '0';
}
else {
mnemonic = (char)('A' + index - 10);
}
index++;
usedMnemonicsSet.add(Character.toUpperCase(mnemonic));
applicable.add(new InvokeSurrounderAction(surrounder, project, editor, elements, mnemonic));
hasEnabledSurrounders = true;
}
}
List<CustomLiveTemplate> customTemplates = SurroundWithTemplateHandler.getApplicableCustomTemplates(editor, file);
List<TemplateImpl> templates = SurroundWithTemplateHandler.getApplicableTemplates(editor, file, true);
if (!templates.isEmpty() || !customTemplates.isEmpty()) {
applicable.add(new Separator("Live templates"));
}
for (TemplateImpl template : templates) {
applicable.add(new InvokeTemplateAction(template, editor, project, usedMnemonicsSet));
hasEnabledSurrounders = true;
}
for (CustomLiveTemplate customTemplate : customTemplates) {
applicable.add(new WrapWithCustomTemplateAction(customTemplate, editor, file, usedMnemonicsSet));
hasEnabledSurrounders = true;
}
if (!templates.isEmpty() || !customTemplates.isEmpty()) {
applicable.add(Separator.getInstance());
applicable.add(new ConfigureTemplatesAction());
}
return hasEnabledSurrounders ? applicable : null;
}
示例4: getHandler
import com.intellij.codeInsight.template.impl.SurroundWithTemplateHandler; //导入依赖的package包/类
@Nonnull
@Override
protected CodeInsightActionHandler getHandler() {
return new SurroundWithTemplateHandler();
}