本文整理汇总了Java中com.intellij.lang.surroundWith.Surrounder.isApplicable方法的典型用法代码示例。如果您正苦于以下问题:Java Surrounder.isApplicable方法的具体用法?Java Surrounder.isApplicable怎么用?Java Surrounder.isApplicable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.lang.surroundWith.Surrounder
的用法示例。
在下文中一共展示了Surrounder.isApplicable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: surround
import com.intellij.lang.surroundWith.Surrounder; //导入方法依赖的package包/类
@Nullable
public static TextRange surround(@NotNull Surrounder surrounder,
@NotNull Editor editor,
@NotNull PsiElement expr) {
Project project = expr.getProject();
PsiElement[] elements = {expr};
if (surrounder.isApplicable(elements)) {
return surrounder.surroundElements(project, editor, elements);
}
else {
showErrorHint(project, editor);
}
return null;
}
示例2: surround
import com.intellij.lang.surroundWith.Surrounder; //导入方法依赖的package包/类
@Nullable
public static TextRange surround(@Nonnull Surrounder surrounder,
@Nonnull Editor editor,
@Nonnull PsiElement expr) {
Project project = expr.getProject();
PsiElement[] elements = {expr};
if (surrounder.isApplicable(elements)) {
return surrounder.surroundElements(project, editor, elements);
}
else {
showErrorHint(project, editor);
}
return null;
}
示例3: doBuildSurroundActions
import com.intellij.lang.surroundWith.Surrounder; //导入方法依赖的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 = TemplateManagerImpl.listApplicableCustomTemplates(editor, file, true);
List<TemplateImpl> templates = TemplateManagerImpl.listApplicableTemplateWithInsertingDummyIdentifier(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: doBuildSurroundActions
import com.intellij.lang.surroundWith.Surrounder; //导入方法依赖的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;
}
示例5: doBuildSurroundActions
import com.intellij.lang.surroundWith.Surrounder; //导入方法依赖的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 = TemplateManagerImpl.listApplicableCustomTemplates(editor, file, true);
List<TemplateImpl> templates = TemplateManagerImpl.listApplicableTemplateWithInsertingDummyIdentifier(editor, file, true);
if (!templates.isEmpty() || !customTemplates.isEmpty()) {
applicable.add(new AnSeparator("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(AnSeparator.getInstance());
applicable.add(new ConfigureTemplatesAction());
}
return hasEnabledSurrounders ? applicable : null;
}