本文整理汇总了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);
}
示例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("}");
}
示例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);
}
示例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);
}
示例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("\"");
}
示例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;
}
}
示例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);
}
示例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);
}
示例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();
}
示例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("}");
}
示例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();
}
示例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();
}
示例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("\"");
}
示例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);
}
示例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();
}
}