Example #1
0
 internal static string MakeDescription(AnalysisValue type, string typeName, IAnalysisSet indexTypes)
 {
     if (type.Push())
     {
         try {
             if (indexTypes == null || indexTypes.Count == 0)
             {
                 return(typeName);
             }
             else if (indexTypes.Count == 1)
             {
                 return(typeName + " of " + indexTypes.First().ShortDescription);
             }
             else if (indexTypes.Count < 4)
             {
                 return(typeName + " of {" + string.Join(", ", indexTypes.Select(ns => ns.ShortDescription)) + "}");
             }
             else
             {
                 return(typeName + " of multiple types");
             }
         } finally {
             type.Pop();
         }
     }
     return(typeName);
 }
        public override IAnalysisSet GetIndex(Node node, AnalysisUnit unit, IAnalysisSet index)
        {
            var indexType = index.Select(av => av.PythonType).Where(pt => pt != null);

            if (indexType != null && indexType.Any())
            {
                return(unit.State.GetAnalysisSetFromObjects(indexType.SelectMany(_dict.GetIndex)));
            }
            return(ValueType);
        }
Example #3
0
        private object GenerateTypeName(IAnalysisSet name, bool isRef)
        {
            if (name.Count == 0)
            {
                return(null);
            }
            else if (name.Count == 1)
            {
                return(GenerateTypeName(name.First(), isRef));
            }

            return(name.Select(ns => GenerateTypeName(ns, isRef)).Distinct().ToList <object>());
        }
Example #4
0
 public static IEnumerable <string> GetShortDescriptions(this IAnalysisSet self)
 {
     return(self
            .Select(v => {
         if (v.Push())
         {
             try {
                 return v.ShortDescription;
             } finally {
                 v.Pop();
             }
         }
         return "...";
     })
            .Where(d => !string.IsNullOrEmpty(d))
            .OrderBy(d => d, DotsLastStringComparer.Instance)
            .Distinct());
 }
 protected string MakeDescription(string typeName)
 {
     if (_indexTypes == null || _indexTypes.Count == 0)
     {
         return(typeName);
     }
     else if (_indexTypes.Count == 1)
     {
         return(typeName + " of " + GetInstanceShortDescription(_indexTypes.First()));
     }
     else if (_indexTypes.Count < 4)
     {
         return(typeName + " of {" + string.Join(", ", _indexTypes.Select(GetInstanceShortDescription)) + "}");
     }
     else
     {
         return(typeName + " of multiple types");
     }
 }
Example #6
0
 /// <summary>
 /// Returns a sequence of all recognized string values in the set.
 /// </summary>
 internal static IEnumerable <string> GetConstantValueAsString(this IAnalysisSet values)
 {
     return(values
            .Select(v => v.GetConstantValueAsString())
            .Where(s => !string.IsNullOrEmpty(s)));
 }
 public override IAnalysisSet Await(Node node, AnalysisUnit unit)
 {
     return(AnalysisSet.UnionAll(_protocols.Select(p => p.Await(node, unit))));
 }
Example #8
0
 internal static string MakeDescription(AnalysisValue type, string typeName, IAnalysisSet indexTypes) {
     if (type.Push()) {
         try {
             if (indexTypes == null || indexTypes.Count == 0) {
                 return typeName;
             } else if (indexTypes.Count == 1) {
                 return typeName + " of " + indexTypes.First().ShortDescription;
             } else if (indexTypes.Count < 4) {
                 return typeName + " of {" + string.Join(", ", indexTypes.Select(ns => ns.ShortDescription)) + "}";
             } else {
                 return typeName + " of multiple types";
             }
         } finally {
             type.Pop();
         }
     }
     return typeName;
 }