/// <summary> /// Adds suggestions that start with the MatchingString from the given type. /// </summary> internal static void AddTopLevelSuggestions(IntellisenseData.IntellisenseData intellisenseData, DType type, string prefix = "") { Contracts.AssertValue(intellisenseData); Contracts.Assert(type.IsValid); Contracts.Assert(prefix.Length == 0 || (TexlLexer.PunctuatorBang + TexlLexer.PunctuatorDot).IndexOf(prefix[prefix.Length - 1]) >= 0); foreach (TypedName tName in type.GetAllNames(DPath.Root)) { if (!intellisenseData.TryAddCustomColumnTypeSuggestions(tName.Type)) { var usedName = tName.Name; string maybeDisplayName; if (DType.TryGetDisplayNameForColumn(type, usedName, out maybeDisplayName)) { usedName = new DName(maybeDisplayName); } AddSuggestion(intellisenseData, prefix + TexlLexer.EscapeName(usedName.Value), SuggestionKind.Global, SuggestionIconKind.Other, tName.Type, requiresSuggestionEscaping: false); } } }
// Get the correct derived type internal static FormulaType Build(DType type) { switch (type.Kind) { case DKind.ObjNull: return(Blank); case DKind.Record: return(new RecordType(type)); case DKind.Table: return(new TableType(type)); case DKind.Number: return(Number); case DKind.String: return(String); case DKind.Boolean: return(Boolean); case DKind.Currency: return(Number); // TODO: validate case DKind.Time: return(Time); case DKind.Date: return(Date); case DKind.DateTime: return(DateTime); case DKind.DateTimeNoTimeZone: return(DateTimeNoTimeZone); case DKind.OptionSetValue: var isBoolean = type.OptionSetInfo?.IsBooleanValued; return(isBoolean.HasValue && isBoolean.Value ? Boolean : OptionSetValue); // This isn't quite right, but once we're in the IR, an option set acts more like a record with optionsetvalue fields. case DKind.OptionSet: return(new RecordType(DType.CreateRecord(type.GetAllNames(DPath.Root)))); default: throw new NotImplementedException($"Not implemented type: {type}"); } }