Example #1
0
        public bool CanAddPairCharacter(string tokenValue, char character)
        {
            switch (character)
            {
            case SingleQuoteCharacter:
                bool isQuotedString;
                char?quoteInitializer;
                var  trimToIndex      = OracleExtensions.GetTrimIndex(tokenValue, out isQuotedString, out quoteInitializer) - (isQuotedString ? 2 : 1);
                var  tokenValueLength = tokenValue.Length;
                if (trimToIndex >= tokenValueLength)
                {
                    trimToIndex = tokenValueLength - 1;
                }

                return(tokenValue[0] != SingleQuoteCharacter && (tokenValue[trimToIndex] != SingleQuoteCharacter));

            case '"':
                return(tokenValue[0] != '"');

            default:
                return(true);
            }
        }
        private static IEnumerable <SourcePosition> FindCorrespondingStringQuotation(StatementGrammarNode terminal, int cursorPosition)
        {
            if (!String.Equals(terminal.Id, Terminals.StringLiteral))
            {
                yield break;
            }

            var value     = terminal.Token.Value;
            var trimIndex = OracleExtensions.GetTrimIndex(value, out var isQuotedString, out var quoteInitializer);

            if (!isQuotedString)
            {
                yield break;
            }

            var startPosition = terminal.SourcePosition.IndexStart;

            yield return(SourcePosition.Create(startPosition, startPosition + trimIndex - 1));

            if (value[value.Length - 1] == '\'')
            {
                yield return(SourcePosition.Create(startPosition + value.Length - 2, startPosition + value.Length - 1));
            }
        }