Example #1
0
        public Type LookupType(string fullName)
        {
            var split = fullName.Split(new char[] { '.', ':' }, StringSplitOptions.RemoveEmptyEntries);

            if (split.Length == 0)
            {
                return(null);
            }
            else if (split.Length == 1)
            {
                return(AllTypes.FirstOrDefault(t => t.Namespace == BasicTypes.GlobalNamespace && t.Name == fullName));
            }
            else
            {
                var typeName = split.Last();
                var ns       = LookupNamespace(split.Take(split.Length - 1).ToArray());

                if (ns == null)
                {
                    return(null);
                }
                else
                {
                    return(AllTypes.FirstOrDefault(t => t.Namespace == ns && t.Name == typeName));
                }
            }
        }
Example #2
0
        public CodeType GetCodeType(string name, FileDiagnostics diagnostics, DocRange range)
        {
            var type = AllTypes.FirstOrDefault(type => type.Name == name);

            if (range != null && type == null)
            {
                diagnostics.Error(string.Format("The type {0} does not exist.", name), range);
            }

            return(type);
        }
Example #3
0
        /// <summary>
        /// Find an existing AST type equivalent to the given system type.
        /// If AST type names are modified, only basic types will continue to successfully resolve.
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public Type LookupType(System.Type type)
        {
            type = U.Deref(type);

            var ret = BasicTypes.Of(type);

            if (ret != null)
            {
                return(ret);
            }

            var ns = LookupNamespace(type.Namespace);

            if (ns != null)
            {
                ret = AllTypes.FirstOrDefault(t => t.Namespace == ns && t.Name == type.Name);
            }

            return(null);
        }
Example #4
0
 public T GetCodeType <T>() where T : CodeType => (T)AllTypes.FirstOrDefault(type => type.GetType() == typeof(T));
Example #5
0
 public CodeType GetCodeType(string name) => AllTypes.FirstOrDefault(type => type.Name == name);