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

Java ConstantNode类代码示例

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

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



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

示例1: insertMethod

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的package包/类
@Override
protected void insertMethod(@NotNull Project project, @NotNull Editor editor) {
    Template template = TemplateManager.getInstance(project).createTemplate("", "");
    template.addTextSegment("public function test");

    Expression nameExpr = new ConstantNode("");
    template.addVariable("name", nameExpr, nameExpr, true);
    template.addTextSegment("()");

    PhpLanguageLevel languageLevel = PhpProjectConfigurationFacade.getInstance(project).getLanguageLevel();
    if (languageLevel.hasFeature(PhpLanguageFeature.RETURN_VOID)) {
        template.addTextSegment(": void");
    }

    template.addTextSegment("\n{\n");
    template.addEndVariable();
    template.addTextSegment("\n}");
    template.setToIndent(true);
    template.setToReformat(true);
    template.setToShortenLongNames(true);
    TemplateManager.getInstance(project).startTemplate(editor, template, null);
}
 
开发者ID:jiripudil,项目名称:intellij-nette-tester,代码行数:23,代码来源:TesterGenerateTestMethodAction.java


示例2: addExprVariable

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的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: buildParameterList

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的package包/类
protected void buildParameterList(@NotNull CreateUnresolvedElementFixContext context, @NotNull PsiFile file, @NotNull Template template)
{
	template.addTextSegment("(");

	CSharpSimpleParameterInfo[] parameterInfos = myLikeMethod.getParameterInfos();

	for(int i = 0; i < parameterInfos.length; i++)
	{
		if(i != 0)
		{
			template.addTextSegment(", ");
		}

		CSharpSimpleParameterInfo parameterInfo = parameterInfos[i];

		template.addVariable(new ConstantNode(CSharpTypeRefPresentationUtil.buildShortText(parameterInfo.getTypeRef(), context.getExpression())), true);
		template.addTextSegment(" ");
		template.addVariable(new ConstantNode(parameterInfo.getNotNullName()), true);

	}
	template.addTextSegment(")");
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:23,代码来源:CreateUnresolvedMethodByLambdaTypeFix.java


示例4: replaceRange

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的package包/类
@Override
public void replaceRange(TextRange rangeWithinElement, String replacementText) {
  final RangeMarker key = myDocument.createRangeMarker(rangeWithinElement.shiftRight(myContainerElement.getStartOffset()));

  ConstantNode value = new ConstantNode(replacementText);
  replaceElement(key, value);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:8,代码来源:TemplateBuilderImpl.java


示例5: addExprVariable

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的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


示例6: setVariables

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的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


示例7: addExprVariable

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的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


示例8: createArgTemplate

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的package包/类
@NotNull
private static Template createArgTemplate(PsiMethod method, int caretOffset, PsiExpressionList argList, TextRange argRange)
{
	Template template = TemplateManager.getInstance(method.getProject()).createTemplate("", "");
	PsiParameter[] parameters = method.getParameterList().getParameters();
	for(int i = 0; i < parameters.length; i++)
	{
		if(i > 0)
		{
			template.addTextSegment(", ");
		}
		String name = StringUtil.notNullize(parameters[i].getName());
		Expression expression = JAVA_COMPLETION_ARGUMENT_LIVE_TEMPLATE_COMPLETION ? new AutoPopupCompletion() : new ConstantNode(name);
		template.addVariable(name, expression, new ConstantNode(name), true);
	}
	boolean finishInsideParens = method.isVarArgs();
	if(finishInsideParens)
	{
		template.addEndVariable();
	}
	template.addTextSegment(argList.getText().substring(caretOffset - argRange.getStartOffset(), argList.getTextLength()));
	if(!finishInsideParens)
	{
		template.addEndVariable();
	}
	return template;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:28,代码来源:JavaMethodCallElement.java


示例9: createTestMethodTemplate

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的package包/类
public static Template createTestMethodTemplate(MethodKind methodKind,
                                                TestFramework descriptor,
                                                PsiClass targetClass,
                                                @Nullable String name,
                                                boolean automatic,
                                                Set<String> existingNames) {
  FileTemplateDescriptor templateDesc = methodKind.getFileTemplateDescriptor(descriptor);
  String templateName = templateDesc.getFileName();
  FileTemplate fileTemplate = FileTemplateManager.getInstance(targetClass.getProject()).getCodeTemplate(templateName);
  Template template = TemplateManager.getInstance(targetClass.getProject()).createTemplate("", "");

  String templateText;
  try {
    templateText = fileTemplate.getText(new Properties());
  }
  catch (IOException e) {
    LOG.warn(e);
    templateText = fileTemplate.getText();
  }

  if (name == null) name = methodKind.getDefaultName();

  if (existingNames != null && !existingNames.add(name)) {
    int idx = 1;
    while (existingNames.contains(name)) {
      final String newName = name + (idx++);
      if (existingNames.add(newName)) {
        name = newName;
        break;
      }
    }
  }

  templateText = StringUtil.replace(templateText, "${BODY}", "");

  int from = 0;
  while (true) {
    int index = templateText.indexOf("${NAME}", from);
    if (index == -1) break;

    template.addTextSegment(templateText.substring(from, index));

    if (index > 0 && !Character.isWhitespace(templateText.charAt(index - 1))) {
      name = StringUtil.capitalize(name);
    }
    else {
      name = StringUtil.decapitalize(name);
    }
    if (from == 0) {
      Expression nameExpr = new ConstantNode(name);
      template.addVariable("name", nameExpr, nameExpr, !automatic);
    }
    else {
      template.addVariableSegment("name");
    }

    from = index + "${NAME}".length();
  }
  template.addTextSegment(templateText.substring(from, templateText.length()));

  template.setToIndent(true);
  template.setToReformat(true);
  template.setToShortenLongNames(true);

  return template;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:67,代码来源:TestIntegrationUtils.java


示例10: replaceElement

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的package包/类
@Override
public void replaceElement(@NotNull PsiElement element, String replacementText) {
  replaceElement(element, new ConstantNode(replacementText));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:TemplateBuilderImpl.java


示例11: getVariableByFQDN

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的package包/类
private Result getVariableByFQDN(ExpressionContext context, String fqn) {
    MacroCallNode callNode = new MacroCallNode(new VariableOfTypeMacro());
    callNode.addParameter(new ConstantNode(fqn));
    return callNode.calculateResult(context);
}
 
开发者ID:takahirom,项目名称:android-postfix-plugin,代码行数:6,代码来源:FindViewByIdMacro.java


示例12: setVariables

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的package包/类
@Override
protected void setVariables(@NotNull Template template, @NotNull PsiElement element) {
    MacroCallNode node = new MacroCallNode(new TagMacro());
    template.addVariable("TAG", node, new ConstantNode(""), false);
}
 
开发者ID:takahirom,项目名称:android-postfix-plugin,代码行数:6,代码来源:LogTemplate.java


示例13: createTestMethodTemplate

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的package包/类
private static Template createTestMethodTemplate(MethodKind methodKind,
                                                 TestFramework descriptor,
                                                 PsiClass targetClass,
                                                 @Nullable String name,
                                                 boolean automatic) {
  FileTemplateDescriptor templateDesc = methodKind.getFileTemplateDescriptor(descriptor);
  String templateName = templateDesc.getFileName();
  FileTemplate fileTemplate = FileTemplateManager.getInstance().getCodeTemplate(templateName);
  Template template = TemplateManager.getInstance(targetClass.getProject()).createTemplate("", "");

  String templateText;
  try {
    templateText = fileTemplate.getText(new Properties());
  }
  catch (IOException e) {
    LOG.warn(e);
    templateText = fileTemplate.getText();
  }

  if (name == null) name = methodKind.getDefaultName();

  templateText = StringUtil.replace(templateText, "${BODY}", "");

  int from = 0;
  while (true) {
    int index = templateText.indexOf("${NAME}", from);
    if (index == -1) break;

    template.addTextSegment(templateText.substring(from, index));

    if (index > 0 && !Character.isWhitespace(templateText.charAt(index - 1))) {
      name = StringUtil.capitalize(name);
    }
    else {
      name = StringUtil.decapitalize(name);
    }
    if (from == 0) {
      Expression nameExpr = new ConstantNode(name);
      template.addVariable("name", nameExpr, nameExpr, !automatic);
    }
    else {
      template.addVariableSegment("name");
    }

    from = index + "${NAME}".length();
  }
  template.addTextSegment(templateText.substring(from, templateText.length()));

  template.setToIndent(true);
  template.setToReformat(true);
  template.setToShortenLongNames(true);

  return template;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:55,代码来源:TestIntegrationUtils.java


示例14: replaceElement

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的package包/类
@Override
public void replaceElement(@Nonnull PsiElement element, String replacementText) {
  replaceElement(element, new ConstantNode(replacementText));
}
 
开发者ID:consulo,项目名称:consulo,代码行数:5,代码来源:TemplateBuilderImpl.java


示例15: createTestMethodTemplate

import com.intellij.codeInsight.template.impl.ConstantNode; //导入依赖的package包/类
private static Template createTestMethodTemplate(MethodKind methodKind,
                                                 TestFramework descriptor,
                                                 PsiClass targetClass,
                                                 @Nullable String name,
                                                 boolean automatic) {
  FileTemplateDescriptor templateDesc = methodKind.getFileTemplateDescriptor(descriptor);
  String templateName = templateDesc.getFileName();
  FileTemplate fileTemplate = FileTemplateManager.getInstance(targetClass.getProject()).getCodeTemplate(templateName);
  Template template = TemplateManager.getInstance(targetClass.getProject()).createTemplate("", "");

  String templateText;
  try {
    templateText = fileTemplate.getText(new Properties());
  }
  catch (IOException e) {
    LOG.warn(e);
    templateText = fileTemplate.getText();
  }

  if (name == null) name = methodKind.getDefaultName();

  templateText = StringUtil.replace(templateText, "${BODY}", "");

  int from = 0;
  while (true) {
    int index = templateText.indexOf("${NAME}", from);
    if (index == -1) break;

    template.addTextSegment(templateText.substring(from, index));

    if (index > 0 && !Character.isWhitespace(templateText.charAt(index - 1))) {
      name = StringUtil.capitalize(name);
    }
    else {
      name = StringUtil.decapitalize(name);
    }
    if (from == 0) {
      Expression nameExpr = new ConstantNode(name);
      template.addVariable("name", nameExpr, nameExpr, !automatic);
    }
    else {
      template.addVariableSegment("name");
    }

    from = index + "${NAME}".length();
  }
  template.addTextSegment(templateText.substring(from, templateText.length()));

  template.setToIndent(true);
  template.setToReformat(true);
  template.setToShortenLongNames(true);

  return template;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:55,代码来源:TestIntegrationUtils.java



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Java Item类代码示例发布时间:2022-05-22
下一篇:
Java AssertableSubscriber类代码示例发布时间: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