private static ResolveResult resolveType(final AstType type) { if (type == null || type.isNull()) { return null; } return resolveType(type.toTypeReference()); }
private static ResolveResult resolveType(final AstType type) { if (type == null || type.isNull()) { return null; } return resolveType(type.toTypeReference()); }
private static ResolveResult resolveType(final AstType type) { if (type == null || type.isNull()) { return null; } return resolveType(type.toTypeReference()); }
public static boolean isBinaryOperatorApplicable( @NotNull final BinaryOperatorType op, @NotNull final AstType lType, @NotNull final AstType rType, final boolean strict) { return isBinaryOperatorApplicable( op, VerifyArgument.notNull(lType, "lType").toTypeReference(), VerifyArgument.notNull(rType, "rType").toTypeReference(), strict ); }
public static boolean isBinaryOperatorApplicable( @NotNull final BinaryOperatorType op, @NotNull final AstType lType, @NotNull final AstType rType, final boolean strict) { return isBinaryOperatorApplicable( op, VerifyArgument.notNull(lType, "lType").toTypeReference(), VerifyArgument.notNull(rType, "rType").toTypeReference(), strict ); }
public static boolean isBinaryOperatorApplicable( @NotNull final BinaryOperatorType op, @NotNull final AstType lType, @NotNull final AstType rType, @Nullable final TypeReference expectedResultType, final boolean strict) { return isBinaryOperatorApplicable( op, VerifyArgument.notNull(lType, "lType").toTypeReference(), VerifyArgument.notNull(rType, "rType").toTypeReference(), expectedResultType, strict ); }
@Override public TypeReference toTypeReference() { TypeReference typeReference = getBaseType().toTypeReference(); for (ArraySpecifier specifier = getArraySpecifiers().firstOrNullObject(); specifier != null; specifier = specifier.getNextSibling(ARRAY_SPECIFIER_ROLE)) { typeReference = typeReference.makeArrayType(); } return typeReference; }
@Override public TypeReference toTypeReference() { TypeReference typeReference = getBaseType().toTypeReference(); for (ArraySpecifier specifier = getArraySpecifiers().firstOrNullObject(); specifier != null; specifier = specifier.getNextSibling(ARRAY_SPECIFIER_ROLE)) { typeReference = typeReference.makeArrayType(); } return typeReference; }
@Override public TypeReference toTypeReference() { TypeReference typeReference = getBaseType().toTypeReference(); for (ArraySpecifier specifier = getArraySpecifiers().firstOrNullObject(); specifier != null; specifier = specifier.getNextSibling(ARRAY_SPECIFIER_ROLE)) { typeReference = typeReference.makeArrayType(); } return typeReference; }
public ImportDeclaration(final AstType type) { final TypeReference typeReference = VerifyArgument.notNull(type, "type").toTypeReference(); if (typeReference != null) { setImport(typeReference.getFullName()); putUserData(Keys.TYPE_REFERENCE, typeReference); } else { setImport(type.toString()); } }
public ImportDeclaration(final AstType type) { final TypeReference typeReference = VerifyArgument.notNull(type, "type").toTypeReference(); if (typeReference != null) { setImport(typeReference.getFullName()); putUserData(Keys.TYPE_REFERENCE, typeReference); } else { setImport(type.toString()); } }
public ImportDeclaration(final AstType type) { final TypeReference typeReference = VerifyArgument.notNull(type, "type").toTypeReference(); if (typeReference != null) { setImport(typeReference.getFullName()); putUserData(Keys.TYPE_REFERENCE, typeReference); } else { setImport(type.toString()); } }
@Override public ResolveResult visitArrayCreationExpression(final ArrayCreationExpression node, final Void data) { final TypeReference elementType = node.getType().toTypeReference(); if (elementType == null) { return null; } final int rank = node.getDimensions().size() + node.getAdditionalArraySpecifiers().size(); TypeReference arrayType = elementType; for (int i = 0; i < rank; i++) { arrayType = arrayType.makeArrayType(); } return new ResolveResult(arrayType); }
@Override public ResolveResult visitArrayCreationExpression(final ArrayCreationExpression node, final Void data) { final TypeReference elementType = node.getType().toTypeReference(); if (elementType == null) { return null; } final int rank = node.getDimensions().size() + node.getAdditionalArraySpecifiers().size(); TypeReference arrayType = elementType; for (int i = 0; i < rank; i++) { arrayType = arrayType.makeArrayType(); } return new ResolveResult(arrayType); }
@Override public ResolveResult visitArrayCreationExpression(final ArrayCreationExpression node, final Void data) { final TypeReference elementType = node.getType().toTypeReference(); if (elementType == null) { return null; } final int rank = node.getDimensions().size() + node.getAdditionalArraySpecifiers().size(); TypeReference arrayType = elementType; for (int i = 0; i < rank; i++) { arrayType = arrayType.makeArrayType(); } return new ResolveResult(arrayType); }
final TypeReference typeReference = castType.toTypeReference();
@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); }
@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); }
@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); }
protected void processPossibleTypeCast(final Expression rightExpression, @Nullable final TypeReference leftType) { if (leftType == null) { return; } final Expression r = removeParentheses(rightExpression); if (r instanceof CastExpression) { final AstType castAstType = ((CastExpression) r).getType(); final TypeReference castType = castAstType != null ? castAstType.toTypeReference() : null; final Expression castOperand = ((CastExpression) r).getExpression(); if (castOperand != null && !castOperand.isNull() && castType != null) { final TypeReference operandType = getType(castOperand); if (operandType != null) { if (MetadataHelper.isAssignableFrom(leftType, operandType, false)) { addToResults((CastExpression) r, false); } else { final TypeReference unboxedCastType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(castType); final TypeReference unboxedLeftType = MetadataHelper.getUnderlyingPrimitiveTypeOrSelf(leftType); if (castOperand instanceof PrimitiveExpression && TypeUtilities.isValidPrimitiveLiteralAssignment(unboxedCastType, ((PrimitiveExpression) castOperand).getValue()) && TypeUtilities.isValidPrimitiveLiteralAssignment(unboxedLeftType, ((PrimitiveExpression) castOperand).getValue())) { addToResults((CastExpression) r, true); } } } } } }