@Nullable public static MethodReferenceBag getMethodParameterReferenceBag( PsiElement psiElement, int wantIndex) { PsiElement variableContext = psiElement.getContext(); if (!(variableContext instanceof ParameterList)) { return null; } ParameterList parameterList = (ParameterList) variableContext; if (!(parameterList.getContext() instanceof MethodReference)) { return null; } ParameterBag currentIndex = PsiElementUtils.getCurrentParameterIndex(psiElement); if (currentIndex == null) { return null; } if (wantIndex >= 0 && currentIndex.getIndex() != wantIndex) { return null; } return new MethodReferenceBag( parameterList, (MethodReference) parameterList.getContext(), currentIndex); }
public static int getParameterIndexValue(@Nullable PsiElement parameterListChild) { if (parameterListChild == null) { return -1; } ParameterBag parameterBag = PsiElementUtils.getCurrentParameterIndex(parameterListChild); if (parameterBag == null) { return -1; } return parameterBag.getIndex(); }
public static boolean isCallToWithParameter( PsiElement psiElement, String className, String methodName, int parameterIndex) { if (!(psiElement.getContext() instanceof ParameterList)) { return false; } ParameterList parameterList = (ParameterList) psiElement.getContext(); if (parameterList == null || !(parameterList.getContext() instanceof MethodReference)) { return false; } MethodReference method = (MethodReference) parameterList.getContext(); Symfony2InterfacesUtil interfacesUtil = new Symfony2InterfacesUtil(); if (!interfacesUtil.isCallTo(method, className, methodName)) { return false; } ParameterBag currentIndex = PsiElementUtils.getCurrentParameterIndex(psiElement); if (currentIndex == null || currentIndex.getIndex() != parameterIndex) { return false; } return true; }