当前位置: 首页>>代码示例>>Java>>正文


Java Surrounder.isApplicable方法代码示例

本文整理汇总了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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:PostfixTemplatesUtils.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:15,代码来源:PostfixTemplatesUtils.java

示例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;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:56,代码来源:SurroundWithHandler.java

示例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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:56,代码来源:SurroundWithHandler.java

示例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;
}
 
开发者ID:consulo,项目名称:consulo,代码行数:56,代码来源:SurroundWithHandler.java


注:本文中的com.intellij.lang.surroundWith.Surrounder.isApplicable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。