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


Java GenerateMembersUtil.substituteGenericMethod方法代码示例

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


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

示例1: generateMethodPrototype

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
public static GrMethod generateMethodPrototype(GrTypeDefinition aClass,
                                               PsiMethod method,
                                               PsiSubstitutor substitutor) {
  final Project project = aClass.getProject();
  final boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT);

  String templName = isAbstract ? JavaTemplateUtil.TEMPLATE_IMPLEMENTED_METHOD_BODY : JavaTemplateUtil.TEMPLATE_OVERRIDDEN_METHOD_BODY;
  final FileTemplate template = FileTemplateManager.getInstance(method.getProject()).getCodeTemplate(templName);
  final GrMethod result = (GrMethod)GenerateMembersUtil.substituteGenericMethod(method, substitutor, aClass);

  setupModifierList(result);
  setupOverridingMethodBody(project, method, result, template, substitutor);
  setupReturnType(result, method);

  setupAnnotations(aClass, method, result);

  GroovyChangeContextUtil.encodeContextInfo(result);
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:20,代码来源:GroovyOverrideImplementUtil.java

示例2: generateMethodPrototype

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
public static GrMethod generateMethodPrototype(GrTypeDefinition aClass,
                                               PsiMethod method,
                                               PsiSubstitutor substitutor) {
  final Project project = aClass.getProject();
  final boolean isAbstract = method.hasModifierProperty(PsiModifier.ABSTRACT);

  String templName = isAbstract ? JavaTemplateUtil.TEMPLATE_IMPLEMENTED_METHOD_BODY : JavaTemplateUtil.TEMPLATE_OVERRIDDEN_METHOD_BODY;
  final FileTemplate template = FileTemplateManager.getInstance().getCodeTemplate(templName);
  final GrMethod result = (GrMethod)GenerateMembersUtil.substituteGenericMethod(method, substitutor, aClass);

  setupModifierList(result);
  setupOverridingMethodBody(project, method, result, template, substitutor);
  setupReturnType(result, method);

  setupAnnotations(aClass, method, result);

  GroovyChangeContextUtil.encodeContextInfo(result);
  return result;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:20,代码来源:GroovyOverrideImplementUtil.java

示例3: delegateMethod

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
private PsiMethod delegateMethod(@NonNls String delegationTarget,
                                 PsiMethod method,
                                 PsiSubstitutor substitutor) throws IncorrectOperationException {
  substitutor = OverrideImplementUtil.correctSubstitutor(method, substitutor);
  PsiMethod methodToAdd = GenerateMembersUtil.substituteGenericMethod(method, substitutor);

  final PsiModifierList modifierList = methodToAdd.getModifierList();
  final NullableNotNullManager manager = NullableNotNullManager.getInstance(myProject);
  modifierList.setModifierProperty(PsiModifier.ABSTRACT, false);
  final PsiAnnotation nullable = manager.copyNullableAnnotation(method);
  if (nullable != null) {
    modifierList.addAfter(nullable, null);
  }
  else {
    final PsiAnnotation notNull = manager.copyNotNullAnnotation(method);
    if (notNull != null) {
      modifierList.addAfter(notNull, null);
    }
  }

  final String delegationBody = getDelegationBody(methodToAdd, delegationTarget);
  PsiCodeBlock newBody = myFactory.createCodeBlockFromText(delegationBody, method);

  PsiCodeBlock oldBody = methodToAdd.getBody();
  if (oldBody != null) {
    oldBody.replace(newBody);
  }
  else {
    methodToAdd.addBefore(newBody, null);
  }

  if (methodToAdd.getDocComment() != null) methodToAdd.getDocComment().delete();
  methodToAdd = (PsiMethod)CodeStyleManager.getInstance(myProject).reformat(methodToAdd);
  methodToAdd = (PsiMethod)JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(methodToAdd);
  return methodToAdd;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:37,代码来源:InheritanceToDelegationProcessor.java

示例4: generateTraitMethodPrototype

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
public static GrMethod generateTraitMethodPrototype(GrTypeDefinition aClass, GrTraitMethod method, PsiSubstitutor substitutor) {
  final Project project = aClass.getProject();

  final GrMethod result = (GrMethod)GenerateMembersUtil.substituteGenericMethod(method, substitutor, aClass);

  setupModifierList(result);
  setupTraitMethodBody(project, result, method);
  setupReturnType(result, method);

  setupAnnotations(aClass, method, result);

  GroovyChangeContextUtil.encodeContextInfo(result);
  return result;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:15,代码来源:GroovyOverrideImplementUtil.java

示例5: delegateMethod

import com.intellij.codeInsight.generation.GenerateMembersUtil; //导入方法依赖的package包/类
private PsiMethod delegateMethod(@NonNls String delegationTarget,
                                 PsiMethod method,
                                 PsiSubstitutor substitutor) throws IncorrectOperationException {
  substitutor = OverrideImplementUtil.correctSubstitutor(method, substitutor);
  PsiMethod methodToAdd = GenerateMembersUtil.substituteGenericMethod(method, substitutor);

  final PsiModifierList modifierList = methodToAdd.getModifierList();
  final NullableNotNullManager manager = NullableNotNullManager.getInstance(myProject);
  modifierList.setModifierProperty(PsiModifier.ABSTRACT, false);
  final String nullable = manager.getNullable(method);
  if (nullable != null) {
    modifierList.addAfter(myFactory.createAnnotationFromText("@" + nullable, methodToAdd), null);
  }
  else {
    final String notNull = manager.getNotNull(method);
    if (notNull != null) {
      modifierList.addAfter(myFactory.createAnnotationFromText("@" + notNull, methodToAdd), null);
    }
  }

  final String delegationBody = getDelegationBody(methodToAdd, delegationTarget);
  PsiCodeBlock newBody = myFactory.createCodeBlockFromText(delegationBody, method);

  PsiCodeBlock oldBody = methodToAdd.getBody();
  if (oldBody != null) {
    oldBody.replace(newBody);
  }
  else {
    methodToAdd.addBefore(newBody, null);
  }

  if (methodToAdd.getDocComment() != null) methodToAdd.getDocComment().delete();
  methodToAdd = (PsiMethod)CodeStyleManager.getInstance(myProject).reformat(methodToAdd);
  methodToAdd = (PsiMethod)JavaCodeStyleManager.getInstance(myProject).shortenClassReferences(methodToAdd);
  return methodToAdd;
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:37,代码来源:InheritanceToDelegationProcessor.java


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