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


Java Template.setToShortenLongNames方法代码示例

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


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

示例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 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

示例4: setupTemplateImpl

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@Override
public Template setupTemplateImpl(PsiField field,
                                  Object expectedTypes,
                                  PsiClass targetClass,
                                  Editor editor,
                                  PsiElement context,
                                  boolean createConstantField,
                                  PsiSubstitutor substitutor) {
  PsiElementFactory factory = JavaPsiFacade.getElementFactory(field.getProject());

  field = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(field);
  TemplateBuilderImpl builder = new TemplateBuilderImpl(field);
  if (!(expectedTypes instanceof ExpectedTypeInfo[])) {
    expectedTypes = ExpectedTypeInfo.EMPTY_ARRAY;
  }
  new GuessTypeParameters(factory).setupTypeElement(field.getTypeElement(), (ExpectedTypeInfo[])expectedTypes, substitutor, builder,
                                                    context, targetClass);

  if (createConstantField) {
    field.setInitializer(factory.createExpressionFromText("0", null));
    builder.replaceElement(field.getInitializer(), new EmptyExpression());
    PsiIdentifier identifier = field.getNameIdentifier();
    builder.setEndVariableAfter(identifier);
    field = CodeInsightUtilCore.forcePsiPostprocessAndRestoreElement(field);
  }
  editor.getCaretModel().moveToOffset(field.getTextRange().getStartOffset());
  Template template = builder.buildInlineTemplate();
  if (((ExpectedTypeInfo[])expectedTypes).length > 1) template.setToShortenLongNames(false);
  return template;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:31,代码来源:JavaCreateFieldFromUsageHelper.java

示例5: setupTemplateImpl

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@Override
public Template setupTemplateImpl(PsiField field,
                                  Object expectedTypes,
                                  PsiClass targetClass,
                                  Editor editor,
                                  PsiElement context,
                                  boolean createConstantField,
                                  PsiSubstitutor substitutor) {
  PsiElementFactory factory = JavaPsiFacade.getElementFactory(field.getProject());

  field = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(field);
  TemplateBuilderImpl builder = new TemplateBuilderImpl(field);
  if (!(expectedTypes instanceof ExpectedTypeInfo[])) {
    expectedTypes = ExpectedTypeInfo.EMPTY_ARRAY;
  }
  new GuessTypeParameters(factory).setupTypeElement(field.getTypeElement(), (ExpectedTypeInfo[])expectedTypes, substitutor, builder,
                                                    context, targetClass);

  if (createConstantField) {
    field.setInitializer(factory.createExpressionFromText("0", null));
    builder.replaceElement(field.getInitializer(), new EmptyExpression());
    PsiIdentifier identifier = field.getNameIdentifier();
    builder.setEndVariableAfter(identifier);
    field = CodeInsightUtilBase.forcePsiPostprocessAndRestoreElement(field);
  }
  editor.getCaretModel().moveToOffset(field.getTextRange().getStartOffset());
  Template template = builder.buildInlineTemplate();
  if (((ExpectedTypeInfo[])expectedTypes).length > 1) template.setToShortenLongNames(false);
  return template;
}
 
开发者ID:consulo,项目名称:consulo-java,代码行数:31,代码来源:JavaCreateFieldFromUsageHelper.java

示例6: setEnabled

import com.intellij.codeInsight.template.Template; //导入方法依赖的package包/类
@Override
public void setEnabled(final Template template, final boolean value) {
  template.setToShortenLongNames(value);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:5,代码来源:ShortenFQNamesProcessor.java

示例7: createTestMethodTemplate

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

示例8: createTestMethodTemplate

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

示例9: createTestMethodTemplate

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