本文整理匯總了Java中com.intellij.psi.PsiMethod.equals方法的典型用法代碼示例。如果您正苦於以下問題:Java PsiMethod.equals方法的具體用法?Java PsiMethod.equals怎麽用?Java PsiMethod.equals使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.intellij.psi.PsiMethod
的用法示例。
在下文中一共展示了PsiMethod.equals方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: insertNewMethod
import com.intellij.psi.PsiMethod; //導入方法依賴的package包/類
public PsiMethod insertNewMethod(PsiClass clazz, @NotNull PsiMethod newMethod, Editor editor) {
// if main method exists and is the last then add toString just before main method
PsiMethod mainMethod = PsiAdapter.findPublicStaticVoidMainMethod(clazz);
if (mainMethod != null) {
// add before main method if it is the last method
PsiMethod[] methods = clazz.getMethods();
if (mainMethod.equals(methods[methods.length - 1])) {
return (PsiMethod) clazz.addBefore(newMethod, mainMethod); // return as the method is added
}
}
// otherwise add it at the end
PsiElement last = clazz.getRBrace(); // rbrace is the last } java token. fixes bug #9
return (PsiMethod) clazz.addBefore(newMethod, last);
}
示例2: isTheLastClassRef
import com.intellij.psi.PsiMethod; //導入方法依賴的package包/類
static PsiMethod isTheLastClassRef(PsiElement element, PsiMethod member) {
final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class, false);
if ( containingMethod != null &&
!containingMethod.hasModifierProperty(PsiModifier.STATIC) &&
!containingMethod.isConstructor() &&
containingMethod.findDeepestSuperMethods().length == 0 &&
!containingMethod.equals(member)) {
final PsiClass containingClass = containingMethod.getContainingClass();
if (containingClass != null) {
final PsiClass gContainingClass = containingClass.getContainingClass();
if (gContainingClass == null || gContainingClass.hasModifierProperty(PsiModifier.STATIC)) {
final InternalUsageInfo[] refsInMember = MakeStaticUtil.findClassRefsInMember(containingMethod, true);
for (InternalUsageInfo info : refsInMember) {
final PsiElement referencedElement = info.getReferencedElement();
if (!member.equals(referencedElement) && !containingMethod.equals(referencedElement)) {
return null;
}
}
return containingMethod;
}
}
}
return null;
}
示例3: methodCallExpressionDefinitelyRecurses
import com.intellij.psi.PsiMethod; //導入方法依賴的package包/類
private static boolean methodCallExpressionDefinitelyRecurses(
GrMethodCallExpression exp, GrMethod method) {
final GrExpression invoked = exp.getInvokedExpression();
if (invoked instanceof GrReferenceExpression) {
final GrReferenceExpression methodExpression = (GrReferenceExpression) invoked;
final PsiMethod referencedMethod = exp.resolveMethod();
if (referencedMethod == null) {
return false;
}
final GrExpression qualifier =
methodExpression.getQualifierExpression();
if (referencedMethod.equals(method)) {
if (method.hasModifierProperty(PsiModifier.STATIC) ||
method.hasModifierProperty(PsiModifier.PRIVATE)) {
return true;
}
if (qualifier == null || qualifier instanceof GrReferenceExpression && PsiUtil.isThisReference(qualifier)) {
return true;
}
}
if (expressionDefinitelyRecurses(qualifier, method)) {
return true;
}
}
return callExpressionDefinitelyRecurses(exp, method);
}
示例4: invoke
import com.intellij.psi.PsiMethod; //導入方法依賴的package包/類
private static void invoke(PsiMethod method, final Project project) {
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, method)) return;
if (method instanceof GrReflectedMethod) method = ((GrReflectedMethod)method).getBaseMethod();
PsiMethod newMethod = SuperMethodWarningUtil.checkSuperMethod(method, RefactoringBundle.message("to.refactor"));
if (newMethod == null) return;
if (!newMethod.equals(method)) {
ChangeSignatureUtil.invokeChangeSignatureOn(newMethod, project);
return;
}
if (!CommonRefactoringUtil.checkReadOnlyStatus(project, method)) return;
if (!(method instanceof GrMethod)) return; //todo
final GrChangeSignatureDialog dialog = new GrChangeSignatureDialog(project, new GrMethodDescriptor((GrMethod)method), true, null);
dialog.show();
}
示例5: newExpressionsAreEquivalent
import com.intellij.psi.PsiMethod; //導入方法依賴的package包/類
private static boolean newExpressionsAreEquivalent(@NotNull GrNewExpression newExp1,
@NotNull GrNewExpression newExp2) {
final PsiMethod constructor1 = newExp1.resolveMethod();
final PsiMethod constructor2 = newExp2.resolveMethod();
if (constructor1 == null || constructor2 == null || constructor1.equals(constructor2)) {
return false;
}
return argumentListsAreEquivalent(newExp1.getArgumentList(), newExp2.getArgumentList());
}