本文整理汇总了Java中com.intellij.psi.infos.MethodCandidateInfo.getCurrentMethod方法的典型用法代码示例。如果您正苦于以下问题:Java MethodCandidateInfo.getCurrentMethod方法的具体用法?Java MethodCandidateInfo.getCurrentMethod怎么用?Java MethodCandidateInfo.getCurrentMethod使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.intellij.psi.infos.MethodCandidateInfo
的用法示例。
在下文中一共展示了MethodCandidateInfo.getCurrentMethod方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCalledMethod
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static PsiMethod getCalledMethod(PsiCall arg) {
final PsiExpressionList argumentList = arg.getArgumentList();
if (argumentList == null) {
return null;
}
MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
if (properties != null) {
return properties.getMethod();
}
final JavaResolveResult resolveResult = getMethodResult(arg);
if (resolveResult instanceof MethodCandidateInfo) {
return (PsiMethod)resolveResult.getElement();
}
else {
return null;
}
}
示例2: collectAdditionalConstraints
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private void collectAdditionalConstraints(final Set<ConstraintFormula> additionalConstraints,
final PsiCall callExpression) {
PsiExpressionList argumentList = callExpression.getArgumentList();
if (argumentList != null) {
final JavaResolveResult result = getMethodResult(callExpression);
MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
final PsiMethod method = result instanceof MethodCandidateInfo ? ((MethodCandidateInfo)result).getElement() : properties != null ? properties.getMethod() : null;
if (method != null) {
final PsiExpression[] newArgs = argumentList.getExpressions();
final PsiParameter[] newParams = method.getParameterList().getParameters();
if (newParams.length > 0) {
collectAdditionalConstraints(newParams, newArgs, method, chooseSiteSubstitutor(properties, result, method), additionalConstraints, chooseVarargsMode(properties, result));
}
}
}
}
示例3: getMethodResult
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static JavaResolveResult getMethodResult(final PsiCall callExpression) {
final PsiExpressionList argumentList = callExpression.getArgumentList();
final PsiLambdaExpression expression = PsiTreeUtil.getParentOfType(argumentList, PsiLambdaExpression.class);
final Computable<JavaResolveResult> computableResolve = new Computable<JavaResolveResult>() {
@Override
public JavaResolveResult compute() {
return getResolveResult(callExpression, argumentList);
}
};
MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
return properties != null ? null :
expression == null || !PsiResolveHelper.ourGraphGuard.currentStack().contains(expression)
? computableResolve.compute()
: PsiResolveHelper.ourGraphGuard.doPreventingRecursion(expression, false, computableResolve);
}
示例4: TypeParamsChecker
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public TypeParamsChecker(PsiElement expression, PsiClass aClass) {
myClass = aClass;
PsiElement parent = expression != null ? expression.getParent() : null;
while (parent instanceof PsiParenthesizedExpression) {
parent = parent.getParent();
}
if (parent instanceof PsiExpressionList) {
final PsiElement gParent = parent.getParent();
if (gParent instanceof PsiCall) {
final MethodCandidateInfo.CurrentCandidateProperties pair = MethodCandidateInfo.getCurrentMethod(parent);
myMethod = pair != null ? pair.getMethod() : null;
if (myMethod == null) {
myMethod = ((PsiCall)gParent).resolveMethod();
}
if (myMethod != null && PsiTreeUtil.isAncestor(myMethod, expression, false)) {
myMethod = null;
}
}
}
}
示例5: resolveConflict
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Override
public final CandidateInfo resolveConflict(@NotNull final List<CandidateInfo> conflicts)
{
final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(myArgumentsList);
if(properties != null && properties.isApplicabilityCheck())
{
final PsiMethod method = properties.getMethod();
LOG.error("Recursive conflict resolution for:" + method + "; " +
myArgumentsList.getText() + "; " +
"file=" + (method == null ? "<unknown>" : method.getContainingFile()));
}
return MethodCandidateInfo.ourOverloadGuard.doPreventingRecursion(myArgumentsList, false, new Computable<CandidateInfo>()
{
@Override
public CandidateInfo compute()
{
return guardedOverloadResolution(conflicts);
}
});
}
示例6: getCalledMethod
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public static PsiMethod getCalledMethod(PsiCall arg)
{
final PsiExpressionList argumentList = arg.getArgumentList();
if(argumentList == null)
{
return null;
}
MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
if(properties != null)
{
return properties.getMethod();
}
final JavaResolveResult resolveResult = getResolveResult(arg);
if(resolveResult instanceof MethodCandidateInfo)
{
return (PsiMethod) resolveResult.getElement();
}
else
{
return null;
}
}
示例7: collectAdditionalConstraints
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private void collectAdditionalConstraints(final Set<ConstraintFormula> additionalConstraints,
final Set<ConstraintFormula> ignoredConstraints,
final PsiCall callExpression,
PsiSubstitutor initialSubstitutor)
{
PsiExpressionList argumentList = callExpression.getArgumentList();
if(argumentList != null)
{
MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
final JavaResolveResult result = properties != null ? null : getResolveResult(callExpression);
final PsiMethod method = properties != null ? properties.getMethod() : result instanceof MethodCandidateInfo ? ((MethodCandidateInfo) result).getElement() : null;
if(method != null)
{
final PsiExpression[] newArgs = argumentList.getExpressions();
final PsiParameter[] newParams = method.getParameterList().getParameters();
if(newParams.length > 0)
{
collectAdditionalConstraints(newParams, newArgs, method, chooseSiteSubstitutor(properties, result, method), additionalConstraints, ignoredConstraints, chooseVarargsMode
(properties, result), initialSubstitutor);
}
}
}
}
示例8: TypeParamsChecker
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public TypeParamsChecker(PsiElement expression, PsiClass aClass)
{
myClass = aClass;
PsiElement parent = expression != null ? expression.getParent() : null;
while(parent instanceof PsiParenthesizedExpression)
{
parent = parent.getParent();
}
if(parent instanceof PsiExpressionList)
{
final PsiElement gParent = parent.getParent();
if(gParent instanceof PsiCall)
{
final MethodCandidateInfo.CurrentCandidateProperties pair = MethodCandidateInfo.getCurrentMethod(parent);
myMethod = pair != null ? pair.getMethod() : null;
if(myMethod == null)
{
myMethod = ((PsiCall) gParent).resolveMethod();
}
if(myMethod != null && PsiTreeUtil.isAncestor(myMethod, expression, false))
{
myMethod = null;
}
}
}
}
示例9: isPolyExpression
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public static boolean isPolyExpression(final PsiExpression expression) {
if (expression instanceof PsiFunctionalExpression) {
return true;
}
else if (expression instanceof PsiParenthesizedExpression) {
return isPolyExpression(((PsiParenthesizedExpression)expression).getExpression());
}
else if (expression instanceof PsiNewExpression) {
final PsiJavaCodeReferenceElement classReference = ((PsiNewExpression)expression).getClassOrAnonymousClassReference();
if (classReference != null) {
final PsiReferenceParameterList parameterList = classReference.getParameterList();
if (parameterList != null) {
final PsiTypeElement[] typeElements = parameterList.getTypeParameterElements();
if (typeElements.length == 1 && typeElements[0].getType() instanceof PsiDiamondType) {
return isInAssignmentOrInvocationContext(expression);
}
}
}
} else if (expression instanceof PsiMethodCallExpression) {
final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(((PsiMethodCallExpression)expression).getArgumentList());
return isMethodCallPolyExpression(expression, candidateProperties != null ? candidateProperties.getMethod() : ((PsiMethodCallExpression)expression).resolveMethod());
}
else if (expression instanceof PsiConditionalExpression) {
final ConditionalKind conditionalKind = isBooleanOrNumeric(expression);
if (conditionalKind == null) {
return isInAssignmentOrInvocationContext(expression);
}
}
return false;
}
示例10: getCurrentProperties
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static MethodCandidateInfo.CurrentCandidateProperties getCurrentProperties(PsiElement parent)
{
if(parent instanceof PsiCall)
{
return MethodCandidateInfo.getCurrentMethod(((PsiCall) parent).getArgumentList());
}
return null;
}
示例11: isPolyExpression
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public static boolean isPolyExpression(final PsiExpression expression)
{
if(expression instanceof PsiFunctionalExpression)
{
return true;
}
else if(expression instanceof PsiParenthesizedExpression)
{
return isPolyExpression(((PsiParenthesizedExpression) expression).getExpression());
}
else if(expression instanceof PsiNewExpression && PsiDiamondType.hasDiamond((PsiNewExpression) expression))
{
return isInAssignmentOrInvocationContext(expression);
}
else if(expression instanceof PsiMethodCallExpression)
{
final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(((PsiMethodCallExpression) expression).getArgumentList());
return isMethodCallPolyExpression(expression, candidateProperties != null ? candidateProperties.getMethod() : ((PsiMethodCallExpression) expression).resolveMethod());
}
else if(expression instanceof PsiConditionalExpression)
{
final ConditionalKind conditionalKind = isBooleanOrNumeric(expression);
if(conditionalKind == null)
{
return isInAssignmentOrInvocationContext(expression);
}
}
return false;
}
示例12: getUnhandledExceptions
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@NotNull
public static List<PsiClassType> getUnhandledExceptions(@NotNull final PsiCallExpression methodCall,
@Nullable final PsiElement topElement,
final boolean includeSelfCalls) {
//exceptions only influence the invocation type after overload resolution is complete
if (MethodCandidateInfo.isOverloadCheck()) {
return Collections.emptyList();
}
final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(methodCall.getArgumentList());
final JavaResolveResult result = properties != null ? properties.getInfo() : methodCall.resolveMethodGenerics();
final PsiMethod method = (PsiMethod)result.getElement();
if (method == null) {
return Collections.emptyList();
}
final PsiMethod containingMethod = PsiTreeUtil.getParentOfType(methodCall, PsiMethod.class);
if (!includeSelfCalls && method == containingMethod) {
return Collections.emptyList();
}
final PsiClassType[] thrownExceptions = method.getThrowsList().getReferencedTypes();
if (thrownExceptions.length == 0) {
return Collections.emptyList();
}
final PsiSubstitutor substitutor = getSubstitutor(result, methodCall);
if (!isArrayClone(method, methodCall) && methodCall instanceof PsiMethodCallExpression) {
final PsiFile containingFile = (containingMethod == null ? methodCall : containingMethod).getContainingFile();
final MethodResolverProcessor processor = new MethodResolverProcessor((PsiMethodCallExpression)methodCall, containingFile);
try {
PsiScopesUtil.setupAndRunProcessor(processor, methodCall, false);
final List<Pair<PsiMethod, PsiSubstitutor>> candidates = ContainerUtil.mapNotNull(
processor.getResults(), new Function<CandidateInfo, Pair<PsiMethod, PsiSubstitutor>>() {
@Override
public Pair<PsiMethod, PsiSubstitutor> fun(CandidateInfo info) {
PsiElement element = info.getElement();
if (element instanceof PsiMethod &&
MethodSignatureUtil.areSignaturesEqual(method, (PsiMethod)element) &&
!MethodSignatureUtil.isSuperMethod((PsiMethod)element, method)) {
return Pair.create((PsiMethod)element, getSubstitutor(info, methodCall));
}
return null;
}
});
if (candidates.size() > 1) {
GlobalSearchScope scope = methodCall.getResolveScope();
final List<PsiClassType> ex = collectSubstituted(substitutor, thrownExceptions, scope);
for (Pair<PsiMethod, PsiSubstitutor> pair : candidates) {
final PsiClassType[] exceptions = pair.first.getThrowsList().getReferencedTypes();
if (exceptions.length == 0) {
return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, PsiClassType.EMPTY_ARRAY);
}
retainExceptions(ex, collectSubstituted(pair.second, exceptions, scope));
}
return getUnhandledExceptions(methodCall, topElement, PsiSubstitutor.EMPTY, ex.toArray(new PsiClassType[ex.size()]));
}
}
catch (MethodProcessorSetupFailedException ignore) {
return Collections.emptyList();
}
}
return getUnhandledExceptions(method, methodCall, topElement, substitutor);
}
示例13: getCurrentProperties
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
private static MethodCandidateInfo.CurrentCandidateProperties getCurrentProperties(PsiElement parent) {
if (parent instanceof PsiCall) {
return MethodCandidateInfo.getCurrentMethod(((PsiCall)parent).getArgumentList());
}
return null;
}
示例14: getTargetType
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
public static PsiType getTargetType(final PsiElement context) {
PsiType targetType = PsiTypesUtil.getExpectedTypeByParent(context);
if (targetType != null) {
return targetType;
}
final PsiElement parent = PsiUtil.skipParenthesizedExprUp(context.getParent());
if (parent instanceof PsiExpressionList) {
PsiElement gParent = parent.getParent();
if (gParent instanceof PsiAnonymousClass) {
gParent = gParent.getParent();
}
if (gParent instanceof PsiCall) {
final PsiExpressionList argumentList = ((PsiCall)gParent).getArgumentList();
if (argumentList != null) {
final MethodCandidateInfo.CurrentCandidateProperties properties = MethodCandidateInfo.getCurrentMethod(argumentList);
if (properties != null && properties.isApplicabilityCheck()) {
return getTypeByMethod(context, argumentList, properties.getMethod(), properties.isVarargs(), properties.getSubstitutor());
}
final JavaResolveResult result = properties != null ? properties.getInfo() : ((PsiCall)gParent).resolveMethodGenerics();
final boolean varargs = chooseVarargsMode(properties, result);
PsiSubstitutor substitutor = PsiResolveHelper.ourGraphGuard.doPreventingRecursion(context, false,
new Computable<PsiSubstitutor>() {
@Override
public PsiSubstitutor compute() {
return result.getSubstitutor();
}
}
);
if (substitutor == null && properties != null) {
substitutor = properties.getSubstitutor();
}
return getTypeByMethod(context, argumentList, result.getElement(), varargs, substitutor);
}
}
} else if (parent instanceof PsiConditionalExpression) {
return getTargetType((PsiExpression)parent);
}
else if (parent instanceof PsiLambdaExpression) {
return getTargetTypeByContainingLambda((PsiLambdaExpression)parent);
}
else if (parent instanceof PsiReturnStatement) {
return getTargetTypeByContainingLambda(PsiTreeUtil.getParentOfType(parent, PsiLambdaExpression.class));
}
return null;
}
示例15: isAcceptable
import com.intellij.psi.infos.MethodCandidateInfo; //导入方法依赖的package包/类
@Override
public boolean isAcceptable(PsiType leftType) {
if (leftType instanceof PsiIntersectionType) {
for (PsiType conjunctType : ((PsiIntersectionType)leftType).getConjuncts()) {
if (isAcceptable(conjunctType)) return true;
}
return false;
}
final PsiExpressionList argsList = PsiTreeUtil.getParentOfType(this, PsiExpressionList.class);
if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList)) {
final MethodCandidateInfo.CurrentCandidateProperties candidateProperties = MethodCandidateInfo.getCurrentMethod(argsList);
if (candidateProperties != null) {
final PsiMethod method = candidateProperties.getMethod();
if (hasFormalParameterTypes() && !InferenceSession.isPertinentToApplicability(this, method)) {
return true;
}
if (LambdaUtil.isPotentiallyCompatibleWithTypeParameter(this, argsList, method)) {
return true;
}
}
}
leftType = FunctionalInterfaceParameterizationUtil.getGroundTargetType(leftType, this);
if (!isPotentiallyCompatible(leftType)) {
return false;
}
if (MethodCandidateInfo.ourOverloadGuard.currentStack().contains(argsList) && !hasFormalParameterTypes()) {
return true;
}
final PsiClassType.ClassResolveResult resolveResult = PsiUtil.resolveGenericsClassInType(leftType);
final PsiMethod interfaceMethod = LambdaUtil.getFunctionalInterfaceMethod(resolveResult);
if (interfaceMethod == null) return false;
if (interfaceMethod.hasTypeParameters()) return false;
final PsiSubstitutor substitutor = LambdaUtil.getSubstitutor(interfaceMethod, resolveResult);
if (hasFormalParameterTypes()) {
final PsiParameter[] lambdaParameters = getParameterList().getParameters();
final PsiType[] parameterTypes = interfaceMethod.getSignature(substitutor).getParameterTypes();
for (int lambdaParamIdx = 0, length = lambdaParameters.length; lambdaParamIdx < length; lambdaParamIdx++) {
PsiParameter parameter = lambdaParameters[lambdaParamIdx];
final PsiTypeElement typeElement = parameter.getTypeElement();
if (typeElement != null) {
final PsiType lambdaFormalType = toArray(typeElement.getType());
final PsiType methodParameterType = toArray(parameterTypes[lambdaParamIdx]);
if (!lambdaFormalType.equals(methodParameterType)) {
return false;
}
}
}
}
PsiType methodReturnType = interfaceMethod.getReturnType();
if (methodReturnType != null && methodReturnType != PsiType.VOID) {
Map<PsiElement, PsiType> map = LambdaUtil.getFunctionalTypeMap();
try {
if (map.put(this, leftType) != null) {
return false;
}
return LambdaUtil.checkReturnTypeCompatible(this, substitutor.substitute(methodReturnType)) == null;
}
finally {
map.remove(this);
}
}
return true;
}