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


Java PsiUtil.isApplicable方法代码示例

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


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

示例1: registerSwapFixes

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static void registerSwapFixes(final PsiExpression[] expressions, final PsiCall callExpression, final List<PsiCall> permutations,
                                      MethodCandidateInfo candidate, final int incompatibilitiesCount, final int minIncompatibleIndex,
                                      final int maxIncompatibleIndex) throws IncorrectOperationException {
  PsiMethod method = candidate.getElement();
  PsiSubstitutor substitutor = candidate.getSubstitutor();
  if (incompatibilitiesCount >= 3) return; // no way we can fix it by swapping

  for (int i = minIncompatibleIndex; i < maxIncompatibleIndex; i++) {
    for (int j = i+1; j <= maxIncompatibleIndex; j++) {
      ArrayUtil.swap(expressions, i, j);
      if (PsiUtil.isApplicable(method, substitutor, expressions)) {
        PsiCall copy = (PsiCall)callExpression.copy();
        PsiExpression[] copyExpressions = copy.getArgumentList().getExpressions();
        copyExpressions[i].replace(expressions[i]);
        copyExpressions[j].replace(expressions[j]);
        JavaResolveResult result = copy.resolveMethodGenerics();
        if (result.getElement() != null && result.isValidResult()) {
          permutations.add(copy);
          if (permutations.size() > 1) return;
        }
      }
      ArrayUtil.swap(expressions, i, j);
    }
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:26,代码来源:PermuteArgumentsFix.java

示例2: isMethodSignatureExists

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
private static boolean isMethodSignatureExists(PsiMethodCallExpression call, PsiClass target) {
  String name = call.getMethodExpression().getReferenceName();
  final JavaResolveResult resolveResult = call.getMethodExpression().advancedResolve(false);
  PsiExpressionList list = call.getArgumentList();
  PsiMethod[] methods = target.findMethodsByName(name, false);
  for (PsiMethod method : methods) {
    if (PsiUtil.isApplicable(method, resolveResult.getSubstitutor(), list)) return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:CreateMethodFromUsageFix.java

示例3: isValidMethodReference

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
static boolean isValidMethodReference(PsiReference reference, PsiMethodCallExpression call) {
  if (!(reference instanceof PsiJavaReference)) return false;
  try {
    JavaResolveResult candidate = ((PsiJavaReference) reference).advancedResolve(true);
    PsiElement result = candidate.getElement();
    return result instanceof PsiMethod && PsiUtil.isApplicable((PsiMethod)result, candidate.getSubstitutor(), call.getArgumentList());
  }
  catch (ClassCastException cce) {
    // rear case
    return false;
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:13,代码来源:CreateFromUsageUtils.java

示例4: shouldCreateConstructor

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
static boolean shouldCreateConstructor(PsiClass targetClass, PsiExpressionList argList, PsiMethod candidate) {
  if (argList == null) return false;
  if (candidate == null) {
    return targetClass != null && !targetClass.isInterface() && !(targetClass instanceof PsiTypeParameter) &&
           !(argList.getExpressions().length == 0 && targetClass.getConstructors().length == 0);
  }
  else {
    return !PsiUtil.isApplicable(candidate, PsiSubstitutor.EMPTY, argList);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:11,代码来源:CreateFromUsageUtils.java

示例5: isMethodSignatureExists

import com.intellij.psi.util.PsiUtil; //导入方法依赖的package包/类
public boolean isMethodSignatureExists() {
  PsiClass target = myTargetMethod.getContainingClass();
  LOG.assertTrue(target != null);
  PsiMethod[] methods = target.findMethodsByName(myTargetMethod.getName(), false);
  for (PsiMethod method : methods) {
    if (PsiUtil.isApplicable(method, PsiSubstitutor.EMPTY, myExpressions)) return true;
  }
  return false;
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:10,代码来源:ChangeMethodSignatureFromUsageFix.java


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