private bool TypeOfFirst(Group full, out Type theType, out string name) { name = full.Value.Split('.').First(); //Map to primative if needed var primitive = RexUtils.MapToPrimitive(name); if (primitive != null) { theType = RexUtils.PrimitiveToType(primitive); return(true); } if (RexHelper.Variables.ContainsKey(name)) { if (RexHelper.Variables[name].VarValue != null) { theType = RexHelper.Variables[name].VarType; return(true); } else { theType = null; return(false); } } var tmpName = name; theType = RexUtils.AllVisibleTypes.FirstOrDefault(t => t.Name == tmpName); return(theType != null); }
private IEnumerable <CodeCompletion> SearchWithoutType(Group search, int offset) { var lowerSearch = search.Value.ToLower(); var variables = from i in RexHelper.Variables let lowerItem = i.Key.ToLower() where lowerItem.Contains(lowerSearch) select new { SearchName = lowerItem, IsNested = false, ReplacementString = i.Key, Details = new MemberDetails(i.Value.VarValue, RexUtils.GetCSharpRepresentation(i.Value.VarType, false).Concat(new[] { Syntax.Space, Syntax.Name(i.Key), Syntax.Space, Syntax.EqualsOp, Syntax.Space }).Concat(RexReflectionUtils.GetSyntaxForValue(i.Value.VarValue))), isInScope = true }; var types = from type in RexUtils.AllVisibleTypes let lowerItem = type.Name.ToLower() where lowerItem.Contains(lowerSearch) && !RexReflectionUtils.IsCompilerGenerated(type) let isInScope = RexCompileEngine.Instance.NamespaceInfos.Any(i => i.Name == type.Namespace && i.Selected) select new { SearchName = lowerItem, type.IsNested, ReplacementString = GetNestedName(type), Details = RexUtils.GetCSharpRepresentation(type), isInScope }; return(from i in types.Concat(variables) orderby i.SearchName.IndexOf(lowerSearch), i.SearchName.Length, i.isInScope, i.IsNested select new CodeCompletion { Details = i.Details, Start = offset, End = offset + search.Length - 1, ReplaceString = i.ReplacementString, //.Details.Name.String, Search = search.Value, IsInScope = i.isInScope }); }