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


Java GenerateMembersUtil.generateSetterPrototype方法代码示例

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


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

示例1: generateMethodPrototype

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
@Override
@Nullable
public PsiMethod generateMethodPrototype(@NotNull PsiField field, @NotNull String methodName, boolean isGetter) {
  PsiMethod prototype = isGetter
                        ? GenerateMembersUtil.generateGetterPrototype(field)
                        : GenerateMembersUtil.generateSetterPrototype(field);
  try {
    prototype.setName(methodName);
    return prototype;
  }
  catch (IncorrectOperationException e) {
    return null;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:JavaEncapsulateFieldHelper.java

示例2: beforeTemplateFinished

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
@Override
protected void beforeTemplateFinished(PsiClass aClass, PsiField field) {
  PsiMethod getterPrototype = GenerateMembersUtil.generateGetterPrototype(field);
  if (aClass.findMethodsBySignature(getterPrototype, false).length == 0) {
    aClass.add(getterPrototype);
  }


  PsiMethod setterPrototype = GenerateMembersUtil.generateSetterPrototype(field);
  if (aClass.findMethodsBySignature(setterPrototype, false).length == 0) {
    aClass.add(setterPrototype);
  }
  
  super.beforeTemplateFinished(aClass, field);
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:16,代码来源:CreateGetterSetterPropertyFromUsageFix.java

示例3: generateMethodPrototype

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
private PsiMethod generateMethodPrototype(PsiField field, String methodName, boolean isGetter) {
  PsiMethod prototype = isGetter
                        ? GenerateMembersUtil.generateGetterPrototype(field)
                        : GenerateMembersUtil.generateSetterPrototype(field);
  try {
    PsiElementFactory factory = JavaPsiFacade.getInstance(field.getProject()).getElementFactory();
    PsiIdentifier identifier = factory.createIdentifier(methodName);
    prototype.getNameIdentifier().replace(identifier);
    //prototype.getModifierList().setModifierProperty(getAccessorsVisibility(), true);
    return prototype;
  } catch (IncorrectOperationException e) {
    return null;
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:15,代码来源:EncapsulateFieldsDialog.java

示例4: doTest

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
private static void doTest(final PsiClass aClass,
                           final String conflicts,
                           final boolean generateGetters,
                           final boolean generateSetters,
                           final PsiField... fields) {
  try {
    final Project project = aClass.getProject();
    EncapsulateFieldsProcessor processor = new EncapsulateFieldsProcessor(project, new EncapsulateFieldsDescriptor() {
      @Override
      public FieldDescriptor[] getSelectedFields() {
        final FieldDescriptor[] descriptors = new FieldDescriptor[fields.length];
        for (int i = 0; i < fields.length; i++) {
          descriptors[i] = new FieldDescriptorImpl(
            fields[i],
            GenerateMembersUtil.suggestGetterName(fields[i]),
            GenerateMembersUtil.suggestSetterName(fields[i]),
            isToEncapsulateGet() ? GenerateMembersUtil.generateGetterPrototype(fields[i]) : null,
            isToEncapsulateSet() ? GenerateMembersUtil.generateSetterPrototype(fields[i]) : null
          );
        }
        return descriptors;
      }

      @Override
      public boolean isToEncapsulateGet() {
        return generateGetters;
      }

      @Override
      public boolean isToEncapsulateSet() {
        return generateSetters;
      }

      @Override
      public boolean isToUseAccessorsWhenAccessible() {
        return true;
      }

      @Override
      public String getFieldsVisibility() {
        return null;
      }

      @Override
      public String getAccessorsVisibility() {
        return PsiModifier.PUBLIC;
      }

      @Override
      public int getJavadocPolicy() {
        return DocCommentPolicy.MOVE;
      }

      @Override
      public PsiClass getTargetClass() {
        return aClass;
      }
    });
    processor.run();
    LocalFileSystem.getInstance().refresh(false);
    FileDocumentManager.getInstance().saveAllDocuments();
  }
  catch (BaseRefactoringProcessor.ConflictsInTestsException e) {
    if (conflicts != null) {
      Assert.assertEquals(conflicts, e.getMessage());
      return;
    }
    else {
      e.printStackTrace();
      fail(e.getMessage());
    }
  }
  if (conflicts != null) {
    fail("Conflicts were not detected: " + conflicts);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:77,代码来源:EncapsulateFieldsTest.java


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