use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project android by JetBrains.
the class AndroidDslContributor method getContributingMethod.
@Nullable
private static PsiMethod getContributingMethod(PsiElement place, PsiClass contributorClass, String methodName) {
GrMethodCall call = PsiTreeUtil.getParentOfType(place, GrMethodCall.class);
if (call == null) {
return null;
}
GrArgumentList args = call.getArgumentList();
int argsCount = GradleResolverUtil.getGrMethodArumentsCount(args);
PsiMethod[] methodsByName = findMethodByName(contributorClass, methodName);
// first check to see if we can narrow down by # of arguments
for (PsiMethod method : methodsByName) {
if (method.getParameterList().getParametersCount() == argsCount) {
return method;
}
}
// if we couldn't narrow down by # of arguments, just use the first one
return methodsByName.length > 0 ? methodsByName[0] : null;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GroovyAnnotator method visitConstructorInvocation.
@Override
public void visitConstructorInvocation(@NotNull GrConstructorInvocation invocation) {
final GroovyResolveResult resolveResult = invocation.advancedResolve();
if (resolveResult.getElement() == null) {
final GroovyResolveResult[] results = invocation.multiResolve(false);
final GrArgumentList argList = invocation.getArgumentList();
if (results.length > 0) {
String message = GroovyBundle.message("ambiguous.constructor.call");
myHolder.createWarningAnnotation(argList, message);
} else {
final PsiClass clazz = invocation.getDelegatedClass();
if (clazz != null) {
//default constructor invocation
PsiType[] argumentTypes = PsiUtil.getArgumentTypes(invocation.getInvokedExpression(), true);
if (argumentTypes != null && argumentTypes.length > 0) {
String message = GroovyBundle.message("cannot.apply.default.constructor", clazz.getName());
myHolder.createWarningAnnotation(argList, message);
}
}
}
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GrEnumConstantInfo method getElementToHighlight.
@NotNull
@Override
public PsiElement getElementToHighlight() {
GrEnumConstant constant = getCall();
GrArgumentList argList = constant.getArgumentList();
if (argList != null)
return argList;
return constant.getNameIdentifierGroovy();
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GroovyDslDefaultMembers method enclosingCall.
/**
* Returns enclosing method call of a given context's place
*/
@Nullable
public GrCall enclosingCall(String name, GdslMembersHolderConsumer consumer) {
final PsiElement place = consumer.getPlace();
if (place == null)
return null;
GrCall call = PsiTreeUtil.getParentOfType(place, GrCall.class, true);
if (call == null)
return null;
while (call != null && !name.equals(getInvokedMethodName(call))) {
call = PsiTreeUtil.getParentOfType(call, GrCall.class, true);
}
if (call == null)
return null;
final GrArgumentList argumentList = call.getArgumentList();
if (argumentList != null) {
for (GrExpression arg : argumentList.getExpressionArguments()) {
if (arg instanceof GrClosableBlock && PsiTreeUtil.findCommonParent(place, arg) == arg) {
return call;
}
}
}
if (call instanceof GrMethodCallExpression) {
for (GrExpression arg : call.getClosureArguments()) {
if (arg instanceof GrClosableBlock && PsiTreeUtil.findCommonParent(place, arg) == arg) {
return call;
}
}
}
return null;
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class EquivalenceChecker method applicationStatementsAreEquivalent.
private static boolean applicationStatementsAreEquivalent(GrApplicationStatement statement1, GrApplicationStatement statement2) {
final GrExpression funExpression1 = statement1.getInvokedExpression();
final GrExpression funExpression2 = statement2.getInvokedExpression();
if (!expressionsAreEquivalent(funExpression1, funExpression2)) {
return false;
}
final GrArgumentList argumentList1 = statement1.getArgumentList();
final GrArgumentList argumentList2 = statement2.getArgumentList();
final GrExpression[] args1 = argumentList1.getExpressionArguments();
final GrExpression[] args2 = argumentList2.getExpressionArguments();
if (!expressionListsAreEquivalent(args1, args2)) {
return false;
}
final GrNamedArgument[] namedArgs1 = argumentList1.getNamedArguments();
final GrNamedArgument[] namedArgs2 = argumentList2.getNamedArguments();
if (!namedArgumentListsAreEquivalent(namedArgs1, namedArgs2)) {
return false;
}
return true;
}
Aggregations