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


Java Template.addEndVariable方法代码示例

本文整理汇总了Java中com.intellij.codeInsight.template.Template.addEndVariable方法的典型用法代码示例。如果您正苦于以下问题:Java Template.addEndVariable方法的具体用法?Java Template.addEndVariable怎么用?Java Template.addEndVariable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.codeInsight.template.Template的用法示例。


在下文中一共展示了Template.addEndVariable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: insertMethod

import com.intellij.codeInsight.template.Template; //导入方法依赖的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: buildTemplate

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@RequiredReadAction
@Override
public void buildTemplate(@NotNull CreateUnresolvedElementFixContext context, CSharpContextUtil.ContextType contextType, @NotNull PsiFile file, @NotNull Template template)
{
	template.addTextSegment(CreateUnresolvedMethodFix.calcModifier(context).getPresentableText());
	template.addTextSegment(" ");
	if(contextType == CSharpContextUtil.ContextType.STATIC)
	{
		template.addTextSegment("static ");
	}
	template.addVariable(new TypeRefExpression(myLikeMethod.getReturnTypeRef(), file), true);
	template.addTextSegment(" ");
	template.addTextSegment(myReferenceName);

	buildParameterList(context, file, template);

	template.addTextSegment("{\n");

	template.addVariable("$RETURN_STATEMENT$", new ReturnStatementExpression(), false);
	template.addEndVariable();

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

示例3: insertMethod

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@Override
protected void insertMethod(@NotNull Project project, @NotNull Editor editor) {
    Template template = TemplateManager.getInstance(project).createTemplate("", "");
    template.addTextSegment("protected function setUp()\n{\n");
    template.addTextSegment("parent::setUp();\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,代码行数:13,代码来源:TesterGenerateSetupMethodAction.java

示例4: insertMethod

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@Override
protected void insertMethod(@NotNull Project project, @NotNull Editor editor) {
    Template template = TemplateManager.getInstance(project).createTemplate("", "");
    template.addTextSegment("protected function tearDown()\n{\n");
    template.addTextSegment("parent::tearDown();\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,代码行数:13,代码来源:TesterGenerateTeardownMethodAction.java

示例5: completeAttribute

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

示例6: completeTagTail

import com.intellij.codeInsight.template.Template; //导入方法依赖的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: addTextTo

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
protected void addTextTo(Template template, XmlTag rootTag) {
  String schemaPrefix = rootTag.getPrefixByNamespace(XmlUtil.XML_SCHEMA_URI);
  if (!schemaPrefix.isEmpty()) schemaPrefix += ":";

  template.addTextSegment(
    "<" + schemaPrefix + myDeclarationTagName + " name=\"" + XmlUtil.findLocalNameByQualifiedName(myRef.getCanonicalText()) + "\">"
  );
  template.addEndVariable();
  template.addTextSegment(
    "</" + schemaPrefix + myDeclarationTagName + ">\n"
  );
  template.setToReformat(true);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:14,代码来源:CreateXmlElementIntentionAction.java

示例8: addTextTo

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
protected void addTextTo(Template template, XmlTag rootTag) {
  String schemaPrefix = rootTag.getPrefixByNamespace(XmlUtil.XML_SCHEMA_URI);
  if (schemaPrefix.length() > 0) schemaPrefix += ":";

  template.addTextSegment(
    "<" + schemaPrefix + myDeclarationTagName + " name=\"" + XmlUtil.findLocalNameByQualifiedName(myRef.getCanonicalText()) + "\">"
  );
  template.addEndVariable();
  template.addTextSegment(
    "</" + schemaPrefix + myDeclarationTagName + ">\n"
  );
  template.setToReformat(true);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:14,代码来源:CreateXmlElementIntentionAction.java

示例9: buildTemplate

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@RequiredReadAction
@Override
public void buildTemplate(@NotNull CreateUnresolvedElementFixContext context,
		CSharpContextUtil.ContextType contextType,
		@NotNull PsiFile file,
		@NotNull Template template)
{
	template.addTextSegment("public ");

	if(contextType == CSharpContextUtil.ContextType.STATIC)
	{
		template.addTextSegment("static ");
	}

	template.addTextSegment("event ");

	// get expected from method call expression not reference
	List<ExpectedTypeInfo> expectedTypeRefs = ExpectedTypeVisitor.findExpectedTypeRefs(context.getExpression());

	if(!expectedTypeRefs.isEmpty())
	{
		template.addVariable(new TypeRefExpression(expectedTypeRefs, file), true);
	}
	else
	{
		template.addVariable(new TypeRefExpression(new CSharpTypeRefByQName(file, DotNetTypes.System.Object), file), true);
	}

	template.addTextSegment(" ");
	template.addTextSegment(myReferenceName);
	template.addTextSegment("\n{\n");
	template.addTextSegment("add;remove;\n");
	template.addTextSegment("}");
	template.addEndVariable();
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:36,代码来源:CreateUnresolvedEventFix.java

示例10: buildTemplate

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@RequiredReadAction
@Override
public void buildTemplate(@NotNull CreateUnresolvedElementFixContext context, CSharpContextUtil.ContextType contextType, @NotNull PsiFile file, @NotNull Template template)
{
	template.addTextSegment("public ");
	template.addTextSegment(myReferenceName);
	buildParameterList(context, file, template);
	template.addTextSegment("{\n");
	template.addEndVariable();
	template.addTextSegment("}");
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:12,代码来源:CreateUnresolvedConstructorFix.java

示例11: buildTemplate

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@RequiredReadAction
@Override
public void buildTemplate(@NotNull CreateUnresolvedElementFixContext context, CSharpContextUtil.ContextType contextType, @NotNull PsiFile file, @NotNull Template template)
{
	template.addTextSegment("public ");

	if(contextType == CSharpContextUtil.ContextType.STATIC)
	{
		template.addTextSegment("static ");
	}

	// get expected from method call expression not reference
	List<ExpectedTypeInfo> expectedTypeRefs = ExpectedTypeVisitor.findExpectedTypeRefs(context.getExpression());

	if(!expectedTypeRefs.isEmpty())
	{
		template.addVariable(new TypeRefExpression(expectedTypeRefs, file), true);
	}
	else
	{
		template.addVariable(new TypeRefExpression(new CSharpTypeRefByQName(file, DotNetTypes.System.Object), file), true);
	}

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

示例12: buildTemplate

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@RequiredReadAction
@Override
public void buildTemplate(@NotNull CreateUnresolvedElementFixContext context,
		CSharpContextUtil.ContextType contextType,
		@NotNull PsiFile file,
		@NotNull Template template)
{
	template.addTextSegment("public ");

	if(contextType == CSharpContextUtil.ContextType.STATIC)
	{
		template.addTextSegment("static ");
	}

	// get expected from method call expression not reference
	List<ExpectedTypeInfo> expectedTypeRefs = ExpectedTypeVisitor.findExpectedTypeRefs(context.getExpression());

	if(!expectedTypeRefs.isEmpty())
	{
		template.addVariable(new TypeRefExpression(expectedTypeRefs, file), true);
	}
	else
	{
		template.addVariable(new TypeRefExpression(new CSharpTypeRefByQName(file, DotNetTypes.System.Object), file), true);
	}

	template.addTextSegment(" ");
	template.addTextSegment(myReferenceName);
	template.addTextSegment("\n{\n");
	template.addTextSegment("get;set;\n");
	template.addTextSegment("}");
	template.addEndVariable();
}
 
开发者ID:consulo,项目名称:consulo-csharp,代码行数:34,代码来源:CreateUnresolvedPropertyFix.java

示例13: completeAttribute

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

示例14: addTextTo

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
protected void addTextTo(Template template, XmlTag rootTag) {
	String schemaPrefix = rootTag.getPrefixByNamespace(XmlUtil.XML_SCHEMA_URI);
	if (!schemaPrefix.isEmpty()) schemaPrefix += ":";

	template.addTextSegment(
			"<" + schemaPrefix + myDeclarationTagName + " name=\"" + XmlUtil.findLocalNameByQualifiedName(myRef.getCanonicalText()) + "\">"
	);
	template.addEndVariable();
	template.addTextSegment(
			"</" + schemaPrefix + myDeclarationTagName + ">\n"
	);
	template.setToReformat(true);
}
 
开发者ID:consulo,项目名称:consulo-xml,代码行数:14,代码来源:CreateXmlElementIntentionAction.java

示例15: buildTemplate

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@RequiredReadAction
@Override
protected void buildTemplate(Template template, JSReferenceExpression referenceExpression, Set<JavaScriptFeature> features, boolean staticContext, PsiFile file,
		PsiElement anchorParent)
{
	boolean classFeature = features.contains(JavaScriptFeature.CLASS);
	String referencedName = classFeature ? referenceExpression.getReferencedName() : referenceExpression.getText();
	BaseCreateFix.addAccessModifier(template, referenceExpression, classFeature, staticContext);
	writeFunctionAndName(template, referencedName, features);
	template.addTextSegment("(");

	addParameters(template, referenceExpression, file, features);

	template.addTextSegment(")");

	if(classFeature)
	{
		template.addTextSegment(":");
		addReturnType(template, referenceExpression, file);
	}

	JSClass clazz = BaseCreateFix.findClass(file, anchorParent);
	if(clazz == null || !clazz.isInterface())
	{
		template.addTextSegment(" {");
		addBody(template, referenceExpression, file);
		template.addTextSegment("}");
	}
	else
	{
		addSemicolonSegment(template, file);
		template.addEndVariable();
	}
}
 
开发者ID:consulo,项目名称:consulo-javascript,代码行数:35,代码来源:CreateJSFunctionFixBase.java


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