private static IntellisenseType GetType(CodeClass rootElement, CodeTypeRef codeTypeRef, HashSet <string> traversedTypes, HashSet <string> references)
        {
            var isArray      = codeTypeRef.TypeKind == vsCMTypeRef.vsCMTypeRefArray;
            var isCollection = codeTypeRef.AsString.StartsWith("System.Collections", StringComparison.Ordinal);
            var isDictionary = false;

            var effectiveTypeRef = codeTypeRef;

            if (isArray && codeTypeRef.ElementType != null)
            {
                effectiveTypeRef = effectiveTypeRef.ElementType;
            }
            else if (isCollection)
            {
                effectiveTypeRef = TryToGuessGenericArgument(rootElement, effectiveTypeRef);
            }

            if (isCollection)
            {
                isDictionary = codeTypeRef.AsString.StartsWith("System.Collections.Generic.Dictionary", StringComparison.Ordinal);
            }

            var codeClass   = effectiveTypeRef.CodeType as CodeClass2;
            var codeEnum    = effectiveTypeRef.CodeType as CodeEnum;
            var isPrimitive = IsPrimitive(effectiveTypeRef);

            var result = new IntellisenseType
            {
                IsArray                 = !isDictionary && (isArray || isCollection),
                IsDictionary            = isDictionary,
                CodeName                = effectiveTypeRef.AsString,
                ClientSideReferenceName =
                    effectiveTypeRef.TypeKind == vsCMTypeRef.vsCMTypeRefCodeType &&
                    effectiveTypeRef.CodeType.InfoLocation == vsCMInfoLocation.vsCMInfoLocationProject
                    ?
                    (codeClass != null && HasIntellisense(codeClass.ProjectItem, Ext.TypeScript, references) ? (GetNamespace(codeClass) + "." + GetClassName(codeClass)) : null) ??
                    (codeEnum != null && HasIntellisense(codeEnum.ProjectItem, Ext.TypeScript, references) ? (GetNamespace(codeEnum) + "." + codeEnum.Name) : null)
                    : null
            };

            if (!isPrimitive && codeClass != null && !traversedTypes.Contains(effectiveTypeRef.CodeType.FullName) && !isCollection)
            {
                traversedTypes.Add(effectiveTypeRef.CodeType.FullName);
                result.Shape = GetProperties(effectiveTypeRef.CodeType.Members, traversedTypes, references).ToList();
                traversedTypes.Remove(effectiveTypeRef.CodeType.FullName);
            }

            return(result);
        }
 public IntellisenseProperty(IntellisenseType type, string propertyName)
 {
     Type = type;
     Name = propertyName;
 }
        private static IntellisenseType GetType(CodeClass rootElement, CodeTypeRef codeTypeRef, HashSet<string> traversedTypes, HashSet<string> references)
        {
            var isArray = codeTypeRef.TypeKind == vsCMTypeRef.vsCMTypeRefArray;
            var isCollection = codeTypeRef.AsString.StartsWith("System.Collections", StringComparison.Ordinal);

            var effectiveTypeRef = codeTypeRef;
            if (isArray && codeTypeRef.ElementType != null) effectiveTypeRef = effectiveTypeRef.ElementType;
            else if (isCollection) effectiveTypeRef = TryToGuessGenericArgument(rootElement, effectiveTypeRef);

            var codeClass = effectiveTypeRef.CodeType as CodeClass2;
            var codeEnum = effectiveTypeRef.CodeType as CodeEnum;
            var isPrimitive = IsPrimitive(effectiveTypeRef);

            var result = new IntellisenseType
            {
                IsArray = isArray || isCollection,
                CodeName = effectiveTypeRef.AsString,
                ClientSideReferenceName =
                    effectiveTypeRef.TypeKind == vsCMTypeRef.vsCMTypeRefCodeType &&
                    effectiveTypeRef.CodeType.InfoLocation == vsCMInfoLocation.vsCMInfoLocationProject
                    ?
                        (codeClass != null && HasIntellisense(codeClass.ProjectItem, Ext.TypeScript, references) ? (GetNamespace(codeClass) + "." + codeClass.Name) : null) ??
                        (codeEnum != null && HasIntellisense(codeEnum.ProjectItem, Ext.TypeScript, references) ? (GetNamespace(codeEnum) + "." + codeEnum.Name) : null)
                    : null
            };

            if (!isPrimitive && codeClass != null && !traversedTypes.Contains(effectiveTypeRef.CodeType.FullName) && !isCollection)
            {
                traversedTypes.Add(effectiveTypeRef.CodeType.FullName);
                result.Shape = GetProperties(effectiveTypeRef.CodeType.Members, traversedTypes, references).ToList();
                traversedTypes.Remove(effectiveTypeRef.CodeType.FullName);
            }

            return result;
        }
Example #4
0
 public IntellisenseProperty(IntellisenseType type, string propertyName)
 {
     Type = type;
     Name = propertyName;
 }