Пример #1
0
        // ** private
        private void BuildCommentRangeList()
        {
            // clear old list
            _commentRanges.Clear();

            // scan the string and save comments
            for (int index = 0; index < _text.Length; index++)
            {
                if (_text[index] == '/' && index < _text.Length - 1)
                {
                    if (_text[index + 1] == '*')
                    {
                        // comments /* xxxx */
                        int end = _text.IndexOf("*/", index + 2);
                        if (end > -1)
                        {
                            CharRange range = new CharRange(_text.Substring(index, end - index + 1), index, false);
                            _commentRanges.Add(range);
                            index = end + 1;
                        }
                    }
                    else if (_text[index + 1] == '/')
                    {
                        // comments // xxxx \n
                        int end = _text.IndexOf("\n", index + 2);
                        if (end > -1)
                        {
                            CharRange range = new CharRange(_text.Substring(index, end - index + 1), index, false);
                            _commentRanges.Add(range);
                            index = end + 1;
                        }
                    }
                }

                // skip over strings in case they contain comment chars: "xxx // foo /* yyy */"
                if (_text[index] == '\"' && IsRealQuote(index))
                {
                    int end = FindNextQuote(index);
                    if (end > -1)
                    {
                        index = end;
                    }
                }
            }
        }