public void DateTimeVerifyPart_ShouldCreateDateTiimePart() { var dataListVerifyPart = IntellisenseFactory.CreateDateTimePart("2008", "Year"); Assert.IsNotNull(dataListVerifyPart); }
public IList <IntellisenseProviderResult> GetIntellisenseResults(IntellisenseProviderContext context) { if (context == null) { return(new List <IntellisenseProviderResult>()); } if (IsDisposed) { throw new ObjectDisposedException("DefaultIntellisenseProvider"); } if (!Equals(TextBox, context.TextBox)) { TextBox = context.TextBox as IntellisenseTextBox; } IList <IIntellisenseResult> results; var input = context.InputText ?? string.Empty; var caretPosition = context.CaretPosition; if (caretPosition > input.Length || caretPosition < 0) { return(new List <IntellisenseProviderResult>()); } enIntellisensePartType filterType = context.FilterType; enIntellisensePartType altfilterType = context.FilterType; IntellisenseDesiredResultSet desiredResultSet = context.DesiredResultSet; string searchText = context.FindTextToSearch(); string recordsetIndex = string.Empty; string recordserName = string.Empty; var region = input.RegionInPostion(caretPosition); var regionName = region.Name; if (DataListUtil.IsValueRecordset(regionName)) { recordsetIndex = DataListUtil.ExtractIndexRegionFromRecordset(regionName); recordserName = DataListUtil.ExtractRecordsetNameFromValue(regionName); if (!string.IsNullOrEmpty(recordsetIndex) && DataListUtil.IsValueRecordsetWithFields(searchText)) { altfilterType = enIntellisensePartType.RecordsetFields; } } if (input.Equals(DataListUtil.OpeningSquareBrackets)) { searchText = context.InputText; } else { searchText = searchText.StartsWith(DataListUtil.OpeningSquareBrackets) || string.IsNullOrEmpty(searchText) ? searchText : DataListUtil.OpeningSquareBrackets + searchText; } switch (desiredResultSet) { case IntellisenseDesiredResultSet.EntireSet: results = GetIntellisenseResultsImpl(DataListUtil.OpeningSquareBrackets, filterType); break; default: { results = GetIntellisenseResultsImpl(searchText, filterType); if (results == null || results.Count == 0 && HandlesResultInsertion) { results = new List <IIntellisenseResult>(); string inputText = input; var regionInPostion = inputText.RegionInPostion(caretPosition); inputText = !string.IsNullOrEmpty(regionInPostion.Name) ? regionInPostion.Name : inputText; var getErrors = GetIntellisenseResultsImpl(inputText, filterType) .Where(i => i.ErrorCode != enIntellisenseErrorCode.None) .ToList(); getErrors.ForEach(results.Add); } break; } } if (altfilterType == enIntellisensePartType.RecordsetFields) { var filteredRecordsetFields = results.Where(r => r.Option.Recordset.Equals(recordserName) || r.Option.IsScalar); if (!string.IsNullOrEmpty(recordsetIndex)) { results = filteredRecordsetFields.ToList().Where(r => !r.Option.HasRecordsetIndex || r.Option.IsScalar).ToList(); } } IList <IntellisenseProviderResult> trueResults = new List <IntellisenseProviderResult>(); string[] openParts = Regex.Split(input, @"\[\["); string[] closeParts = Regex.Split(input, @"\]\]"); if (openParts.Length != closeParts.Length) { if (results != null) { results.Add(IntellisenseFactory.CreateCalculateIntellisenseResult(2, 2, "Invalid Expression", "", StringResources.IntellisenseErrorMisMacthingBrackets)); } } if (results != null) { foreach (IIntellisenseResult currentResult in results) { if (currentResult.ErrorCode != enIntellisenseErrorCode.None) { if (currentResult.Type == enIntellisenseResultType.Error && currentResult.IsClosedRegion) { var displayValue = currentResult.Option == null ? string.Empty : currentResult.Option.DisplayValue; trueResults.Add(new IntellisenseProviderResult(this, displayValue, currentResult.Message, currentResult.Message, true)); } } if (currentResult.Type == enIntellisenseResultType.Selectable) { var displayValue = currentResult.Option == null ? string.Empty : currentResult.Option.DisplayValue; var description = currentResult.Option == null ? string.Empty : currentResult.Option.Description; trueResults.Add(new IntellisenseProviderResult(this, displayValue, description, description, false)); } } } return(trueResults); }
public DateTimeIntellisenseProvider() { Optional = false; IntellisenseProviderType = IntellisenseProviderType.NonDefault; IDateTimeParser dateTimeParser = DateTimeConverterFactory.CreateParser(); _intellisenseResults = dateTimeParser.DateTimeFormatParts.Select(p => { IIntellisenseResult intellisenseResult = IntellisenseFactory.CreateDateTimeResult(IntellisenseFactory.CreateDateTimePart(p.Value, p.Description)); return(intellisenseResult); }).OrderBy(p => p.Option.DisplayValue).ToList(); }
static void AddMissingWorkFlowRecordsetPart(List <IDataListVerifyPart> missingWorkflowParts, IRecordSetItemModel dataListItem, IRecordSetFieldItemModel child = null) { if (dataListItem.IsEditable) { missingWorkflowParts.Add(child != null ? IntellisenseFactory.CreateDataListValidationRecordsetPart(dataListItem.DisplayName, child.DisplayName, child.Description) : IntellisenseFactory.CreateDataListValidationRecordsetPart(dataListItem.DisplayName, string.Empty, dataListItem.Description)); } }
public void ProcessNonRecordsetFields(IParseTO payload, IList <IIntellisenseResult> result, IDev2DataLanguageIntellisensePart t1) { if (payload.Parent != null && payload.Parent.Payload.IndexOf(DataListUtil.RecordsetIndexOpeningBracket, StringComparison.Ordinal) >= 0) { var part = IntellisenseFactory.CreateDataListValidationScalarPart(t1.Name, t1.Description + " / Use row at this index"); result.Add(IntellisenseFactory.CreateSelectableResult(payload.StartIndex, payload.EndIndex, part, part.Description)); } else { IDataListVerifyPart part; part = t1.Name.Contains('(') && t1.Name.Contains(')') ? IntellisenseFactory.CreateDataListValidationRecordsetPart(string.Empty, t1.Name, true) : IntellisenseFactory.CreateDataListValidationScalarPart(t1.Name, t1.Description); result.Add(IntellisenseFactory.CreateSelectableResult(payload.StartIndex, payload.EndIndex, part, part.Description)); } }
public static void BuildDataPart(string dataPartFieldData, Dictionary <IDataListVerifyPart, string> unique) { Dev2DataLanguageParser dataLanguageParser = new Dev2DataLanguageParser(); dataPartFieldData = DataListUtil.StripBracketsFromValue(dataPartFieldData); IDataListVerifyPart verifyPart; string fullyFormattedStringValue; string[] fieldList = dataPartFieldData.Split('.'); if (fieldList.Count() > 1 && !String.IsNullOrEmpty(fieldList[0])) { // If it's a RecordSet Containing a field bool recAdded = false; foreach (var item in fieldList) { if (item.EndsWith(")") && item == fieldList[0]) { if (item.Contains("(")) { fullyFormattedStringValue = RemoveRecordSetBrace(item); var intellisenseResult = dataLanguageParser.ValidateName(fullyFormattedStringValue, ""); if (intellisenseResult == null) { recAdded = true; verifyPart = IntellisenseFactory.CreateDataListValidationRecordsetPart(fullyFormattedStringValue, String.Empty); AddDataVerifyPart(verifyPart, verifyPart.DisplayValue, unique); } } } else if (item == fieldList[1] && !(item.EndsWith(")") && item.Contains(")"))) { // If it's a field to a record set var intellisenseResult = dataLanguageParser.ValidateName(item, ""); if (intellisenseResult == null && recAdded) { verifyPart = IntellisenseFactory.CreateDataListValidationRecordsetPart( RemoveRecordSetBrace(fieldList.ElementAt(0)), item); AddDataVerifyPart(verifyPart, verifyPart.DisplayValue, unique); } } else { break; } } } else if (fieldList.Count() == 1 && !String.IsNullOrEmpty(fieldList[0])) { // If the workflow field is simply a scalar or a record set without a child if (dataPartFieldData.EndsWith(")") && dataPartFieldData == fieldList[0]) { if (dataPartFieldData.Contains("(")) { fullyFormattedStringValue = RemoveRecordSetBrace(fieldList[0]); var intellisenseResult = dataLanguageParser.ValidateName(fullyFormattedStringValue, ""); if (intellisenseResult == null) { verifyPart = IntellisenseFactory.CreateDataListValidationRecordsetPart(fullyFormattedStringValue, String.Empty); AddDataVerifyPart(verifyPart, verifyPart.DisplayValue, unique); } } } else { var intellisenseResult = dataLanguageParser.ValidateName(dataPartFieldData, ""); if (intellisenseResult == null) { verifyPart = IntellisenseFactory.CreateDataListValidationScalarPart(RemoveRecordSetBrace(dataPartFieldData)); AddDataVerifyPart(verifyPart, verifyPart.DisplayValue, unique); } } } }
internal string ProcessValidPartNameContainingFields(IParseTO payload, bool addCompleteParts, IList <IIntellisenseResult> result, string[] parts, string search, bool emptyOk, string partName, IDev2DataLanguageIntellisensePart recordsetPart, string display) { if (partName.IndexOf(DataListUtil.RecordsetIndexOpeningBracket, StringComparison.Ordinal) >= 0) { partName = partName.Substring(0, partName.IndexOf(DataListUtil.RecordsetIndexOpeningBracket, StringComparison.Ordinal)); } if (recordsetPart == null) { var part = IntellisenseFactory.CreateDataListValidationRecordsetPart(partName, parts[1], ""); result.Add(IntellisenseFactory.CreateErrorResult(payload.StartIndex, parts[0].Length - 1, part, DataListUtil.OpeningSquareBrackets + display + "]] does not exist in your variable list", enIntellisenseErrorCode.NeitherRecordsetNorFieldFound, !payload.HangingOpen)); } else { var processForRecordset = _parserHelper.ProcessFieldsForRecordSet(payload, addCompleteParts, result, parts, out search, out emptyOk, display, recordsetPart, partName); if (recordsetPart.Children != null && recordsetPart.Children.Count > 0 && processForRecordset) { return(search); } } if (result.Count == 0 && !emptyOk) { var part = IntellisenseFactory.CreateDataListValidationRecordsetPart(parts[0], search); result.Add(char.IsNumber(search[0]) ? IntellisenseFactory.CreateErrorResult(payload.StartIndex, parts[0].Length - 1, part, "Invalid Expression: Recordset Field [ " + search + " ] starts with a number", enIntellisenseErrorCode.SyntaxError, !payload.HangingOpen) : IntellisenseFactory.CreateErrorResult(parts[0].Length, payload.EndIndex, part, "Recordset Field [ " + search + " ] does not exist for [ " + parts[0] + " ]", enIntellisenseErrorCode.FieldNotFound, !payload.HangingOpen)); } return(search); }
static void FinalEvaluation(IParseTO payload, StringBuilder tmp, IList <IIntellisenseResult> result, IList <IDev2DataLanguageIntellisensePart> additionalParts, bool isRs) { var display = tmp.ToString().Replace("]", ""); IDataListVerifyPart part; var code = enIntellisenseErrorCode.RecordsetNotFound; if (!isRs) { code = display.IndexOf(' ') >= 0 ? enIntellisenseErrorCode.SyntaxError : enIntellisenseErrorCode.ScalarNotFound; part = IntellisenseFactory.CreateDataListValidationScalarPart(display); } else { var start = display.IndexOf(DataListUtil.RecordsetIndexOpeningBracket, StringComparison.Ordinal); display = display.Substring(0, start); display += "()"; part = IntellisenseFactory.CreateDataListValidationRecordsetPart(display, ""); } if (additionalParts == null) { result.Add(!display.Contains(' ') ? IntellisenseFactory.CreateErrorResult(payload.StartIndex, payload.EndIndex, part, " [[" + display + "]] does not exist in your variable list", code, !payload.HangingOpen) : IntellisenseFactory.CreateErrorResult(payload.StartIndex, payload.EndIndex, part, " [[" + display + "]] contains a space, this is an invalid character for a variable name", code, !payload.HangingOpen)); } else { if (!additionalParts.Select(a => a.Name).Contains(display)) { result.Add(!display.Contains(' ') ? IntellisenseFactory.CreateErrorResult(payload.StartIndex, payload.EndIndex, part, " [[" + display + "]] does not exist in your variable list", code, !payload.HangingOpen) : IntellisenseFactory.CreateErrorResult(payload.StartIndex, payload.EndIndex, part, " [[" + display + "]] contains a space, this is an invalid character for a variable name", code, !payload.HangingOpen)); } } }
/// <summary> /// Finds the missing workflow data regions. /// </summary> /// <param name="partsToVerify">The parts to verify.</param> /// <param name="excludeUnusedItems"></param> /// <returns></returns> public List <IDataListVerifyPart> MissingWorkflowItems(IList <IDataListVerifyPart> partsToVerify, bool excludeUnusedItems = false) { var missingWorkflowParts = new List <IDataListVerifyPart>(); if (DataListSingleton.ActiveDataList != null && DataListSingleton.ActiveDataList.DataList != null) { foreach (var dataListItem in DataListSingleton.ActiveDataList.DataList) { if (String.IsNullOrEmpty(dataListItem.Name)) { continue; } if ((dataListItem.Children.Count > 0)) { if (partsToVerify.Count(part => part.Recordset == dataListItem.Name) == 0) { //19.09.2012: massimo.guerrera - Added in the description to creating the part if (dataListItem.IsEditable) { // skip it if unused and exclude is on ;) if (excludeUnusedItems && !dataListItem.IsUsed) { continue; } missingWorkflowParts.Add( IntellisenseFactory.CreateDataListValidationRecordsetPart(dataListItem.Name, String.Empty, dataListItem.Description)); // ReSharper disable once LoopCanBeConvertedToQuery foreach (var child in dataListItem.Children) { if (!(String.IsNullOrEmpty(child.Name))) { //19.09.2012: massimo.guerrera - Added in the description to creating the part if (dataListItem.IsEditable) { missingWorkflowParts.Add( IntellisenseFactory.CreateDataListValidationRecordsetPart( dataListItem.Name, child.Name, child.Description)); } } } } } else { // ReSharper disable once LoopCanBeConvertedToQuery foreach (var child in dataListItem.Children) { if (partsToVerify.Count(part => part.Field == child.Name && part.Recordset == child.Parent.Name) == 0) { //19.09.2012: massimo.guerrera - Added in the description to creating the part if (child.IsEditable) { // skip it if unused and exclude is on ;) if (excludeUnusedItems && !dataListItem.IsUsed) { continue; } missingWorkflowParts.Add( IntellisenseFactory.CreateDataListValidationRecordsetPart( dataListItem.Name, child.Name, child.Description)); } } } } } else if (partsToVerify.Count(part => part.Field == dataListItem.Name) == 0) { if (dataListItem.IsEditable) { // skip it if unused and exclude is on ;) if (excludeUnusedItems && !dataListItem.IsUsed) { continue; } //19.09.2012: massimo.guerrera - Added in the description to creating the part missingWorkflowParts.Add( IntellisenseFactory.CreateDataListValidationScalarPart(dataListItem.Name, dataListItem.Description)); } } } } return(missingWorkflowParts); }