Esempio n. 1
0
        public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth, int startOffset, int endOffset)
        {
            ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar);
            if (completionData == null || completionData.Length == 0)
            {
                return(null);
            }
            var codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, completionData, parent, control, showDeclarationWindow, fixedListViewWidth, startOffset, endOffset);

            codeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\0';
            codeCompletionWindow.ShowCompletionWindow();
            return(codeCompletionWindow);
        }
Esempio n. 2
0
        private void ShowIntellisense(char value)
        {
            _intellisenseData = IntellisenseManager.Instance.GetIntellisenseData(DatabaseConnection);
            if (_intellisenseData == null)
            {
                _log.Debug("Intellisense data is still generating.");
                return;
            }

            var startOffset = Math.Min(_sqlEditor.ActiveTextAreaControl.Caret.Offset, _sqlEditor.ActiveTextAreaControl.Document.TextLength - 1);
            var endOffset   = _sqlEditor.ActiveTextAreaControl.Caret.Offset;
            var text        = _sqlEditor.ActiveTextAreaControl.Document.GetText(startOffset, 1);

            //Debug.WriteLine(text);
            while (startOffset > 0 && !text.IsNullEmptyOrWhitespace() && DatabaseConnection.DatabaseServer.ValidIdentifierRegex.IsMatch(text))
            {
                --startOffset;
                text = _sqlEditor.ActiveTextAreaControl.Document.GetText(startOffset, 1);
            }
            //Debug.WriteLine("StartOffset (before code completion window): {0}.", startOffset);
            if (startOffset == _sqlEditor.ActiveTextAreaControl.Document.TextLength - 1)
            {
                ++startOffset;
            }
            //++startOffset;

            ICompletionDataProvider completionDataProvider = new CompleteWordCompletionProvider(_img16,
                                                                                                _intellisenseData, 18, 19, 19, 20);

            CodeCompletionWindow.ShowCompletionWindow(
                ParentForm,             // The parent window for the completion window
                _sqlEditor,             // The text editor to show the window for
                string.Empty,           // Filename - will be passed back to the provider
                completionDataProvider, // Provider to get the list of possible completions
                value,                  // Key pressed - will be passed to the provider
                true,
                false,
                startOffset,
                endOffset
                );
        }