public override IntelisenseData GetIntelisenseData(IDbConnection connection, string currentSchemaName) { if (connection == null) { throw new ArgumentNullException("connection"); } // Load schemas var intellisenseData = new IntelisenseData(); intellisenseData.AllSchemas.Add(_defaultSchema); // Load tables var tables = GetTables(connection, currentSchemaName); _defaultSchema.Tables.Clear(); _defaultSchema.Tables.AddRange(tables); intellisenseData.AllObjects.AddRange(tables); // Load table columns foreach (var table in tables) { table.Columns.Clear(); table.Columns.AddRange(GetTableColumns(connection, currentSchemaName, table.Name)); intellisenseData.AllColumns.AddRange(table.Columns); } // Load views var views = GetViews(connection, currentSchemaName); _defaultSchema.Views.Clear(); _defaultSchema.Views.AddRange(views); intellisenseData.AllObjects.AddRange(views); // Load view columns foreach (var view in views) { view.Columns.Clear(); view.Columns.AddRange(GetViewColumns(connection, currentSchemaName, view.Name)); intellisenseData.AllColumns.AddRange(view.Columns); } // Set current schema intellisenseData.CurrentSchema = _defaultSchema; return(intellisenseData); }
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 ); }