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


Java MacroCallNode类代码示例

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


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


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