public IType AsIType(KnownTypesCache knownTypesCache, IPsiModule module)
        {
            // TODO: It would be nice to also cache the closed generic and array types
            // We would need a different key for that

            IType type = knownTypesCache.GetByClrTypeName(ClrTypeName, module);

            if (TypeParameters.Length > 0)
            {
                var typeParameters = new IType[TypeParameters.Length];
                for (int i = 0; i < TypeParameters.Length; i++)
                {
                    typeParameters[i] = knownTypesCache.GetByClrTypeName(TypeParameters[i], module);
                }

                var typeElement = type.GetTypeElement().NotNull("typeElement != null");
                type = TypeFactory.CreateType(typeElement, typeParameters);
            }

            if (IsArray)
            {
                type = TypeFactory.CreateArrayType(type, 1);
            }

            return(type);
        }
Beispiel #2
0
 public ITypeElement GetTypeElement(KnownTypesCache knownTypesCache, [NotNull] IPsiModule module)
 {
     using (CompilationContextCookie.GetExplicitUniversalContextIfNotSet())
     {
         var type = knownTypesCache.GetByClrTypeName(myTypeName, module);
         return(type.GetTypeElement());
     }
 }
 private static ITypeElement GetTypeElement(IClrTypeName typeName, KnownTypesCache knownTypesCache,
                                            IPsiModule module)
 {
     using (CompilationContextCookie.GetExplicitUniversalContextIfNotSet())
     {
         var type = knownTypesCache.GetByClrTypeName(typeName, module);
         return(type.GetTypeElement());
     }
 }