예제 #1
0
        public void AugmentCompletionSession(ICompletionSession session, IList<CompletionSet> completionSets)
        {
            if (_disposed)
                throw new ObjectDisposedException("LuaCompletionSource");
         
            ITextSnapshot snapshot = _buffer.CurrentSnapshot;
            var triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
                return;

            var line = triggerPoint.GetContainingLine();
            SnapshotPoint start = triggerPoint;

            var word = start;
            word -= 1;
            var ch = word.GetChar();

            List<Completion> completions = new List<Completion>();

            while (word > line.Start && (word - 1).GetChar().IsWordOrDot())
            {
                word -= 1;
            }

            if (ch == '.' || ch == ':')
            {
                String w = snapshot.GetText(word.Position, start - 1 - word);
                if (!FillTable(w, ch, completions)) return;
            }
            else
            {
                char front = word > line.Start ? (word - 1).GetChar() : char.MinValue;
                if (front == '.' || front == ':')
                {
                    int loc = (word - 1).Position;
                    while (loc > 0 && snapshot[loc - 1].IsWordOrDot()) loc--;
                    int len = word - 1 - loc;
                    if (len <= 0) return;
                    string w = snapshot.GetText(loc, len);
                    if (!FillTable(w, front, completions)) return;
                }
                else
                {
                    String w = snapshot.GetText(word.Position, start - word);
                    if (!FillWord(w, completions)) return;
                }
            }

            if (ch != '.' && ch != ':')
            {
                start = word;
            }

            var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);
            var cs = new LuaCompletionSet("All", "All", applicableTo, completions, null);
            completionSets.Add(cs);
        }
예제 #2
0
        public void AugmentCompletionSession(ICompletionSession session, IList <CompletionSet> completionSets)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException("LuaCompletionSource");
            }

            ITextSnapshot snapshot     = _buffer.CurrentSnapshot;
            var           triggerPoint = (SnapshotPoint)session.GetTriggerPoint(snapshot);

            if (triggerPoint == null)
            {
                return;
            }

            var           line  = triggerPoint.GetContainingLine();
            SnapshotPoint start = triggerPoint;

            var word = start;

            word -= 1;
            var ch = word.GetChar();

            List <Completion> completions = new List <Completion>();

            while (word > line.Start && (word - 1).GetChar().IsWordOrDot())
            {
                word -= 1;
            }

            if (ch == '.' || ch == ':')
            {
                String w = snapshot.GetText(word.Position, start - 1 - word);
                if (!FillTable(w, ch, completions))
                {
                    return;
                }
            }
            else
            {
                char front = word > line.Start ? (word - 1).GetChar() : char.MinValue;
                if (front == '.' || front == ':')
                {
                    int loc = (word - 1).Position;
                    while (loc > 0 && snapshot[loc - 1].IsWordOrDot())
                    {
                        loc--;
                    }
                    int len = word - 1 - loc;
                    if (len <= 0)
                    {
                        return;
                    }
                    string w = snapshot.GetText(loc, len);
                    if (!FillTable(w, front, completions))
                    {
                        return;
                    }
                }
                else
                {
                    String w = snapshot.GetText(word.Position, start - word);
                    if (!FillWord(w, completions))
                    {
                        return;
                    }
                }
            }

            if (ch != '.' && ch != ':')
            {
                start = word;
            }

            var applicableTo = snapshot.CreateTrackingSpan(new SnapshotSpan(start, triggerPoint), SpanTrackingMode.EdgeInclusive);
            var cs           = new LuaCompletionSet("All", "All", applicableTo, completions, null);

            completionSets.Add(cs);
        }