private void AnalyseLastText()
        {
            if (m_lastAnalysedText == m_lastText)
            {
                return;
            }
            string text    = m_lastText;
            var    dialect = m_editor.Connection.Dialect;
            var    strm    = dialect.GetAntlrTokenStream(new StringReader(text));
            var    anal    = new SqlEditorAnalyser(strm, dialect);

            if (strm == null)
            {
                return;
            }
            if (!anal.ParseInput())
            {
                return;
            }
            if (!anal.LoadCatalogs(m_conn))
            {
                return;
            }
            m_lastAnalysedText = text;
            m_anal             = anal;
        }
        public CodeCompletionProvider(Form parentForm, IDatabaseSource conn, SqlEditorAnalyser anal, ImageCache imgCache, char firstChar, TextAreaControl textArea, CodeCompletionSettings settings)
        {
            m_parentForm = parentForm;
            m_conn       = conn;
            m_anal       = anal;
            m_dialect    = m_conn.Dialect;
            m_imgCache   = imgCache;
            m_firstChar  = firstChar;
            m_settings   = settings;

            if (m_firstChar == '\0')
            {
                int    col  = textArea.Caret.Column;
                string line = textArea.Document.GetText(textArea.Document.GetLineSegment(textArea.Caret.Line));
                var    sb   = new StringBuilder();
                while (col >= 1 && (Char.IsLetterOrDigit(line[col - 1]) || line[col - 1] == '_'))
                {
                    sb.Insert(0, line[col - 1]);
                    col--;
                }
                if (sb.Length > 0)
                {
                    m_presel = sb.ToString();
                }
            }
        }
Example #3
0
        public static void Run(SqlEditorAnalyser anal, CodeEditor editor, CodeCompletionSettings settings)
        {
            var win = new InsertJoinForm(anal, settings);

            if (win.ShowDialogEx() == DialogResult.OK)
            {
                string text = win.GetSqlText();
                editor.InsertTextOnCursor(text);
                editor.ActiveTextAreaControl.Caret.Position = editor.Document.OffsetToPosition(editor.ActiveTextAreaControl.Caret.Offset + text.Length);
            }
        }
Example #4
0
 public InsertJoinForm(SqlEditorAnalyser anal, CodeCompletionSettings settings)
 {
     InitializeComponent();
     codeEditor1.Dialect = anal.Dialect;
     m_anal     = anal;
     m_settings = settings;
     foreach (var tbl in anal.UsedTables)
     {
         if (tbl.RealTable == null)
         {
             continue;
         }
         lbxExistingTable.Items.Add(tbl);
     }
     if (lbxExistingTable.Items.Count > 0)
     {
         lbxExistingTable.SelectedIndex = 0;
     }
 }