本文整理汇总了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);
}
}
}
示例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;
}
示例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;
}
}
示例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);
}
}
示例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;
}