@Override public TypeBinding withoutToplevelNullAnnotation() { if (!hasNullTypeAnnotations()) return this; ReferenceBinding unannotatedGenericType = (ReferenceBinding) this.environment.getUnannotatedType(this.genericType()); AnnotationBinding[] newAnnotations = this.environment.filterNullTypeAnnotations(this.typeAnnotations); return this.environment.createRawType(unannotatedGenericType, this.enclosingType(), newAnnotations); }
@Override public TypeBinding withoutToplevelNullAnnotation() { if (!hasNullTypeAnnotations()) return this; ReferenceBinding unannotatedGenericType = (ReferenceBinding) this.environment.getUnannotatedType(this.genericType()); AnnotationBinding[] newAnnotations = this.environment.filterNullTypeAnnotations(this.typeAnnotations); return this.environment.createRawType(unannotatedGenericType, this.enclosingType(), newAnnotations); }
@Override public TypeBinding withoutToplevelNullAnnotation() { if (!hasNullTypeAnnotations()) return this; ReferenceBinding unannotatedGenericType = (ReferenceBinding) this.environment.getUnannotatedType(this.genericType()); AnnotationBinding[] newAnnotations = this.environment.filterNullTypeAnnotations(this.typeAnnotations); return this.environment.createRawType(unannotatedGenericType, this.enclosingType(), newAnnotations); }
/** Apply the given type arguments on the (declaring class of the) actual constructor being represented by this factory method and if method type arguments is not empty materialize the parameterized generic constructor * @param targetType */ public ParameterizedMethodBinding applyTypeArgumentsOnConstructor(TypeBinding[] typeArguments, TypeBinding[] constructorTypeArguments, boolean inferredWithUncheckedConversion, TypeBinding targetType) { ReferenceBinding parameterizedType = typeArguments == null ? this.environment.createRawType(this.declaringClass, this.enclosingType) : this.environment.createParameterizedType(this.declaringClass, typeArguments, this.enclosingType); for (MethodBinding parameterizedMethod : parameterizedType.methods()) { if (parameterizedMethod.original() == this.staticFactoryFor) return (constructorTypeArguments.length > 0 || inferredWithUncheckedConversion) ? this.environment.createParameterizedGenericMethod(parameterizedMethod, constructorTypeArguments, inferredWithUncheckedConversion, false, targetType) : (ParameterizedMethodBinding) parameterizedMethod; if (parameterizedMethod instanceof ProblemMethodBinding) { MethodBinding closestMatch = ((ProblemMethodBinding)parameterizedMethod).closestMatch; if (closestMatch instanceof ParameterizedMethodBinding && closestMatch.original() == this.staticFactoryFor) return (ParameterizedMethodBinding) closestMatch; } } throw new IllegalArgumentException("Type doesn't have its own method?"); //$NON-NLS-1$ } }
@Override public TypeBinding withoutToplevelNullAnnotation() { if (!hasNullTypeAnnotations()) return this; ReferenceBinding unannotatedGenericType = (ReferenceBinding) this.environment.getUnannotatedType(this.genericType()); AnnotationBinding[] newAnnotations = this.environment.filterNullTypeAnnotations(this.typeAnnotations); return this.environment.createRawType(unannotatedGenericType, this.enclosingType(), newAnnotations); }
/** Apply the given type arguments on the (declaring class of the) actual constructor being represented by this factory method and if method type arguments is not empty materialize the parameterized generic constructor * @param targetType */ public ParameterizedMethodBinding applyTypeArgumentsOnConstructor(TypeBinding[] typeArguments, TypeBinding[] constructorTypeArguments, boolean inferredWithUncheckedConversion, TypeBinding targetType) { ReferenceBinding parameterizedType = typeArguments == null ? this.environment.createRawType(this.declaringClass, this.enclosingType) : this.environment.createParameterizedType(this.declaringClass, typeArguments, this.enclosingType); for (MethodBinding parameterizedMethod : parameterizedType.methods()) { if (parameterizedMethod.original() == this.staticFactoryFor) return (constructorTypeArguments.length > 0 || inferredWithUncheckedConversion) ? this.environment.createParameterizedGenericMethod(parameterizedMethod, constructorTypeArguments, inferredWithUncheckedConversion, false, targetType) : (ParameterizedMethodBinding) parameterizedMethod; if (parameterizedMethod instanceof ProblemMethodBinding) { MethodBinding closestMatch = ((ProblemMethodBinding)parameterizedMethod).closestMatch; if (closestMatch instanceof ParameterizedMethodBinding && closestMatch.original() == this.staticFactoryFor) return (ParameterizedMethodBinding) closestMatch; } } throw new IllegalArgumentException("Type doesn't have its own method?"); //$NON-NLS-1$ } }
@Override public TypeBinding withoutToplevelNullAnnotation() { if (!hasNullTypeAnnotations()) return this; ReferenceBinding unannotatedGenericType = (ReferenceBinding) this.environment.getUnannotatedType(this.genericType()); AnnotationBinding[] newAnnotations = this.environment.filterNullTypeAnnotations(this.typeAnnotations); return this.environment.createRawType(unannotatedGenericType, this.enclosingType(), newAnnotations); }
@Override public DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs) { int typeArgsLength = typeArgs.length; TypeElementImpl typeElementImpl = (TypeElementImpl) typeElem; ReferenceBinding elementBinding = (ReferenceBinding) typeElementImpl._binding; TypeVariableBinding[] typeVariables = elementBinding.typeVariables(); int typeVariablesLength = typeVariables.length; if (typeArgsLength == 0) { if (elementBinding.isGenericType()) { // per javadoc, return (DeclaredType) _env.getFactory().newTypeMirror(this._env.getLookupEnvironment().createRawType(elementBinding, null)); } return (DeclaredType)typeElem.asType(); } else if (typeArgsLength != typeVariablesLength) { throw new IllegalArgumentException("Number of typeArguments doesn't match the number of formal parameters of typeElem"); //$NON-NLS-1$ } TypeBinding[] typeArguments = new TypeBinding[typeArgsLength]; for (int i = 0; i < typeArgsLength; i++) { TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) typeArgs[i]; Binding binding = typeMirrorImpl._binding; if (!(binding instanceof TypeBinding)) { throw new IllegalArgumentException("Invalid type argument: " + typeMirrorImpl); //$NON-NLS-1$ } typeArguments[i] = (TypeBinding) binding; } return (DeclaredType) _env.getFactory().newTypeMirror( this._env.getLookupEnvironment().createParameterizedType(elementBinding, typeArguments, null)); }
@Override public DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs) { int typeArgsLength = typeArgs.length; TypeElementImpl typeElementImpl = (TypeElementImpl) typeElem; ReferenceBinding referenceBinding = (ReferenceBinding) typeElementImpl._binding; TypeVariableBinding[] typeVariables = referenceBinding.typeVariables(); int typeVariablesLength = typeVariables.length; if (typeArgsLength == 0) { if (referenceBinding.isGenericType()) { // must return a raw type return _env.getFactory().newDeclaredType(this._env.getLookupEnvironment().createRawType(referenceBinding, null)); } return (DeclaredType)typeElem.asType(); } else if (typeArgsLength != typeVariablesLength) { throw new IllegalArgumentException("Number of typeArguments doesn't match the number of formal parameters of typeElem"); //$NON-NLS-1$ } TypeBinding[] typeArguments = new TypeBinding[typeArgsLength]; for (int i = 0; i < typeArgsLength; i++) { TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) typeArgs[i]; Binding binding = typeMirrorImpl._binding; if (!(binding instanceof TypeBinding)) { throw new IllegalArgumentException("Invalid type argument: " + typeMirrorImpl); //$NON-NLS-1$ } typeArguments[i] = (TypeBinding) binding; } return _env.getFactory().newDeclaredType( this._env.getLookupEnvironment().createParameterizedType(referenceBinding, typeArguments, null)); }
@Override public DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs) { int typeArgsLength = typeArgs.length; TypeElementImpl typeElementImpl = (TypeElementImpl) typeElem; ReferenceBinding referenceBinding = (ReferenceBinding) typeElementImpl._binding; TypeVariableBinding[] typeVariables = referenceBinding.typeVariables(); int typeVariablesLength = typeVariables.length; if (typeArgsLength == 0) { if (referenceBinding.isGenericType()) { // must return a raw type return (DeclaredType) _env.getFactory().newTypeMirror(this._env.getLookupEnvironment().createRawType(referenceBinding, null)); } return (DeclaredType)typeElem.asType(); } else if (typeArgsLength != typeVariablesLength) { throw new IllegalArgumentException("Number of typeArguments doesn't match the number of formal parameters of typeElem"); //$NON-NLS-1$ } TypeBinding[] typeArguments = new TypeBinding[typeArgsLength]; for (int i = 0; i < typeArgsLength; i++) { TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) typeArgs[i]; Binding binding = typeMirrorImpl._binding; if (!(binding instanceof TypeBinding)) { throw new IllegalArgumentException("Invalid type argument: " + typeMirrorImpl); //$NON-NLS-1$ } typeArguments[i] = (TypeBinding) binding; } return (DeclaredType) _env.getFactory().newTypeMirror( this._env.getLookupEnvironment().createParameterizedType(referenceBinding, typeArguments, null)); }
@Override public DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs) { int typeArgsLength = typeArgs.length; TypeElementImpl typeElementImpl = (TypeElementImpl) typeElem; ReferenceBinding referenceBinding = (ReferenceBinding) typeElementImpl._binding; TypeVariableBinding[] typeVariables = referenceBinding.typeVariables(); int typeVariablesLength = typeVariables.length; if (typeArgsLength == 0) { if (referenceBinding.isGenericType()) { // must return a raw type return (DeclaredType) _env.getFactory().newTypeMirror(this._env.getLookupEnvironment().createRawType(referenceBinding, null)); } return (DeclaredType)typeElem.asType(); } else if (typeArgsLength != typeVariablesLength) { throw new IllegalArgumentException("Number of typeArguments doesn't match the number of formal parameters of typeElem"); //$NON-NLS-1$ } TypeBinding[] typeArguments = new TypeBinding[typeArgsLength]; for (int i = 0; i < typeArgsLength; i++) { TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) typeArgs[i]; Binding binding = typeMirrorImpl._binding; if (!(binding instanceof TypeBinding)) { throw new IllegalArgumentException("Invalid type argument: " + typeMirrorImpl); //$NON-NLS-1$ } typeArguments[i] = (TypeBinding) binding; } return (DeclaredType) _env.getFactory().newTypeMirror( this._env.getLookupEnvironment().createParameterizedType(referenceBinding, typeArguments, null)); }
@Override public DeclaredType getDeclaredType(TypeElement typeElem, TypeMirror... typeArgs) { int typeArgsLength = typeArgs.length; TypeElementImpl typeElementImpl = (TypeElementImpl) typeElem; ReferenceBinding elementBinding = (ReferenceBinding) typeElementImpl._binding; TypeVariableBinding[] typeVariables = elementBinding.typeVariables(); int typeVariablesLength = typeVariables.length; if (typeArgsLength == 0) { if (elementBinding.isGenericType()) { // per javadoc, return (DeclaredType) _env.getFactory().newTypeMirror(this._env.getLookupEnvironment().createRawType(elementBinding, null)); } return (DeclaredType)typeElem.asType(); } else if (typeArgsLength != typeVariablesLength) { throw new IllegalArgumentException("Number of typeArguments doesn't match the number of formal parameters of typeElem"); //$NON-NLS-1$ } TypeBinding[] typeArguments = new TypeBinding[typeArgsLength]; for (int i = 0; i < typeArgsLength; i++) { TypeMirrorImpl typeMirrorImpl = (TypeMirrorImpl) typeArgs[i]; Binding binding = typeMirrorImpl._binding; if (!(binding instanceof TypeBinding)) { throw new IllegalArgumentException("Invalid type argument: " + typeMirrorImpl); //$NON-NLS-1$ } typeArguments[i] = (TypeBinding) binding; } return (DeclaredType) _env.getFactory().newTypeMirror( this._env.getLookupEnvironment().createParameterizedType(elementBinding, typeArguments, null)); }
if (referenceBinding.isGenericType()) { return (DeclaredType) _env.getFactory().newTypeMirror(this._env.getLookupEnvironment().createRawType(referenceBinding, enclosingType));
public void consumeParameterizedType(char[] simpleTypeName, boolean isRaw) { if (this.typeBinding == null) return; TypeBinding[] arguments = getTypeBindingArguments(); if (arguments == null) { this.typeBinding = null; this.genericType = null; return; } if (simpleTypeName != null) { if (this.genericType == null) { // parameterized member type with raw enclosing type this.genericType = ((ReferenceBinding) this.typeBinding).getMemberType(simpleTypeName); } else { // parameterized member type with parameterized enclosing type this.genericType = this.genericType.getMemberType(simpleTypeName); } if (!isRaw) this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, (ReferenceBinding) this.typeBinding); else // raw type this.typeBinding = this.environment.createRawType(this.genericType, (ReferenceBinding) this.typeBinding); } else { // parameterized top level type or parameterized member type with raw enclosing type this.genericType = (ReferenceBinding) this.typeBinding; ReferenceBinding enclosing = this.genericType.enclosingType(); if (enclosing != null) enclosing = (ReferenceBinding) this.environment.convertToRawType(enclosing, false /*do not force conversion of enclosing types*/); this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, enclosing); } }
else this.typeBinding = this.environment.createRawType(this.genericType, (ReferenceBinding) this.typeBinding); } else {
public void consumeParameterizedType(char[] simpleTypeName, boolean isRaw) { if (this.typeBinding == null) return; TypeBinding[] arguments = getTypeBindingArguments(); if (arguments == null) { this.typeBinding = null; this.genericType = null; return; } if (simpleTypeName != null) { if (this.genericType == null) { // parameterized member type with raw enclosing type this.genericType = ((ReferenceBinding) this.typeBinding).getMemberType(simpleTypeName); } else { // parameterized member type with parameterized enclosing type this.genericType = this.genericType.getMemberType(simpleTypeName); } if (!isRaw) this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, (ReferenceBinding) this.typeBinding); else // raw type this.typeBinding = this.environment.createRawType(this.genericType, (ReferenceBinding) this.typeBinding); } else { // parameterized top level type or parameterized member type with raw enclosing type this.genericType = (ReferenceBinding) this.typeBinding; ReferenceBinding enclosing = this.genericType.enclosingType(); if (enclosing != null) enclosing = (ReferenceBinding) this.environment.convertToRawType(enclosing, false /*do not force conversion of enclosing types*/); this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, enclosing); } }
public void consumeParameterizedType(char[] simpleTypeName, boolean isRaw) { if (this.typeBinding == null) return; TypeBinding[] arguments = getTypeBindingArguments(); if (arguments == null) { this.typeBinding = null; this.genericType = null; return; } if (simpleTypeName != null) { if (this.genericType == null) { // parameterized member type with raw enclosing type this.genericType = ((ReferenceBinding) this.typeBinding).getMemberType(simpleTypeName); } else { // parameterized member type with parameterized enclosing type this.genericType = this.genericType.getMemberType(simpleTypeName); } if (!isRaw) this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, (ReferenceBinding) this.typeBinding); else // raw type this.typeBinding = this.environment.createRawType(this.genericType, (ReferenceBinding) this.typeBinding); } else { // parameterized top level type or parameterized member type with raw enclosing type this.genericType = (ReferenceBinding) this.typeBinding; ReferenceBinding enclosing = this.genericType.enclosingType(); if (enclosing != null) enclosing = (ReferenceBinding) this.environment.convertToRawType(enclosing, false /*do not force conversion of enclosing types*/); this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, enclosing); } }
public void consumeParameterizedType(char[] simpleTypeName, boolean isRaw) { if (this.typeBinding == null) return; TypeBinding[] arguments = getTypeBindingArguments(); if (arguments == null) { this.typeBinding = null; this.genericType = null; return; } if (simpleTypeName != null) { if (this.genericType == null) { // parameterized member type with raw enclosing type this.genericType = ((ReferenceBinding) this.typeBinding).getMemberType(simpleTypeName); } else { // parameterized member type with parameterized enclosing type this.genericType = this.genericType.getMemberType(simpleTypeName); } if (!isRaw) this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, (ReferenceBinding) this.typeBinding); else // raw type this.typeBinding = this.environment.createRawType(this.genericType, (ReferenceBinding) this.typeBinding); } else { // parameterized top level type or parameterized member type with raw enclosing type this.genericType = (ReferenceBinding) this.typeBinding; ReferenceBinding enclosing = this.genericType.enclosingType(); if (enclosing != null) enclosing = (ReferenceBinding) this.environment.convertToRawType(enclosing, false /*do not force conversion of enclosing types*/); this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, enclosing); } }
public void consumeParameterizedType(char[] simpleTypeName, boolean isRaw) { if (this.typeBinding == null) return; TypeBinding[] arguments = getTypeBindingArguments(); if (arguments == null) { this.typeBinding = null; this.genericType = null; return; } if (simpleTypeName != null) { if (this.genericType == null) { // parameterized member type with raw enclosing type this.genericType = ((ReferenceBinding) this.typeBinding).getMemberType(simpleTypeName); } else { // parameterized member type with parameterized enclosing type this.genericType = this.genericType.getMemberType(simpleTypeName); } if (!isRaw) this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, (ReferenceBinding) this.typeBinding); else // raw type this.typeBinding = this.environment.createRawType(this.genericType, (ReferenceBinding) this.typeBinding); } else { // parameterized top level type or parameterized member type with raw enclosing type this.genericType = (ReferenceBinding) this.typeBinding; ReferenceBinding enclosing = this.genericType.enclosingType(); if (enclosing != null) enclosing = (ReferenceBinding) this.environment.convertToRawType(enclosing, false /*do not force conversion of enclosing types*/); this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, enclosing); } }
public void consumeParameterizedType(char[] simpleTypeName, boolean isRaw) { if (this.typeBinding == null) return; TypeBinding[] arguments = getTypeBindingArguments(); if (arguments == null) { this.typeBinding = null; this.genericType = null; return; } if (simpleTypeName != null) { if (this.genericType == null) { // parameterized member type with raw enclosing type this.genericType = ((ReferenceBinding) this.typeBinding).getMemberType(simpleTypeName); } else { // parameterized member type with parameterized enclosing type this.genericType = this.genericType.getMemberType(simpleTypeName); } if (!isRaw) this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, (ReferenceBinding) this.typeBinding); else // raw type this.typeBinding = this.environment.createRawType(this.genericType, (ReferenceBinding) this.typeBinding); } else { // parameterized top level type or parameterized member type with raw enclosing type this.genericType = (ReferenceBinding) this.typeBinding; ReferenceBinding enclosing = this.genericType.enclosingType(); if (enclosing != null) enclosing = (ReferenceBinding) this.environment.convertToRawType(enclosing, false /*do not force conversion of enclosing types*/); this.typeBinding = this.environment.createParameterizedType(this.genericType, arguments, enclosing); } }