Example #1
0
            public void AddIfMissing(
                string displayText,
                string suffix,
                string description,
                RegexNode parentOpt,
                int?positionOffset   = null,
                string insertionText = null
                )
            {
                var replacementStart = parentOpt != null?parentOpt.GetSpan().Start : Position;

                var replacementSpan = TextSpan.FromBounds(replacementStart, Position);
                var newPosition     = replacementStart + positionOffset;

                insertionText ??= displayText;
                var escapedInsertionText = _language.EscapeText(insertionText, StringToken);

                if (escapedInsertionText != insertionText)
                {
                    newPosition += escapedInsertionText.Length - insertionText.Length;
                }

                AddIfMissing(
                    new RegexItem(
                        displayText,
                        suffix,
                        description,
                        CompletionChange.Create(
                            new TextChange(replacementSpan, escapedInsertionText),
                            newPosition
                            )
                        )
                    );
            }