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


Java SurroundWithTemplateHandler类代码示例

本文整理汇总了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;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:18,代码来源:SurroundWithAction.java

示例2: getHandler

import com.intellij.codeInsight.template.impl.SurroundWithTemplateHandler; //导入依赖的package包/类
@NotNull
@Override
protected CodeInsightActionHandler getHandler() {
  return new SurroundWithTemplateHandler();
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:6,代码来源:SurroundWithTemplateAction.java

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

示例4: getHandler

import com.intellij.codeInsight.template.impl.SurroundWithTemplateHandler; //导入依赖的package包/类
@Nonnull
@Override
protected CodeInsightActionHandler getHandler() {
  return new SurroundWithTemplateHandler();
}
 
开发者ID:consulo,项目名称:consulo,代码行数:6,代码来源:SurroundWithTemplateAction.java


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