use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GrArgumentListImpl method replaceWithArgumentList.
@Override
public GrArgumentList replaceWithArgumentList(GrArgumentList newArgList) throws IncorrectOperationException {
if (this.getParent() == null || this.getParent().getNode() == null) {
throw new IncorrectOperationException();
}
ASTNode parentNode = this.getParent().getNode();
ASTNode newNode = newArgList.getNode();
assert parentNode != null;
parentNode.replaceChild(this.getNode(), newNode);
if (!(newNode.getPsi() instanceof GrArgumentList)) {
throw new IncorrectOperationException();
}
return ((GrArgumentList) newNode.getPsi());
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GrCallImpl method addNamedArgument.
@Override
public GrNamedArgument addNamedArgument(final GrNamedArgument namedArgument) throws IncorrectOperationException {
GrArgumentList list = getArgumentList();
assert list != null;
if (list.getText().trim().isEmpty()) {
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(getProject());
final GrArgumentList newList = factory.createExpressionArgumentList();
list = (GrArgumentList) list.replace(newList);
}
return list.addNamedArgument(namedArgument);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GrNewExpressionImpl method addNamedArgument.
@Override
public GrNamedArgument addNamedArgument(final GrNamedArgument namedArgument) throws IncorrectOperationException {
final GrArgumentList list = getArgumentList();
if (list == null) {
//so it is not anonymous class declaration
final GroovyPsiElementFactory factory = GroovyPsiElementFactory.getInstance(getProject());
final GrArgumentList newList = factory.createExpressionArgumentList();
PsiElement last = getLastChild();
assert last != null;
while (last.getPrevSibling() instanceof PsiWhiteSpace || last.getPrevSibling() instanceof PsiErrorElement) {
last = last.getPrevSibling();
assert last != null;
}
ASTNode astNode = last.getNode();
assert astNode != null;
getNode().addChild(newList.getNode(), astNode);
}
return super.addNamedArgument(namedArgument);
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class GrEnumConstantImpl method getOrCreateInitializingClass.
@NotNull
@Override
public PsiEnumConstantInitializer getOrCreateInitializingClass() {
final GrEnumConstantInitializer initializingClass = getInitializingClass();
if (initializingClass != null)
return initializingClass;
final GrEnumConstantInitializer initializer = GroovyPsiElementFactory.getInstance(getProject()).createEnumConstantFromText("foo{}").getInitializingClass();
LOG.assertTrue(initializer != null);
final GrArgumentList argumentList = getArgumentList();
if (argumentList != null) {
return (PsiEnumConstantInitializer) addAfter(initializer, argumentList);
} else {
return (PsiEnumConstantInitializer) addAfter(initializer, getNameIdentifierGroovy());
}
}
use of org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList in project intellij-community by JetBrains.
the class MakeClosureCallImplicitIntention method processIntention.
@Override
public void processIntention(@NotNull PsiElement element, @NotNull Project project, Editor editor) throws IncorrectOperationException {
final GrMethodCallExpression expression = (GrMethodCallExpression) element;
final GrReferenceExpression invokedExpression = (GrReferenceExpression) expression.getInvokedExpression();
final GrExpression qualifier = invokedExpression.getQualifierExpression();
final GrArgumentList argList = expression.getArgumentList();
final GrClosableBlock[] closureArgs = expression.getClosureArguments();
final StringBuilder newExpression = new StringBuilder();
newExpression.append(qualifier.getText());
newExpression.append(argList.getText());
for (GrClosableBlock closureArg : closureArgs) {
newExpression.append(closureArg.getText());
}
PsiImplUtil.replaceExpression(newExpression.toString(), expression);
}
Aggregations