/** * Is the type represented by the specified binding a constrained type? * * @param binding the binding to check, or <code>null</code> * @return <code>true</code> if it is constrained, <code>false</code> otherwise */ public static boolean isConstrainedType(final ITypeBinding binding) { return binding != null && !binding.isSynthetic() && !binding.isPrimitive(); }
/** * Is the type represented by the specified binding a constrained type? * * @param binding the binding to check, or <code>null</code> * @return <code>true</code> if it is constrained, <code>false</code> otherwise */ public static boolean isConstrainedType(final ITypeBinding binding) { return binding != null && !binding.isSynthetic() && !binding.isPrimitive(); }
/** * Is the type represented by the specified binding a constrained type? * * @param binding the binding to check, or <code>null</code> * @return <code>true</code> if it is constrained, <code>false</code> otherwise */ public static boolean isConstrainedType(final ITypeBinding binding) { return binding != null && !binding.isSynthetic() && !binding.isPrimitive(); }
/** * Returns whether the provided type binding represents the provided primitive type. * * @param typeBinding the type binding to analyze * @param primitiveTypeName the primitive type name * @return true if the provided type binding represents the provided primitive type, false otherwise */ public static boolean isPrimitive(ITypeBinding typeBinding, String primitiveTypeName) { return typeBinding != null && typeBinding.isPrimitive() && typeBinding.getQualifiedName().equals(primitiveTypeName); }
/** * Returns whether the provided type binding represents a primitive type. * * @param typeBinding the type binding to analyze * @return true if the provided type binding represents a primitive type, false otherwise */ public static boolean isPrimitive(ITypeBinding typeBinding) { return typeBinding != null && typeBinding.isPrimitive() && Arrays.asList("boolean", "byte", "char", "short", "int", "long", "float", "double") .contains(typeBinding.getQualifiedName()); }
/** * Returns an enum representing the primitive type of this type binding. * * @param typeBinding the type binding to analyze * @return an enum representing the primitive type of this type binding, * {@code null} if the type binding is null, or if it does not a primitive type. */ public static PrimitiveEnum getPrimitiveEnum(ITypeBinding typeBinding) { return typeBinding != null && typeBinding.isPrimitive() ? PrimitiveEnum.valueOf2(typeBinding.getQualifiedName()) : null; }
private void coupleTo(ITypeBinding binding) { if (binding == null) return; if (binding.isWildcardType()) return; String type = binding.getQualifiedName(); if (type.equals("null")) return; if (!isFromJava(type) && !binding.isPrimitive()) coupling.add(type.replace("[]", "")); }
public static ITypeBinding[] getNarrowingTypes(AST ast, ITypeBinding type) { ArrayList res= new ArrayList(); res.add(type); if (type.isPrimitive()) { Code code= PrimitiveType.toCode(type.getName()); for (int i= 0; i < CODE_ORDER.length && code != CODE_ORDER[i]; i++) { String typeName= CODE_ORDER[i].toString(); res.add(ast.resolveWellKnownType(typeName)); } } return (ITypeBinding[]) res.toArray(new ITypeBinding[res.size()]); }
public static ITypeBinding[] getNarrowingTypes(AST ast, ITypeBinding type) { ArrayList<ITypeBinding> res= new ArrayList<>(); res.add(type); if (type.isPrimitive()) { Code code= PrimitiveType.toCode(type.getName()); for (int i= 0; i < CODE_ORDER.length && code != CODE_ORDER[i]; i++) { String typeName= CODE_ORDER[i].toString(); res.add(ast.resolveWellKnownType(typeName)); } } return res.toArray(new ITypeBinding[res.size()]); }
public static ITypeBinding[] getNarrowingTypes(AST ast, ITypeBinding type) { ArrayList<ITypeBinding> res= new ArrayList<>(); res.add(type); if (type.isPrimitive()) { Code code= PrimitiveType.toCode(type.getName()); for (int i= 0; i < CODE_ORDER.length && code != CODE_ORDER[i]; i++) { String typeName= CODE_ORDER[i].toString(); res.add(ast.resolveWellKnownType(typeName)); } } return res.toArray(new ITypeBinding[res.size()]); }
private static boolean isIntegerType(ITypeBinding binding) { if (binding == null) return false; if (!binding.isPrimitive()) return false; String name= binding.getName(); if (isIntegerNumber(name)) return true; return false; }
private static boolean isIntegerType(ITypeBinding binding) { if (binding == null) return false; if (!binding.isPrimitive()) return false; String name= binding.getName(); if (isIntegerNumber(name)) return true; return false; }
private boolean replaceBooleanObjectByPrimitive(final QualifiedName node, final ITypeBinding typeBinding) { if (typeBinding != null && typeBinding.isPrimitive()) { if (isField(node, "java.lang.Boolean", "TRUE")) { return replaceWithBooleanLiteral(node, true); } else if (isField(node, "java.lang.Boolean", "FALSE")) { return replaceWithBooleanLiteral(node, false); } } return VISIT_SUBTREE; }
private TType getBoxedType(ITypeBinding typeBinding, Expression expression) { if (typeBinding == null) return null; if (! typeBinding.isPrimitive()) return createTType(typeBinding); if (expression == null || ! expression.resolveBoxing()) return null; ITypeBinding boxed= Bindings.getBoxedTypeBinding(typeBinding, expression.getAST()); return createTType(boxed); }
private TType getBoxedType(ITypeBinding typeBinding, Expression expression) { if (typeBinding == null) return null; if (! typeBinding.isPrimitive()) return createTType(typeBinding); if (expression == null || ! expression.resolveBoxing()) return null; ITypeBinding boxed= Bindings.getBoxedTypeBinding(typeBinding, expression.getAST()); return createTType(boxed); }
private ITypeConstraint[] getReturnTypeConstraint(Expression invocation, IMethodBinding methodBinding){ if (methodBinding == null || methodBinding.isConstructor() || methodBinding.getReturnType().isPrimitive()) return new ITypeConstraint[0]; ConstraintVariable returnTypeVariable= fConstraintVariableFactory.makeReturnTypeVariable(methodBinding); ConstraintVariable invocationVariable= fConstraintVariableFactory.makeExpressionOrTypeVariable(invocation, getContext()); return fTypeConstraintFactory.createDefinesConstraint(invocationVariable, returnTypeVariable); }
private ITypeConstraint[] getReturnTypeConstraint(Expression invocation, IMethodBinding methodBinding){ if (methodBinding == null || methodBinding.isConstructor() || methodBinding.getReturnType().isPrimitive()) return new ITypeConstraint[0]; ConstraintVariable returnTypeVariable= fConstraintVariableFactory.makeReturnTypeVariable(methodBinding); ConstraintVariable invocationVariable= fConstraintVariableFactory.makeExpressionOrTypeVariable(invocation, getContext()); return fTypeConstraintFactory.createDefinesConstraint(invocationVariable, returnTypeVariable); }
private ITypeConstraint[] getReturnTypeConstraint(Expression invocation, IMethodBinding methodBinding){ if (methodBinding == null || methodBinding.isConstructor() || methodBinding.getReturnType().isPrimitive()) return new ITypeConstraint[0]; ConstraintVariable returnTypeVariable= fConstraintVariableFactory.makeReturnTypeVariable(methodBinding); ConstraintVariable invocationVariable= fConstraintVariableFactory.makeExpressionOrTypeVariable(invocation, getContext()); return fTypeConstraintFactory.createDefinesConstraint(invocationVariable, returnTypeVariable); }
private TType getBoxedType(ITypeBinding typeBinding, Expression expression) { if (typeBinding == null) return null; if (! typeBinding.isPrimitive()) return createTType(typeBinding); if (expression == null || ! expression.resolveBoxing()) return null; String primitiveName= typeBinding.getName(); ITypeBinding boxed= expression.getAST().resolveWellKnownType(getBoxedTypeName(primitiveName)); return createTType(boxed); }
private void setUpMethodFromMethodBinding(Method method, IMethodBinding binding) { if (binding.isConstructor()) method.setKind(CONSTRUCTOR_KIND); ITypeBinding returnType = binding.getReturnType(); if ((returnType != null) && !(returnType.isPrimitive() && returnType.getName().equals("void"))) // we do not want to set void as a return type method.setDeclaredType(ensureTypeFromTypeBinding(returnType)); extractBasicModifiersFromBinding(binding.getModifiers(), method); if (Modifier.isStatic(binding.getModifiers())) method.setHasClassScope(true); }