protected static LightweightTypeReference getComponentTypeIfLast(LightweightTypeReference type, List<JvmFormalParameter> parameter, int idx) { if (type != null) { if (idx >= parameter.size() - 1) { LightweightTypeReference componentType = type.getComponentType(); if (componentType != null) { return componentType; } } } return type; }
@Override /* @Nullable */ public LightweightTypeReference getComponentType() { if (internalIsResolved()) { return resolvedTo.getComponentType(); } return super.getComponentType(); }
@Override public LightweightTypeReference getComponentType() { if (components != null) { for(LightweightTypeReference component: components) { if (component.isArray()) return component.getComponentType(); } } return super.getComponentType(); }
@Override public TypeReference getArrayComponentType() { final LightweightTypeReference componentType = this.getDelegate().getComponentType(); if ((componentType == null)) { return null; } return this.getCompilationUnit().toTypeReference(componentType); }
private boolean isArrayTypeMismatch(LightweightTypeReference receiverType, LightweightTypeReference parameterType) { if (receiverType.isArray()) { if (parameterType.isArray()) { LightweightTypeReference componentType = parameterType.getComponentType(); if (isArrayTypeMismatch(receiverType.getComponentType(), componentType)) { return true; } return false; } return true; } else { if (!parameterType.isArray() && parameterType.isPrimitive()) { return true; } } return false; }
@Override /* @Nullable */ protected LightweightTypeReference getExpectedType() { JvmOperation operation = annotationValue.getOperation(); LightweightTypeReference result = getResolvedTypes().getActualType(operation); if (result != null && result.isArray()) { return result.getComponentType(); } return result; }
protected LightweightTypeReference getCollectionElementType(XCollectionLiteral literal) { LightweightTypeReference type = getLightweightType(literal); if (type == null) throw new IllegalStateException(); if(type.isArray()) { LightweightTypeReference result = type.getComponentType(); if (result == null) throw new IllegalStateException(); return result; } else if(type.isSubtypeOf(Collection.class) && type.hasTypeArguments()) { return type.getTypeArguments().get(0).getInvariantBoundSubstitute(); } return type.getOwner().newReferenceToObject(); }
protected Object _doEvaluate(XListLiteral literal, IEvaluationContext context, CancelIndicator indicator) { IResolvedTypes resolveTypes = typeResolver.resolveTypes(literal); LightweightTypeReference type = resolveTypes.getActualType(literal); List<Object> list = newArrayList(); for(XExpression element: literal.getElements()) { if (indicator.isCanceled()) throw new InterpreterCanceledException(); list.add(internalEvaluate(element, context, indicator)); } if(type != null && type.isArray()) { try { LightweightTypeReference componentType = type.getComponentType(); return Conversions.unwrapArray(list, getJavaType(componentType.getType())); } catch (ClassNotFoundException e) { } } return Collections.unmodifiableList(list); }
protected boolean isFinal(LightweightTypeReference expressionTypeRef) { if (expressionTypeRef.isArray()) { return isFinal(expressionTypeRef.getComponentType()); } if (expressionTypeRef.isPrimitive()) return true; return expressionTypeRef.getType() instanceof JvmDeclaredType && ((JvmDeclaredType) expressionTypeRef.getType()).isFinal(); }
/** Replies if the given reference is referencing a final type. * * @param expressionTypeRef - the type reference to test. * @return <code>true</code> if the given type is final. */ public static boolean isFinal(LightweightTypeReference expressionTypeRef) { if (expressionTypeRef.isArray()) { return isFinal(expressionTypeRef.getComponentType()); } if (expressionTypeRef.isPrimitive()) { return true; } return expressionTypeRef.getType() instanceof JvmDeclaredType && ((JvmDeclaredType) expressionTypeRef.getType()).isFinal(); }
protected Object wrapOrUnwrapArray(Object result, LightweightTypeReference expectedType) { if (expectedType.isArray() && !(result instanceof Object[])) { Class<?> arrayType; try { arrayType = getJavaType(expectedType.getComponentType().getType()); return Conversions.unwrapArray(result, arrayType); } catch (ClassNotFoundException e) { return result; } } else if (!expectedType.isArray() && expectedType.isSubtypeOf(Iterable.class)) { return Conversions.doWrapArray(result); } return result; }
private void convertListToArray( final LightweightTypeReference arrayTypeReference, final ITreeAppendable appendable, final Later expression) { appendable.append("(("); appendable.append(arrayTypeReference); appendable.append(")"); appendable.append(Conversions.class); appendable.append(".unwrapArray("); expression.exec(appendable); LightweightTypeReference rawTypeArrayReference = arrayTypeReference.getRawTypeReference(); appendable.append(", "); appendable.append(rawTypeArrayReference.getComponentType()); appendable.append(".class))"); }
LightweightTypeReference listType = type.tryConvertToListType(); if (listType != null) { LightweightTypeReference componentType = type.getComponentType(); if (componentType == null) { throw new IllegalStateException("Component type of an array may not be null");
LightweightTypeReference parameterType = getClosureOperationParameterType(type, operation, i); if (isVarArgs && i == closureParams.size()-1 && parameterType.isArray()) { b.append(parameterType.getComponentType()); b.append("..."); } else {
throw new IllegalStateException(); LightweightTypeReference componentType = lastParameterType.isArray() ? lastParameterType.getComponentType() : lastParameterType; if (componentType == null) { throw new IllegalStateException();
@Override public LightweightTypeReference substitute(LightweightTypeReference original) { if (original instanceof ArrayTypeReference) { LightweightTypeReference componentType = original.getComponentType(); if (componentType instanceof UnboundTypeReference) { LightweightTypeReference substitutedComponentType = substitute(componentType); return getOwner().newArrayTypeReference(substitutedComponentType); } } if (original instanceof UnboundTypeReference) { ConstraintVisitingInfo visitingInfo = createVisiting(); JvmTypeParameter typeParameter = ((UnboundTypeReference) original).getTypeParameter(); JvmTypeParameterDeclarator declarator = typeParameter.getDeclarator(); visitingInfo.pushInfo(declarator, declarator.getTypeParameters().indexOf(typeParameter)); LightweightTypeReference result = visitTypeArgument(original, visitingInfo); return result; } else { LightweightTypeReference result = original.accept(this, createVisiting()); return result; } }
parameter = parameter.getComponentType().getWrapperTypeIfPrimitive(); isPrimitive = this.immutableTypeValidator.isImmutable(parameter); } else {
LightweightTypeReference parameterType = getClosureOperationParameterType(type, operation, i); if (isVarArgs && i == closureParams.size()-1 && parameterType.isArray()) { appendClosureParameterVarArgs(closureParam, parameterType.getComponentType(), b); } else { appendClosureParameter(closureParam, parameterType, b);
final LightweightTypeReference parameterType = getClosureOperationParameterType(type, operation, i); if (isVarArgs && i == closureParams.size() - 1 && parameterType.isArray()) { appendClosureParameterVarArgs(closureParam, parameterType.getComponentType(), appendable); } else { appendClosureParameter(closureParam, parameterType, appendable);
LightweightTypeReference expectation = operation == null || operation.eIsProxy() ? null : state.getReferenceOwner().toLightweightTypeReference(operation.getReturnType()); if (expectation != null && expectation.isArray()) { LightweightTypeReference componentType = expectation.getComponentType(); if (componentType == null) { throw new IllegalStateException("Array without component type: " + expectation.getIdentifier());