public ObjectCreationExpression makeNew(final Iterable<Expression> arguments) { return new ObjectCreationExpression(Expression.MYSTERY_OFFSET, this, arguments); } }
@Override public boolean matches(final INode other, final Match match) { if (other instanceof ObjectCreationExpression) { final ObjectCreationExpression otherExpression = (ObjectCreationExpression) other; return !otherExpression.isNull() && getTarget().matches(otherExpression.getTarget(), match) && getType().matches(otherExpression.getType(), match) && getArguments().matches(otherExpression.getArguments(), match); } return false; } }
super.visitObjectCreationExpression(node, data); final AstNodeCollection<Expression> arguments = node.getArguments(); final TypeReference createdType = node.getType().getUserData(Keys.TYPE_REFERENCE); final TypeReference argumentType = resolvedArgument.getType(); firstArgument instanceof ThisReferenceExpression) { final MethodReference constructor = (MethodReference) node.getUserData(Keys.MEMBER_REFERENCE); node.setTarget(firstArgument); node.getType().replaceWith(type);
@Override public Void visitObjectCreationExpression(final ObjectCreationExpression node, final Void ignored) { startNode(node); final Expression target = node.getTarget(); if (target != null && !target.isNull()) { target.acceptVisitor(this, ignored); writeToken(Roles.DOT); } writeKeyword(ObjectCreationExpression.NEW_KEYWORD_ROLE); node.getType().acceptVisitor(this, ignored); space(policy.SpaceBeforeMethodCallParentheses); writeCommaSeparatedListInParenthesis(node.getArguments(), policy.SpaceWithinMethodCallParentheses); endNode(node); return null; }
creation = new ObjectCreationExpression( byteCode.getOffset(), declaredType); final ConvertTypeOptions options = new ConvertTypeOptions(); options.setIncludeTypeParameterDefinitions(false); creation = new ObjectCreationExpression( byteCode.getOffset(), _astBuilder.convertType(declaringType, options)); creation.getArguments().addAll(adjustArgumentsForMethodCall(methodReference, arguments)); creation.putUserData(Keys.MEMBER_REFERENCE, methodReference);
public final AstType getType() { return getChildByRole(Roles.TYPE); }
@Override public Void visitObjectCreationExpression(final ObjectCreationExpression node, final Void data) { final AstNodeCollection<Expression> arguments = node.getArguments(); if (arguments.isEmpty() || arguments.hasSingleElement()) { final Expression firstArgument; if (arguments.hasSingleElement()) { final Match m = _stringBuilderArgumentPattern.match(arguments.firstOrNullObject()); if (!m.success()) { return super.visitObjectCreationExpression(node, data); } firstArgument = firstOrDefault(m.<Expression>get("firstArgument")); } else { firstArgument = null; } final TypeReference typeReference = node.getType().toTypeReference(); if (typeReference != null && isStringBuilder(typeReference)) { convertStringBuilderToConcatenation(node, firstArgument); } } return super.visitObjectCreationExpression(node, data); }
final MethodReference constructor = (MethodReference) initializer.getUserData(Keys.MEMBER_REFERENCE); final MethodDefinition resolvedConstructor = constructor.resolve(); final AstNodeCollection<Expression> arguments = initializer.getArguments(); final boolean trimArguments = arguments.size() == constructor.getParameters().size();
@Override public Void visitObjectCreationExpression(final ObjectCreationExpression node, final Void data) { for (final Expression argument : node.getArguments()) { argument.acceptVisitor(this, data); } processCall(node); return null; }
@Override public ResolveResult visitObjectCreationExpression(final ObjectCreationExpression node, final Void _) { /* final ResolveResult result = resolveTypeFromMember(node.getUserData(Keys.MEMBER_REFERENCE)); if (result != null) { return result; } */ return node.getType().acceptVisitor(this, _); }
public final AstNodeCollection<Expression> getArguments() { return getChildrenByRole(Roles.ARGUMENT); }
private void convertStringBuilderToConcatenation(final ObjectCreationExpression node, final Expression firstArgument) { if (node.getParent() == null || node.getParent().getParent() == null) { return; AstNode parent; for (current = node.getParent(), parent = current.getParent(); current instanceof MemberReferenceExpression && parent instanceof InvocationExpression && parent.getParent() != null; current = parent.getParent(), parent = current.getParent()) {
super.visitObjectCreationExpression(node, data); final AstNodeCollection<Expression> arguments = node.getArguments(); final TypeReference createdType = node.getType().getUserData(Keys.TYPE_REFERENCE); final TypeReference argumentType = resolvedArgument.getType(); firstArgument instanceof ThisReferenceExpression) { final MethodReference constructor = (MethodReference) node.getUserData(Keys.MEMBER_REFERENCE); node.setTarget(firstArgument); node.getType().replaceWith(type);
@Override public Void visitObjectCreationExpression(final ObjectCreationExpression node, final Void ignored) { startNode(node); final Expression target = node.getTarget(); if (target != null && !target.isNull()) { target.acceptVisitor(this, ignored); writeToken(Roles.DOT); } writeKeyword(ObjectCreationExpression.NEW_KEYWORD_ROLE); node.getType().acceptVisitor(this, ignored); space(policy.SpaceBeforeMethodCallParentheses); writeCommaSeparatedListInParenthesis(node.getArguments(), policy.SpaceWithinMethodCallParentheses); endNode(node); return null; }
creation = new ObjectCreationExpression( byteCode.getOffset(), declaredType); final ConvertTypeOptions options = new ConvertTypeOptions(); options.setIncludeTypeParameterDefinitions(false); creation = new ObjectCreationExpression( byteCode.getOffset(), _astBuilder.convertType(declaringType, options)); creation.getArguments().addAll(adjustArgumentsForMethodCall(methodReference, arguments)); creation.putUserData(Keys.MEMBER_REFERENCE, methodReference);
public final Expression getTarget() { return getChildByRole(Roles.TARGET_EXPRESSION); }
@Override public Void visitObjectCreationExpression(final ObjectCreationExpression node, final Void data) { final AstNodeCollection<Expression> arguments = node.getArguments(); if (arguments.isEmpty() || arguments.hasSingleElement()) { final Expression firstArgument; if (arguments.hasSingleElement()) { final Match m = _stringBuilderArgumentPattern.match(arguments.firstOrNullObject()); if (!m.success()) { return super.visitObjectCreationExpression(node, data); } firstArgument = firstOrDefault(m.<Expression>get("firstArgument")); } else { firstArgument = null; } final TypeReference typeReference = node.getType().toTypeReference(); if (typeReference != null && isStringBuilder(typeReference)) { convertStringBuilderToConcatenation(node, firstArgument); } } return super.visitObjectCreationExpression(node, data); }
final MethodReference constructor = (MethodReference) initializer.getUserData(Keys.MEMBER_REFERENCE); final MethodDefinition resolvedConstructor = constructor.resolve(); final AstNodeCollection<Expression> arguments = initializer.getArguments(); final boolean trimArguments = arguments.size() == constructor.getParameters().size();