public void MatchFieldVariables(IParseTO payload, IList <IDev2DataLanguageIntellisensePart> refParts, bool addCompleteParts, IList <IIntellisenseResult> result, string[] parts, bool isRs, string rawSearch, string search, bool emptyOk)
            {
                var tmpTo = new ParseTO {
                    Payload = parts[0], StartIndex = 0, EndIndex = parts[0].Length - 1
                };

                var isRecName = isRs && rawSearch.Contains(DataListUtil.RecordsetIndexOpeningBracket) && rawSearch.EndsWith(DataListUtil.RecordsetIndexClosingBracket);

                const string DisplayString = "Recordset";

                if ((!isRecName || parts[1] == string.Empty) && payload.Child == null)
                {
                    if (_parserHelper.ValidateName(rawSearch, DisplayString, result, out IList <IIntellisenseResult> intellisenseResults))
                    {
                        return;
                    }
                }
                else
                {
                    if (_parserHelper.ValidateName(search, DisplayString, result, out IList <IIntellisenseResult> intellisenseResults))
                    {
                        return;
                    }
                }

                try
                {
                    _parserHelper.IsValidIndex(tmpTo);
                }
                catch (Dev2DataLanguageParseError e)
                {
                    result.Add(_parserHelper.AddErrorToResults(isRs, parts[0], e, !payload.HangingOpen));
                }

                var recordsetPart = refParts.FirstOrDefault(c => c.Name.ToLower() == search && c.Children != null);

                var display  = parts[0];
                var partName = parts[0];
                var start    = display.IndexOf(DataListUtil.RecordsetIndexOpeningBracket, StringComparison.Ordinal);

                if (start >= 0 && recordsetPart == null)
                {
                    display  = display.Substring(0, start);
                    display += "()";
                }

                if (partName.IndexOf(' ') < 0)
                {
                    search = ProcessValidPartNameContainingFields(payload, addCompleteParts, result, parts, search, emptyOk, partName, recordsetPart, display);
                }
                else
                {
                    var part = IntellisenseFactory.CreateDataListValidationRecordsetPart(parts[0], "." + parts[1], true);
                    result.Add(IntellisenseFactory.CreateErrorResult(payload.StartIndex, payload.EndIndex, part, " [[" + display + "]] contains a space, this is an invalid character for a variable name", enIntellisenseErrorCode.SyntaxError, !payload.HangingOpen));
                }
            }
            public IList <IIntellisenseResult> TryExtractActualIntellisenseOptions(IParseTO payload, IEnumerable <IDev2DataLanguageIntellisensePart> refParts, bool addCompleteParts)
            {
                var tmp = new StringBuilder(payload.Payload);
                IList <IIntellisenseResult> result = new List <IIntellisenseResult>();

                if (payload != null)
                {
                    var parts  = tmp.ToString().Split('.');
                    var search = parts[0].ToLower();
                    var isRs   = search.Contains(DataListUtil.RecordsetIndexOpeningBracket);

                    if (search.Contains(DataListUtil.RecordsetIndexOpeningBracket))
                    {
                        isRs = true;
                        var pos = search.IndexOf(DataListUtil.RecordsetIndexOpeningBracket, StringComparison.Ordinal);
                        search = search.Substring(0, search.Length - (search.Length - pos));
                    }

                    try
                    {
                        ExtractActualIntellisenseOptions(payload, refParts, addCompleteParts, result, parts, search);
                    }
                    catch (Dev2DataLanguageParseError e)
                    {
                        result.Add(_parserHelper.AddErrorToResults(isRs, parts[0], e, !payload.HangingOpen));
                    }
                }

                IList <IIntellisenseResult> realResults = new List <IIntellisenseResult>();

                result.ToList()
                .ForEach(r =>
                {
                    var addToFinal = true;

                    realResults
                    .ToList()
                    .ForEach(rr =>
                    {
                        if (rr.Option.DisplayValue == r.Option.DisplayValue)
                        {
                            addToFinal = false;
                        }
                    });

                    if (addToFinal)
                    {
                        realResults.Add(r);
                    }
                });

                return(result);
            }
Ejemplo n.º 3
0
 IIntellisenseResult AddErrorToResults(bool isRs, string part, Dev2DataLanguageParseError e, bool isOpen) => _parserHelper.AddErrorToResults(isRs, part, e, isOpen);