Exemple #1
0
        static JavaTypeReference JavaTypeNameToReference(this JavaApi api, JavaTypeName tn, params JavaTypeParameters?[] contextTypeParameters)
        {
            var tp = contextTypeParameters.Where(tps => tps != null)
                     .SelectMany(tps => tps !.TypeParameters)
                     .FirstOrDefault(xp => xp.Name == tn.DottedName);

            if (tp != null)
            {
                return(new JavaTypeReference(tp, tn.ArrayPart));
            }
            if (tn.DottedName == JavaTypeReference.GenericWildcard.SpecialName)
            {
                return(new JavaTypeReference(tn.BoundsType, tn.GenericConstraints?.Select(gc => JavaTypeNameToReference(api, gc, contextTypeParameters)), tn.ArrayPart));
            }
            var primitive = JavaTypeReference.GetSpecialType(tn.DottedName);

            if (primitive != null)
            {
                return(tn.ArrayPart == null && tn.GenericConstraints == null ? primitive : new JavaTypeReference(primitive, tn.ArrayPart, tn.BoundsType, tn.GenericConstraints?.Select(gc => JavaTypeNameToReference(api, gc, contextTypeParameters))));
            }
            var type = api.FindNonGenericType(tn.FullNameNonGeneric);

            return(new JavaTypeReference(type,
                                         tn.GenericArguments != null ? tn.GenericArguments.Select(_ => api.JavaTypeNameToReference(_, contextTypeParameters)).ToArray() : null,
                                         tn.ArrayPart));
        }
Exemple #2
0
        static JavaTypeReference JavaTypeNameToReference(this JavaApi api, JavaTypeName tn, params JavaTypeParameters [] contextTypeParameters)
        {
            var tp = contextTypeParameters.Where(tps => tps != null).SelectMany(tps => tps.TypeParameters).FirstOrDefault(_ => _.Name == tn.FullNameNonGeneric);

            if (tp != null)
            {
                return(new JavaTypeReference(tp, tn.ArrayPart));
            }
            var primitive = JavaTypeReference.GetSpecialType(tn.FullNameNonGeneric);

            if (primitive != null)
            {
                return(tn.ArrayPart == null ? primitive : new JavaTypeReference(primitive, tn.ArrayPart));
            }
            var type = api.FindNonGenericType(tn.FullNameNonGeneric);

            return(new JavaTypeReference(type,
                                         tn.GenericArguments != null ? tn.GenericArguments.Select(_ => api.JavaTypeNameToReference(_, contextTypeParameters)).ToArray() : null,
                                         tn.ArrayPart));
        }