use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GrEnumConstantInfo method inferArgTypes.
@Nullable
@Override
protected PsiType[] inferArgTypes() {
GrEnumConstant call = getCall();
GrArgumentList argList = call.getArgumentList();
if (argList != null) {
return PsiUtil.getArgumentTypes(argList);
} else {
return PsiType.EMPTY_ARRAY;
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GrNewExpressionInfo method getElementToHighlight.
@NotNull
@Override
public PsiElement getElementToHighlight() {
GrNewExpression call = getCall();
GrArgumentList argList = call.getArgumentList();
if (argList != null)
return argList;
GrCodeReferenceElement ref = call.getReferenceElement();
if (ref != null)
return ref;
throw new IncorrectOperationException("reference of new expression should exist if it is a constructor call");
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GroovyAnnotator method visitEnumConstant.
@Override
public void visitEnumConstant(@NotNull GrEnumConstant enumConstant) {
super.visitEnumConstant(enumConstant);
final GrArgumentList argumentList = enumConstant.getArgumentList();
if (argumentList != null && PsiImplUtil.hasNamedArguments(argumentList) && !PsiImplUtil.hasExpressionArguments(argumentList)) {
final PsiMethod constructor = enumConstant.resolveConstructor();
if (constructor != null) {
if (!PsiUtil.isConstructorHasRequiredParameters(constructor)) {
myHolder.createErrorAnnotation(argumentList, GroovyBundle.message("the.usage.of.a.map.entry.expression.to.initialize.an.enum.is.currently.not.supported"));
}
}
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GroovyAnnotator method visitTypeDefinitionBody.
@Override
public void visitTypeDefinitionBody(@NotNull GrTypeDefinitionBody typeDefinitionBody) {
final PsiElement parent = typeDefinitionBody.getParent();
if (!(parent instanceof GrAnonymousClassDefinition))
return;
final PsiElement prev = typeDefinitionBody.getPrevSibling();
if (!PsiUtil.isLineFeed(prev))
return;
final PsiElement newExpression = parent.getParent();
if (!(newExpression instanceof GrNewExpression))
return;
final GrStatementOwner statementOwner = PsiTreeUtil.getParentOfType(newExpression, GrStatementOwner.class);
final GrParenthesizedExpression parenthesizedExpression = PsiTreeUtil.getParentOfType(newExpression, GrParenthesizedExpression.class);
if (parenthesizedExpression != null && PsiTreeUtil.isAncestor(statementOwner, parenthesizedExpression, true))
return;
final GrArgumentList argumentList = PsiTreeUtil.getParentOfType(newExpression, GrArgumentList.class);
if (argumentList != null && !(argumentList instanceof GrCommandArgumentList)) {
if (PsiTreeUtil.isAncestor(statementOwner, argumentList, true))
return;
}
myHolder.createErrorAnnotation(typeDefinitionBody, GroovyBundle.message("ambiguous.code.block"));
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GrMethodCallExpressionImpl method replaceClosureArgument.
@Override
public GrExpression replaceClosureArgument(@NotNull GrClosableBlock closure, @NotNull GrExpression newExpr) throws IncorrectOperationException {
if (newExpr instanceof GrClosableBlock) {
return closure.replaceWithExpression(newExpr, true);
}
final GrClosableBlock[] closureArguments = getClosureArguments();
final int i = ArrayUtil.find(closureArguments, closure);
GrArgumentList argList = getArgumentList();
if (argList.getText().isEmpty()) {
argList = (GrArgumentList) argList.replace(GroovyPsiElementFactory.getInstance(getProject()).createArgumentList());
}
for (int j = 0; j < i; j++) {
argList.add(closureArguments[j]);
closureArguments[j].delete();
}
final GrExpression result = (GrExpression) argList.add(newExpr);
closure.delete();
return result;
}
Aggregations