public PreferredType(JvmType referencedType, JvmType usedType) { if (referencedType.eIsProxy()) { throw new IllegalArgumentException(); } this.referencedType = referencedType; this.usedType = usedType; this.unresolvedTypeName = null; } public PreferredType(String name) {
public IResolvedFeatures getResolvedFeatures(JvmType type) { if (type instanceof JvmDeclaredType && !type.eIsProxy()) { return RawResolvedFeatures.getResolvedFeatures((JvmDeclaredType) type, services); } return NO_FEATURES; } }
protected boolean isPrimitiveVoid(JvmTypeReference typeRef) { JvmType type = typeRef.getType(); if (type instanceof JvmVoid) { return !type.eIsProxy(); } return false; }
public boolean accept(JvmTypeReference superType, int distance) { JvmType rawType = superType.getType(); if (rawType != null && !rawType.eIsProxy() && rawTypes.add(superType.getType())) { result.add(superType); return true; } return false; } });
@Override public Boolean doVisitTypeReference(final JvmTypeReference it) { return Boolean.valueOf(((it.getType() == null) || it.getType().eIsProxy())); }
@Override public List<JvmType> doVisitGenericArrayTypeReference(JvmGenericArrayTypeReference reference, Resource resource) { JvmTypeReference componentType = reference.getComponentType(); List<JvmType> rawComponentTypes = visit(componentType, resource); List<JvmType> result = Lists.newArrayListWithCapacity(rawComponentTypes.size()); for(JvmType rawComponentType: rawComponentTypes) { if (!rawComponentType.eIsProxy() && rawComponentType instanceof JvmComponentType) { JvmArrayType arrayType = ((JvmComponentType) rawComponentType).getArrayType(); result.add(arrayType); } } return result; }
@Override protected List<JvmType> doVisitParameterizedTypeReference(ParameterizedTypeReference reference, ResourceSet resourceSet) { JvmType type = reference.getType(); if (!type.eIsProxy()) { if (type instanceof JvmTypeParameter) { return getRawTypesFromConstraints(reference.getOwner(), (JvmTypeParameter) type, resourceSet); } return Collections.singletonList(type); } return Collections.emptyList(); }
@Override public List<JvmType> doVisitParameterizedTypeReference(JvmParameterizedTypeReference reference, Resource resource) { JvmType type = reference.getType(); if (type != null && !type.eIsProxy()) { if (type instanceof JvmTypeParameter) { return getRawTypesFromConstraints(((JvmTypeParameter) type).getConstraints(), resource); } return Collections.singletonList(type); } return Collections.emptyList(); }
private boolean isProcedure() { JvmTypeReference returnType = getReturnType(); if (returnType == null) return true; JvmType type = returnType.getType(); if (type == null) return false; if (type.eIsProxy()) return false; if (type instanceof JvmVoid) return true; return false; }
@Override public List<JvmType> doVisitParameterizedTypeReference(JvmParameterizedTypeReference reference, Resource resource) { JvmType type = reference.getType(); if (type != null && !type.eIsProxy()) { if (type instanceof JvmTypeParameter) { return getRawTypesFromConstraints(((JvmTypeParameter) type).getConstraints(), resource); } return Collections.singletonList(type); } return Collections.emptyList(); }
public Iterable<JvmFeature> getAllJvmFeatures(JvmTypeReference type) { if (type == null) return Collections.emptyList(); ITypeArgumentContext context = contextProvider.getTypeArgumentContext( new TypeArgumentContextProvider.ReceiverRequest(type)); JvmType rawType = type.getType(); if (rawType == null || rawType.eIsProxy() || !(rawType instanceof JvmDeclaredType)) return Collections.emptyList(); return getAllJvmFeatures((JvmDeclaredType) rawType, context); }
@Override public JvmArrayType getType() { JvmType componentType = component.toJavaType().getType(); if (componentType instanceof JvmComponentType) { return Preconditions.checkNotNull(((JvmComponentType) componentType).getArrayType()); } if (component.isUnknown() || componentType.eIsProxy()) { return null; } throw new IllegalStateException("component type seems to be invalid: " + componentType + " / " + component); }
public String getSuperTypeName(JvmTypeReference typeReference) { if (typeReference instanceof JvmParameterizedTypeReference) { JvmType rawType = typeReference.getType(); if (rawType != null && !rawType.eIsProxy()) { return rawType.getIdentifier(); } return null; } else { return typeReference.getIdentifier(); } } });
protected void computeAllOperationsFromSuperTypes(JvmDeclaredType type, Multimap<String, AbstractResolvedOperation> processedOperations, Set<JvmType> processedTypes) { for (JvmTypeReference superType: type.getSuperTypes()) { JvmType rawSuperType = superType.getType(); if (rawSuperType instanceof JvmDeclaredType && !rawSuperType.eIsProxy() && processedTypes.add(rawSuperType)) { computeAllOperations((JvmDeclaredType) rawSuperType, processedOperations); computeAllOperationsFromSuperTypes((JvmDeclaredType) rawSuperType, processedOperations, processedTypes); } } }
@Override public StringBuilder doVisitInnerTypeReference(JvmInnerTypeReference reference, StringBuilder param) { JvmType type = reference.getType(); if (type == null || type.eIsProxy()) { return null; } param = reference.getOuter().accept(this, param); if (param == null) return null; param.append("."); return doVisitParameterizedTypeReference(reference, param); }
/** * Detects whether the type reference refers to primitive boolean. * * @since 2.9 */ protected boolean isPrimitiveBoolean(JvmTypeReference typeRef) { if (InferredTypeIndicator.isInferred(typeRef)) { return false; } return typeRef != null && typeRef.getType() != null && !typeRef.getType().eIsProxy() && "boolean".equals(typeRef.getType().getIdentifier()); }
@Check public void checkFunctionTypeArgsNonVoid(XFunctionTypeRef typeRef) { for (JvmTypeReference paramType : typeRef.getParamTypes()) { JvmType type = paramType.getType(); if (type instanceof JvmVoid && !type.eIsProxy()) { error("The primitive 'void' cannot be the type of a function parameter. ", paramType, null, -1, INVALID_USE_OF_TYPE); } } }
/** Replies if the given object is a valid type reference. */ @Pure protected boolean isTypeReference(JvmTypeReference typeReference) { return (typeReference != null && !typeReference.eIsProxy() && typeReference.getType() != null && !typeReference.getType().eIsProxy()); }
@Check public void checkPatternName(Pattern pattern) { if (pattern.getName() != null && !SourceVersion.isName(pattern.getName())) { JvmType inferredSpecification = inferrerUtil.findInferredSpecification(pattern); if (inferredSpecification != null && !inferredSpecification.eIsProxy() && !SourceVersion.isName(inferredSpecification.getQualifiedName())) { error(String.format("The pattern name %s is not a valid Java classname", pattern.getName()), PatternLanguagePackage.Literals.PATTERN__NAME, IssueCodes.OTHER_ISSUE); } } }
@Override public LightweightTypeReference doVisitParameterizedTypeReference(JvmParameterizedTypeReference reference) { JvmType type = getType(reference); if (type == null || type.eIsProxy()) { return createUnknownTypeReference(reference); } ParameterizedTypeReference result = owner.newParameterizedTypeReference(type); for(JvmTypeReference argument: reference.getArguments()) { result.addTypeArgument(visit(argument).getWrapperTypeIfPrimitive()); } return result; }