@Override public boolean matches(final INode other, final Match match) { if (other instanceof CastExpression) { final CastExpression otherCast = (CastExpression) other; return !otherCast.isNull() && getType().matches(otherCast.getType(), match) && getExpression().matches(otherCast.getExpression(), match); } return false; } }
@Override public boolean matches(final INode other, final Match match) { if (other instanceof CastExpression) { final CastExpression otherCast = (CastExpression) other; return !otherCast.isNull() && getType().matches(otherCast.getType(), match) && getExpression().matches(otherCast.getExpression(), match); } return false; } }
@Override public boolean matches(final INode other, final Match match) { if (other instanceof CastExpression) { final CastExpression otherCast = (CastExpression) other; return !otherCast.isNull() && getType().matches(otherCast.getType(), match) && getExpression().matches(otherCast.getExpression(), match); } return false; } }
protected void processBinaryExpressionOperand( final Expression operand, final TypeReference otherType, final BinaryOperatorType op) { if (operand instanceof CastExpression) { final CastExpression cast = (CastExpression) operand; final Expression toCast = cast.getExpression(); final TypeReference castType = getType(cast); final TypeReference innerType = getType(toCast); if (castType != null && innerType != null && TypeUtilities.isBinaryOperatorApplicable(op, innerType, otherType, false)) { addToResults(cast, false); } } }
protected void processBinaryExpressionOperand( final Expression operand, final TypeReference otherType, final BinaryOperatorType op) { if (operand instanceof CastExpression) { final CastExpression cast = (CastExpression) operand; final Expression toCast = cast.getExpression(); final TypeReference castType = getType(cast); final TypeReference innerType = getType(toCast); if (castType != null && innerType != null && TypeUtilities.isBinaryOperatorApplicable(op, innerType, otherType, false)) { addToResults(cast, false); } } }
public boolean isInPolymorphicCall(final CastExpression cast) { // // See http://download.java.net/jdk7/docs/api/java/lang/invoke/MethodHandle.html#sigpoly // final Expression operand = cast.getExpression(); if (operand instanceof InvocationExpression || operand instanceof MemberReferenceExpression && operand.getParent() instanceof InvocationExpression || operand instanceof ObjectCreationExpression) { if (isPolymorphicMethod(operand)) { return true; } } return cast.getRole() == Roles.ARGUMENT && isPolymorphicMethod(skipParenthesesUp(cast.getParent())); }
public boolean isInPolymorphicCall(final CastExpression cast) { // // See http://download.java.net/jdk7/docs/api/java/lang/invoke/MethodHandle.html#sigpoly // final Expression operand = cast.getExpression(); if (operand instanceof InvocationExpression || operand instanceof MemberReferenceExpression && operand.getParent() instanceof InvocationExpression || operand instanceof ObjectCreationExpression) { if (isPolymorphicMethod(operand)) { return true; } } return cast.getRole() == Roles.ARGUMENT && isPolymorphicMethod(skipParenthesesUp(cast.getParent())); }
public boolean isInPolymorphicCall(final CastExpression cast) { // // See http://download.java.net/jdk7/docs/api/java/lang/invoke/MethodHandle.html#sigpoly // final Expression operand = cast.getExpression(); if (operand instanceof InvocationExpression || operand instanceof MemberReferenceExpression && operand.getParent() instanceof InvocationExpression || operand instanceof ObjectCreationExpression) { if (isPolymorphicMethod(operand)) { return true; } } return cast.getRole() == Roles.ARGUMENT && isPolymorphicMethod(skipParenthesesUp(cast.getParent())); }
public static void removeCast(final CastExpression castExpression) { if (castExpression == null || castExpression.isNull()) { return; } Expression operand = castExpression.getExpression(); if (operand instanceof ParenthesizedExpression) { operand = ((ParenthesizedExpression) operand).getExpression(); } if (operand.isNull()) { return; } AstNode toBeReplaced = castExpression; AstNode parent = castExpression.getParent(); while (parent instanceof ParenthesizedExpression) { toBeReplaced = parent; parent = parent.getParent(); } toBeReplaced.replaceWith(operand); }
public static void removeCast(final CastExpression castExpression) { if (castExpression == null || castExpression.isNull()) { return; } Expression operand = castExpression.getExpression(); if (operand instanceof ParenthesizedExpression) { operand = ((ParenthesizedExpression) operand).getExpression(); } if (operand == null || operand.isNull()) { return; } AstNode toBeReplaced = castExpression; AstNode parent = castExpression.getParent(); while (parent instanceof ParenthesizedExpression) { toBeReplaced = parent; parent = parent.getParent(); } toBeReplaced.replaceWith(operand); }
public static void removeCast(final CastExpression castExpression) { if (castExpression == null || castExpression.isNull()) { return; } Expression operand = castExpression.getExpression(); if (operand instanceof ParenthesizedExpression) { operand = ((ParenthesizedExpression) operand).getExpression(); } if (operand == null || operand.isNull()) { return; } AstNode toBeReplaced = castExpression; AstNode parent = castExpression.getParent(); while (parent instanceof ParenthesizedExpression) { toBeReplaced = parent; parent = parent.getParent(); } toBeReplaced.replaceWith(operand); }
@Override public Void visitCastExpression(final CastExpression node, final Void data) { super.visitCastExpression(node, data); final Expression operand = node.getExpression(); final ResolveResult targetResult = _resolver.apply(node.getType()); if (targetResult == null || targetResult.getType() == null) { return null; } final ResolveResult valueResult = _resolver.apply(operand); if (valueResult == null || valueResult.getType() == null) { return null; } final ConversionType conversionType = MetadataHelper.getConversionType(targetResult.getType(), valueResult.getType()); if (conversionType == ConversionType.NONE) { addCastForAssignment(node.getType(), node.getExpression()); } if (RedundantCastUtility.isCastRedundant(_resolver, node)) { RedundantCastUtility.removeCast(node); } return null; }
@Override public Void visitCastExpression(final CastExpression node, final Void data) { super.visitCastExpression(node, data); final Expression operand = node.getExpression(); final ResolveResult targetResult = _resolver.apply(node.getType()); if (targetResult == null || targetResult.getType() == null) { return null; } final ResolveResult valueResult = _resolver.apply(operand); if (valueResult == null || valueResult.getType() == null) { return null; } final ConversionType conversionType = MetadataHelper.getConversionType(targetResult.getType(), valueResult.getType()); if (conversionType == ConversionType.NONE) { addCastForAssignment(node.getType(), node.getExpression()); } if (RedundantCastUtility.isCastRedundant(_resolver, node)) { RedundantCastUtility.removeCast(node); } return null; }
@Override public Void visitCastExpression(final CastExpression node, final Void data) { super.visitCastExpression(node, data); final Expression operand = node.getExpression(); final ResolveResult targetResult = _resolver.apply(node.getType()); if (targetResult == null || targetResult.getType() == null) { return null; } final ResolveResult valueResult = _resolver.apply(operand); if (valueResult == null || valueResult.getType() == null) { return null; } final ConversionType conversionType = MetadataHelper.getConversionType(targetResult.getType(), valueResult.getType()); if (conversionType == ConversionType.NONE) { addCastForAssignment(node.getType(), node.getExpression()); } if (RedundantCastUtility.isCastRedundant(_resolver, node)) { RedundantCastUtility.removeCast(node); } return null; }
@Override public Void visitCastExpression(final CastExpression node, final Void ignored) { startNode(node); leftParenthesis(); space(policy.SpacesWithinCastParentheses); node.getType().acceptVisitor(this, ignored); space(policy.SpacesWithinCastParentheses); rightParenthesis(); space(policy.SpaceAfterTypecast); node.getExpression().acceptVisitor(this, ignored); endNode(node); return null; }
@Override public Void visitCastExpression(final CastExpression node, final Void ignored) { startNode(node); leftParenthesis(); space(policy.SpacesWithinCastParentheses); node.getType().acceptVisitor(this, ignored); space(policy.SpacesWithinCastParentheses); rightParenthesis(); space(policy.SpaceAfterTypecast); node.getExpression().acceptVisitor(this, ignored); endNode(node); return null; }
@Override public Void visitCastExpression(final CastExpression node, final Void ignored) { startNode(node); leftParenthesis(); space(policy.SpacesWithinCastParentheses); node.getType().acceptVisitor(this, ignored); space(policy.SpacesWithinCastParentheses); rightParenthesis(); space(policy.SpaceAfterTypecast); node.getExpression().acceptVisitor(this, ignored); endNode(node); return null; }
@Override public ResolveResult visitCastExpression(final CastExpression node, final Void data) { final ResolveResult childResult = node.getExpression().acceptVisitor(this, data); final ResolveResult typeResult = resolveType(node.getType()); if (typeResult == null) { return childResult; } final TypeReference resolvedType = typeResult.getType(); if (resolvedType != null) { if (resolvedType.isPrimitive() && childResult != null && childResult.isCompileTimeConstant()) { return new PrimitiveResolveResult( resolvedType, JavaPrimitiveCast.cast(resolvedType.getSimpleType(), childResult.getConstantValue()) ); } return new ResolveResult(resolvedType); } return typeResult; }
@Override public ResolveResult visitCastExpression(final CastExpression node, final Void data) { final ResolveResult childResult = node.getExpression().acceptVisitor(this, data); final ResolveResult typeResult = resolveType(node.getType()); if (typeResult == null) { return childResult; } final TypeReference resolvedType = typeResult.getType(); if (resolvedType != null) { if (resolvedType.isPrimitive() && childResult != null && childResult.isCompileTimeConstant()) { return new PrimitiveResolveResult( resolvedType, JavaPrimitiveCast.cast(resolvedType.getSimpleType(), childResult.getConstantValue()) ); } return new ResolveResult(resolvedType); } return typeResult; }
@Override public ResolveResult visitCastExpression(final CastExpression node, final Void data) { final ResolveResult childResult = node.getExpression().acceptVisitor(this, data); final ResolveResult typeResult = resolveType(node.getType()); if (typeResult == null) { return childResult; } final TypeReference resolvedType = typeResult.getType(); if (resolvedType != null) { if (resolvedType.isPrimitive() && childResult != null && childResult.isCompileTimeConstant()) { return new PrimitiveResolveResult( resolvedType, JavaPrimitiveCast.cast(resolvedType.getSimpleType(), childResult.getConstantValue()) ); } return new ResolveResult(resolvedType); } return typeResult; }