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


Java PsiMethod.getSignature方法代码示例

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


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

示例1: visitMethod

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
@Override
public void visitMethod(@NotNull PsiMethod method) {
  final PsiClass aClass = method.getContainingClass();
  if (aClass == null) {
    return;
  }
  if (method.getNameIdentifier() == null) {
    return;
  }
  final String methodName = method.getName();
  final MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY);
  PsiClass ancestorClass = aClass.getSuperClass();
  final Set<PsiClass> visitedClasses = new HashSet<PsiClass>();
  while (ancestorClass != null) {
    if (!visitedClasses.add(ancestorClass)) {
      return;
    }
    final PsiMethod[] methods =
      ancestorClass.findMethodsByName(methodName, false);
    for (final PsiMethod testMethod : methods) {
      final MethodSignature testSignature = testMethod.getSignature(PsiSubstitutor.EMPTY);
      if (!signature.equals(testSignature)) {
        continue;
      }
      if (testMethod.hasModifierProperty(PsiModifier.STATIC) &&
          !testMethod.hasModifierProperty(PsiModifier.PRIVATE)) {
        registerMethodError(method);
        return;
      }
    }
    ancestorClass = ancestorClass.getSuperClass();
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:34,代码来源:MethodOverridesStaticMethodInspectionBase.java

示例2: GrMethodCallUsageInfo

import com.intellij.psi.PsiMethod; //导入方法依赖的package包/类
public GrMethodCallUsageInfo(PsiElement element, boolean isToChangeArguments, boolean isToCatchExceptions, PsiMethod method) {
  super(element);
  final GroovyResolveResult resolveResult = resolveMethod(element);
  if (resolveResult == null || resolveResult.getElement() == null) {
    mySubstitutor = PsiSubstitutor.EMPTY;
  }
  else if (resolveResult.getElement() instanceof PsiMethod) {
    PsiMethod resolved = (PsiMethod)resolveResult.getElement();
    mySubstitutor = resolveResult.getSubstitutor();
    if (!element.getManager().areElementsEquivalent(method, resolved)) {
      final PsiClass baseClass = method.getContainingClass();
      final PsiClass derivedClass = resolved.getContainingClass();
      if (baseClass != null && derivedClass != null && InheritanceUtil.isInheritorOrSelf(derivedClass, baseClass, true)) {
        final PsiSubstitutor superClassSubstitutor = TypeConversionUtil.getSuperClassSubstitutor(baseClass, derivedClass, mySubstitutor);
        final MethodSignature superMethodSignature = method.getSignature(superClassSubstitutor);
        final MethodSignature methodSignature = resolved.getSignature(PsiSubstitutor.EMPTY);
        final PsiSubstitutor superMethodSignatureSubstitutor =
          MethodSignatureUtil.getSuperMethodSignatureSubstitutor(methodSignature, superMethodSignature);
        mySubstitutor = TypesUtil.composeSubstitutors(superMethodSignatureSubstitutor, mySubstitutor);
      }
    }
  }
  GrClosureSignature signature = GrClosureSignatureUtil.createSignature(method, mySubstitutor);
  myToChangeArguments = isToChangeArguments;
  myToCatchExceptions = isToCatchExceptions;
  final GrCall call = GroovyRefactoringUtil.getCallExpressionByMethodReference(element);
  if (call == null) {
    myMapToArguments = GrClosureSignatureUtil.ArgInfo.empty_array();
  }
  else {
    myMapToArguments = GrClosureSignatureUtil.mapParametersToArguments(signature, call.getNamedArguments(), call.getExpressionArguments(),
                                                                       call.getClosureArguments(), call, false, false);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:GrMethodCallUsageInfo.java


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