當前位置: 首頁>>代碼示例>>Java>>正文


Java PsiMethod.equals方法代碼示例

本文整理匯總了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);
    }
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:17,代碼來源:InsertLastStrategy.java

示例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;
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:25,代碼來源:MakeStaticJavaCallerChooser.java

示例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);
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:27,代碼來源:RecursionUtils.java

示例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();
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:19,代碼來源:GrChangeSignatureHandler.java

示例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());
}
 
開發者ID:jskierbi,項目名稱:intellij-ce-playground,代碼行數:10,代碼來源:EquivalenceChecker.java


注:本文中的com.intellij.psi.PsiMethod.equals方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。