本文整理匯總了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);
}
}