• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java MacroCallNode类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中com.intellij.codeInsight.template.impl.MacroCallNode的典型用法代码示例。如果您正苦于以下问题:Java MacroCallNode类的具体用法?Java MacroCallNode怎么用?Java MacroCallNode使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



MacroCallNode类属于com.intellij.codeInsight.template.impl包,在下文中一共展示了MacroCallNode类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: replaceElements

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
private static void replaceElements(XmlTag tag, TemplateBuilder builder) {
  for (XmlAttribute attribute : tag.getAttributes()) {
    XmlAttributeValue value = attribute.getValueElement();
    if (value != null) {
      builder.replaceElement(value, TextRange.from(1, 0), new MacroCallNode(new CompleteMacro()));
    }
  }
  if ("<".equals(tag.getText())) {
    builder.replaceElement(tag, TextRange.from(1, 0), new MacroCallNode(new CompleteSmartMacro()));
  }
  else if (tag.getSubTags().length == 0) {
    int i = tag.getText().indexOf("></");
    if (i > 0) {
      builder.replaceElement(tag, TextRange.from(i + 1, 0), new MacroCallNode(new CompleteMacro()));
    }
  }
  for (XmlTag subTag : tag.getSubTags()) {
    replaceElements(subTag, builder);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:21,代码来源:GenerateXmlTagAction.java


示例2: addExprVariable

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
@Override
protected void addExprVariable(@NotNull PsiElement expr, Template template) {
    ToStringIfNeedMacro toStringIfNeedMacro = new ToStringIfNeedMacro();
    MacroCallNode macroCallNode = new MacroCallNode(toStringIfNeedMacro);
    macroCallNode.addParameter(new ConstantNode(expr.getText()));

    MacroCallNode node = new MacroCallNode(new VariableOfTypeMacro());
    node.addParameter(new ConstantNode(VIEW.toString()));
    template.addVariable("view", node, new EmptyNode(), false);

    template.addVariable("expr", macroCallNode, false);

    if (mWithAction) {
        template.addVariable("actionText", new EmptyNode(), false);
        template.addVariable("action", new EmptyNode(), false);
    }
}
 
开发者ID:takahirom,项目名称:android-postfix-plugin,代码行数:18,代码来源:SnackbarTemplate.java


示例3: setVariables

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
@Override
public void setVariables(@NotNull Template template, @NotNull PsiElement element) {
  MacroCallNode type = new MacroCallNode(new IterableComponentTypeMacro());
  MacroCallNode name = new MacroCallNode(new SuggestVariableNameMacro());
  type.addParameter(new VariableNode("expr", null));
  template.addVariable("type", type, type, false);
  template.addVariable("name", name, name, true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:9,代码来源:ForeachPostfixTemplate.java


示例4: completeAttribute

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
private static void completeAttribute(Template template) {
  template.addTextSegment(" ");
  template.addVariable(new MacroCallNode(new CompleteMacro()), true);
  template.addTextSegment("=\"");
  template.addEndVariable();
  template.addTextSegment("\"");
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:XmlTagInsertHandler.java


示例5: addRequiredSubTags

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
private static boolean addRequiredSubTags(Template template, XmlElementDescriptor descriptor, PsiFile file, XmlTag context) {

    if (!WebEditorOptions.getInstance().isAutomaticallyInsertRequiredSubTags()) return false;
    List<XmlElementDescriptor> requiredSubTags = GenerateXmlTagAction.getRequiredSubTags(descriptor);
    if (!requiredSubTags.isEmpty()) {
      template.addTextSegment(">");
      template.setToReformat(true);
    }
    for (XmlElementDescriptor subTag : requiredSubTags) {
      if (subTag == null) { // placeholder for smart completion
        template.addTextSegment("<");
        template.addVariable(new MacroCallNode(new CompleteSmartMacro()), true);
        continue;
      }
      String qname = subTag.getName();
      if (subTag instanceof XmlElementDescriptorImpl) {
        String prefixByNamespace = context.getPrefixByNamespace(((XmlElementDescriptorImpl)subTag).getNamespace());
        if (StringUtil.isNotEmpty(prefixByNamespace)) {
          qname = prefixByNamespace + ":" + subTag.getName();
        }
      }
      template.addTextSegment("<" + qname);
      addRequiredAttributes(subTag, null, template, file);
      completeTagTail(template, subTag, file, context, false);
    }
    if (!requiredSubTags.isEmpty()) {
      addTagEnd(template, descriptor, context);
    }
    return !requiredSubTags.isEmpty();
  }
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:XmlTagInsertHandler.java


示例6: completeTagTail

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
private static void completeTagTail(Template template, XmlElementDescriptor descriptor, PsiFile file, XmlTag context, boolean firstLevel) {
  boolean completeIt = !firstLevel || descriptor.getAttributesDescriptors(null).length == 0;
  switch (descriptor.getContentType()) {
    case XmlElementDescriptor.CONTENT_TYPE_UNKNOWN:
      return;
    case XmlElementDescriptor.CONTENT_TYPE_EMPTY:
      if (completeIt) {
        template.addTextSegment("/>");
      }
      break;
    case XmlElementDescriptor.CONTENT_TYPE_MIXED:
       if (completeIt) {
         template.addTextSegment(">");
         if (firstLevel) {
           template.addEndVariable();
         }
         else {
           template.addVariable(new MacroCallNode(new CompleteMacro()), true);
         }
         addTagEnd(template, descriptor, context);
       }
       break;
     default:
       if (!addRequiredSubTags(template, descriptor, file, context)) {
         if (completeIt) {
           template.addTextSegment(">");
           template.addEndVariable();
           addTagEnd(template, descriptor, context);
         }
       }
       break;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:XmlTagInsertHandler.java


示例7: showRenameTemplate

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
public static void showRenameTemplate(PsiElement context,
                                      PsiNameIdentifierOwner element,
                                      PsiReference... references) {
  context = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(
    context);
  final Project project = context.getProject();
  final FileEditorManager fileEditorManager =
    FileEditorManager.getInstance(project);
  final Editor editor = fileEditorManager.getSelectedTextEditor();
  if (editor == null) {
    return;
  }
  final TemplateBuilderImpl builder = new TemplateBuilderImpl(context);
  final Expression macroCallNode = new MacroCallNode(
    new SuggestVariableNameMacro());
  final PsiElement identifier = element.getNameIdentifier();
  builder.replaceElement(identifier, "PATTERN", macroCallNode, true);
  for (PsiReference reference : references) {
    builder.replaceElement(reference, "PATTERN", "PATTERN",
                           false);
  }
  final Template template = builder.buildInlineTemplate();
  final TextRange textRange = context.getTextRange();
  final int startOffset = textRange.getStartOffset();
  editor.getCaretModel().moveToOffset(startOffset);
  final TemplateManager templateManager =
    TemplateManager.getInstance(project);
  templateManager.startTemplate(editor, template);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:HighlightUtils.java


示例8: showRenameTemplate

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
public static void showRenameTemplate(PsiElement context, PsiNameIdentifierOwner element) {
  context = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(context);
  final Query<PsiReference> query = ReferencesSearch.search(element, element.getUseScope());
  final Collection<PsiReference> references = query.findAll();
  final Project project = context.getProject();
  final FileEditorManager fileEditorManager =
    FileEditorManager.getInstance(project);
  final Editor editor = fileEditorManager.getSelectedTextEditor();
  if (editor == null) {
    return;
  }
  final TemplateBuilderImpl builder = new TemplateBuilderImpl(context);
  final Expression macroCallNode = new MacroCallNode(
    new SuggestVariableNameMacro());
  final PsiElement identifier = element.getNameIdentifier();
  builder.replaceElement(identifier, "PATTERN", macroCallNode, true);
  for (PsiReference reference : references) {
    builder.replaceElement(reference, "PATTERN", "PATTERN", false);
  }
  final Template template = builder.buildInlineTemplate();
  final TextRange textRange = context.getTextRange();
  final int startOffset = textRange.getStartOffset();
  editor.getCaretModel().moveToOffset(startOffset);
  final TemplateManager templateManager =
    TemplateManager.getInstance(project);
  templateManager.startTemplate(editor, template);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:28,代码来源:HighlightUtil.java


示例9: addExprVariable

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
@Override
protected void addExprVariable(@NotNull PsiElement expr, Template template) {
    final ToStringIfNeedMacro toStringIfNeedMacro = new ToStringIfNeedMacro();
    MacroCallNode macroCallNode = new MacroCallNode(toStringIfNeedMacro);
    macroCallNode.addParameter(new ConstantNode(expr.getText()));
    template.addVariable("expr", macroCallNode, false);
}
 
开发者ID:takahirom,项目名称:android-postfix-plugin,代码行数:8,代码来源:ToastTemplate.java


示例10: setVariables

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
@Override
protected void setVariables(@NotNull Template template, @NotNull PsiElement element) {
    MacroCallNode node = new MacroCallNode(new VariableOfTypeMacro());
    node.addParameter(new ConstantNode(CONTEXT.toString()));
    template.addVariable("context", node, new ConstantNode(""), false);

}
 
开发者ID:takahirom,项目名称:android-postfix-plugin,代码行数:8,代码来源:ToastTemplate.java


示例11: addExprVariable

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
@Override
protected void addExprVariable(@NotNull PsiElement expr, Template template) {
    final FindViewByIdMacro toStringIfNeedMacro = new FindViewByIdMacro();
    MacroCallNode macroCallNode = new MacroCallNode(toStringIfNeedMacro);
    macroCallNode.addParameter(new ConstantNode(expr.getText()));
    template.addVariable("expr", macroCallNode, false);
}
 
开发者ID:takahirom,项目名称:android-postfix-plugin,代码行数:8,代码来源:FindViewByIdTemplate.java


示例12: createElement

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
@Override
protected DomElement createElement(final WebApp context,
                                   final Editor editor,
                                   PsiFile file,
                                   final Project project,
                                   final PsiClass selectedClass) {

  new WriteCommandAction.Simple(project, "Create Filter", file) {
    @Override
    protected void run() throws Throwable {
      Filter filter = (Filter)createElement(context);
      filter.getFilterClass().setValue(selectedClass);

      FilterMapping mapping = context.addFilterMapping();

      TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(context.getXmlElement());
      VariableNode nameNode = new VariableNode("NAME", new MacroCallNode(new CompleteMacro()));
      replaceElementValue(builder, filter.getFilterName(), nameNode);

      replaceElementValue(builder, mapping.getFilterName(), nameNode);
      GenericDomValue<String> value = mapping.addUrlPattern();
      XmlTag tag = value.ensureTagExists();
      PsiElement child = tag.getLastChild();
      while (child != null && child != tag.getFirstChild()) {
        PsiElement prevSibling = child.getPrevSibling();
        child.delete();
        child = prevSibling;
      }
      builder.replaceElement(tag, TextRange.from(1, 0), new MacroCallNode(new CompleteSmartMacro()));

      PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
      builder.run();
    }
  }.execute();
  return null;
}
 
开发者ID:consulo,项目名称:consulo-javaee,代码行数:37,代码来源:GenerateFilterAction.java


示例13: createElement

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
@Override
protected DomElement createElement(final WebApp context,
                                   final Editor editor,
                                   PsiFile file,
                                   final Project project,
                                   final PsiClass selectedClass) {

  new WriteCommandAction.Simple(project, "Create servlet", file) {
    @Override
    protected void run() throws Throwable {
      Servlet servlet = (Servlet)createElement(context);
      servlet.getServletClass().setValue(selectedClass);

      ServletMapping mapping = context.addServletMapping();

      TemplateBuilder builder = TemplateBuilderFactory.getInstance().createTemplateBuilder(context.getXmlElement());
      VariableNode nameNode = new VariableNode("NAME", new MacroCallNode(new CompleteMacro()));
      replaceElementValue(builder, servlet.getServletName(), nameNode);

      replaceElementValue(builder, mapping.getServletName(), nameNode);
      replaceElementValue(builder, mapping.addUrlPattern(), new EmptyNode());

      PsiDocumentManager.getInstance(project).doPostponedOperationsAndUnblockDocument(editor.getDocument());
      builder.run();
    }
  }.execute();
  return null;
}
 
开发者ID:consulo,项目名称:consulo-javaee,代码行数:29,代码来源:GenerateServletAction.java


示例14: completeAttribute

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
private static void completeAttribute(Template template)
{
	template.addTextSegment(" ");
	template.addVariable(new MacroCallNode(new CompleteMacro()), true);
	template.addTextSegment("=\"");
	template.addEndVariable();
	template.addTextSegment("\"");
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:9,代码来源:XmlTagInsertHandler.java


示例15: addRequiredSubTags

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
private static boolean addRequiredSubTags(Template template, XmlElementDescriptor descriptor, PsiFile file, XmlTag context)
{

	if(!XmlEditorOptions.getInstance().isAutomaticallyInsertRequiredSubTags())
	{
		return false;
	}
	List<XmlElementDescriptor> requiredSubTags = GenerateXmlTagAction.getRequiredSubTags(descriptor);
	if(!requiredSubTags.isEmpty())
	{
		template.addTextSegment(">");
		template.setToReformat(true);
	}
	for(XmlElementDescriptor subTag : requiredSubTags)
	{
		if(subTag == null)
		{ // placeholder for smart completion
			template.addTextSegment("<");
			template.addVariable(new MacroCallNode(new CompleteSmartMacro()), true);
			continue;
		}
		String qname = subTag.getName();
		if(subTag instanceof XmlElementDescriptorImpl)
		{
			String prefixByNamespace = context.getPrefixByNamespace(((XmlElementDescriptorImpl) subTag).getNamespace());
			if(StringUtil.isNotEmpty(prefixByNamespace))
			{
				qname = prefixByNamespace + ":" + subTag.getName();
			}
		}
		template.addTextSegment("<" + qname);
		addRequiredAttributes(subTag, null, template, file);
		completeTagTail(template, subTag, file, context, false);
	}
	if(!requiredSubTags.isEmpty())
	{
		addTagEnd(template, descriptor, context);
	}
	return !requiredSubTags.isEmpty();
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:41,代码来源:XmlTagInsertHandler.java


示例16: expand

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
@Override
public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
  PsiExpression expr = JavaPostfixTemplatesUtils.getTopmostExpression(context);
  if (expr == null) return;
  Project project = context.getProject();

  Document document = editor.getDocument();
  document.deleteString(expr.getTextRange().getStartOffset(), expr.getTextRange().getEndOffset());
  TemplateManager manager = TemplateManager.getInstance(project);

  Template template = manager.createTemplate("", "");
  template.setToReformat(true);
  template.addTextSegment("for (");
  MacroCallNode type = new MacroCallNode(new IterableComponentTypeMacro());

  String variable = "variable";
  type.addParameter(new VariableNode(variable, null));
  MacroCallNode name = new MacroCallNode(new SuggestVariableNameMacro());

  template.addVariable("type", type, type, false);
  template.addTextSegment(" ");
  template.addVariable("name", name, name, true);

  template.addTextSegment(" : ");
  template.addVariable(variable, new TextExpression(expr.getText()), false);
  template.addTextSegment(") {\n");
  template.addEndVariable();
  template.addTextSegment("\n}");

  manager.startTemplate(editor, template);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:32,代码来源:ForeachPostfixTemplate.java


示例17: expand

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
@Override
public void expand(@NotNull PsiElement context, @NotNull Editor editor) {
  PsiExpression expr = JavaPostfixTemplatesUtils.getTopmostExpression(context);
  if (expr == null) {
    PostfixTemplatesUtils.showErrorHint(context.getProject(), editor);
    return;
  }

  Pair<String, String> bounds = calculateBounds(expr);
  if (bounds == null) {
    PostfixTemplatesUtils.showErrorHint(context.getProject(), editor);
    return;
  }
  Project project = context.getProject();

  Document document = editor.getDocument();
  document.deleteString(expr.getTextRange().getStartOffset(), expr.getTextRange().getEndOffset());
  TemplateManager manager = TemplateManager.getInstance(project);

  Template template = manager.createTemplate("", "");
  template.setToReformat(true);
  template.addTextSegment("for (" + suggestIndexType(expr) + " ");
  MacroCallNode index = new MacroCallNode(new SuggestVariableNameMacro());
  String indexVariable = "index";
  template.addVariable(indexVariable, index, index, true);
  template.addTextSegment(" = " + bounds.first + "; ");
  template.addVariableSegment(indexVariable);
  template.addTextSegment(getComparativeSign(expr));
  template.addTextSegment(bounds.second);
  template.addTextSegment("; ");
  template.addVariableSegment(indexVariable);
  template.addTextSegment(getOperator());
  template.addTextSegment(") {\n");
  template.addEndVariable();
  template.addTextSegment("\n}");

  manager.startTemplate(editor, template);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:39,代码来源:ForIndexedPostfixTemplate.java


示例18: showRenameTemplate

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
public static void showRenameTemplate(PsiElement context, PsiNameIdentifierOwner element) {
  context = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(context);
  final Query<PsiReference> query = ReferencesSearch.search(element, element.getUseScope());
  final Collection<PsiReference> references = query.findAll();
  final Project project = context.getProject();
  final FileEditorManager fileEditorManager =
    FileEditorManager.getInstance(project);
  final Editor editor = fileEditorManager.getSelectedTextEditor();
  if (editor == null) {
    return;
  }
  final TemplateBuilderImpl builder = new TemplateBuilderImpl(context);
  final Expression macroCallNode = new MacroCallNode(
    new SuggestVariableNameMacro());
  final PsiElement identifier = element.getNameIdentifier();
  builder.replaceElement(identifier, "PATTERN", macroCallNode, true);
  for (PsiReference reference : references) {
    builder.replaceElement(reference, "PATTERN", "PATTERN", false);
  }
  final Template template = builder.buildInlineTemplate();
  final TextRange textRange = context.getTextRange();
  final int startOffset = textRange.getStartOffset();
  editor.getCaretModel().moveToOffset(startOffset);
  final TemplateManager templateManager =
    TemplateManager.getInstance(project);
  templateManager.startTemplate(editor, template);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:28,代码来源:HighlightUtil.java


示例19: showRenameTemplate

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
public static void showRenameTemplate(PsiElement context,
                                      PsiNameIdentifierOwner element,
                                      PsiReference... references) {
  context = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(
    context);
  final Project project = context.getProject();
  final FileEditorManager fileEditorManager =
    FileEditorManager.getInstance(project);
  final Editor editor = fileEditorManager.getSelectedTextEditor();
  if (editor == null) {
    return;
  }
  final TemplateBuilderImpl builder = new TemplateBuilderImpl(context);
  final Expression macroCallNode = new MacroCallNode(
    new SuggestVariableNameMacro());
  final PsiElement identifier = element.getNameIdentifier();
  builder.replaceElement(identifier, "PATTERN", macroCallNode, true);
  for (PsiReference reference : references) {
    builder.replaceElement(reference, "PATTERN", "PATTERN",
                           false);
  }
  final Template template = builder.buildInlineTemplate();
  final TextRange textRange = context.getTextRange();
  final int startOffset = textRange.getStartOffset();
  editor.getCaretModel().moveToOffset(startOffset);
  final TemplateManager templateManager =
    TemplateManager.getInstance(project);
  templateManager.startTemplate(editor, template);
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:30,代码来源:HighlightUtils.java


示例20: setVariables

import com.intellij.codeInsight.template.impl.MacroCallNode; //导入依赖的package包/类
@Override
public void setVariables(Template template, PsiElement element) {
    super.setVariables(template, element);
    template.addVariable("return", new MacroCallNode(new SuggestVariableNameMacro()), false);
}
 
开发者ID:krrrr38,项目名称:intellij-mockito-postfix-plugin,代码行数:6,代码来源:DoReturnTemplate.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java ModifierSet类代码示例发布时间:2022-05-22
下一篇:
Java ContainerLocalizationRequestEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap