Пример #1
0
        private void HandleAfterStringLiteral(SnapshotPoint triggerPt, string fileName)
        {
            var tracker = TextBufferStateTracker.GetTrackerForTextBuffer(_textView.TextBuffer);
            var stmt    = State.ToStatement(tracker.GetStateForPosition(triggerPt, fileName, _appSettings));

            StatementLayout.GetCompletionsAfterToken(stmt, this);
        }
Пример #2
0
        private void HandleAfterWord(string word, int curPos, ITextSnapshot snapshot, string fileName)
        {
            var tracker = TextBufferStateTracker.GetTrackerForTextBuffer(_textView.TextBuffer);
            var stmt    = State.ToStatement(tracker.GetStateForPosition(curPos, snapshot, fileName, _appSettings));

            StatementLayout.GetCompletionsAfterToken(stmt, this);
        }
Пример #3
0
        private void GetWordCompletions(SnapshotPoint triggerPt, SnapshotPoint wordStartPt, string fileName)
        {
            var fileStore = CodeModel.FileStore.GetOrCreateForTextBuffer(_textView.TextBuffer);

            if (fileStore == null)
            {
                return;
            }

            var model    = fileStore.GetMostRecentModel(_appSettings, fileName, triggerPt.Snapshot, "Auto-completion get word completions");
            var modelPos = model.AdjustPosition(triggerPt);

            var tokens = model.FindTokens(modelPos).ToArray();

            foreach (var def in model.DefinitionProvider.GlobalsFromAnywhere)
            {
                CreateCompletion(def);
            }

            foreach (var def in model.DefinitionProvider.GetLocal(modelPos))
            {
                CreateCompletion(def);
            }

            // Dictionary definitions are already provided by the DefinitionProvider.

            foreach (var d in Constants.DataTypeKeywords)
            {
                CreateCompletion(d, ProbeCompletionType.DataType, null);
            }

            // Don't show functions when on the root.
            if (tokens.Any(t => !t.IsOnRoot))
            {
                var ffApp = ProbeToolsPackage.Instance.FunctionFileScanner.CurrentApp;
                foreach (var f in ffApp.GlobalDefinitions)
                {
                    CreateCompletion(f);
                }
            }

            var bottomToken = tokens.LastOrDefault();

            if (bottomToken != null)
            {
                if (bottomToken.Scope.BreakOwner != null)
                {
                    CreateCompletion("break", ProbeCompletionType.Keyword, null);
                }
                if (bottomToken.Scope.ContinueOwner != null)
                {
                    CreateCompletion("continue", ProbeCompletionType.Keyword, null);
                }
            }

            // Global keywords
            foreach (var k in Constants.GlobalKeywords)
            {
                CreateCompletion(k, ProbeCompletionType.Keyword, null);
            }

            var tracker = Classifier.TextBufferStateTracker.GetTrackerForTextBuffer(_textView.TextBuffer);
            var state   = Classifier.State.ToStatement(tracker.GetStateForPosition(wordStartPt, fileName, _appSettings));

            foreach (var keyword in StatementLayout.GetNextPossibleKeywords(state))
            {
                CreateCompletion(keyword, ProbeCompletionType.Keyword, null);
            }
        }