bool TextArea_KeyEventHandler(char ch)
        {
            if (provider != null)
            {
                if (codeCompletionWindow != null)
                {
                    if (char.IsLetterOrDigit(ch) || ch == '_' || ch == '$')
                    {
                        if (codeCompletionWindow.ProcessKeyEvent(ch))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        codeCompletionWindow.Close();
                    }
                }

                if (codeCompletionWindow == null && char.IsLetterOrDigit(ch) || ch == '_')
                {
                    codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(mainForm, editor, editor.FileName, provider, ch);

                    if (codeCompletionWindow != null)
                    {
                        codeCompletionWindow.FormClosed += new System.Windows.Forms.FormClosedEventHandler(codeCompletionWindow_FormClosed);
                    }
                }
            }
            return(false);
        }
Ejemplo n.º 2
0
        bool TextAreaKeyEventHandler(char key)
        {
            if (inHandleKeyPress)
            {
                return(false);
            }

            inHandleKeyPress = true;

            try
            {
                if (FCompletionWindow != null && !FCompletionWindow.IsDisposed)
                {
                    // If completion window is open and wants to handle the key, don't let the text area handle it.
                    if (FCompletionWindow.ProcessKeyEvent(key))
                    {
                        return(true);
                    }
                    if (FCompletionWindow != null && !FCompletionWindow.IsDisposed)
                    {
                        // code-completion window is still opened but did not want to handle
                        // the keypress -> don't try to restart code-completion
                        return(false);
                    }
                }

                return(FCompletionBinding.HandleKeyPress(this, key));
            }
            finally
            {
                inHandleKeyPress = false;
            }
        }
        public SqlCodeCompletion(TextEditorControl control, ImageList imageList)
        {
            _editor    = control;
            _imageList = imageList;

            control.ActiveTextAreaControl.TextArea.KeyDown += (o, s) =>
            {
                // open via "ctrl+space"
                if (s.Control && s.KeyCode == Keys.Space)
                {
                    s.SuppressKeyPress = true;
                    this.ShowCodeCompleteWindow('\0');
                }
            };

            control.ActiveTextAreaControl.TextArea.KeyEventHandler += (key) =>
            {
                if (_codeCompletionWindow != null)
                {
                    if (_codeCompletionWindow.ProcessKeyEvent(key))
                    {
                        return(true);
                    }
                }

                return(false);
            };

            control.Disposed += this.CloseCodeCompletionWindow;  // When the editor is disposed, close the code completion window

            this.UpdateCodeCompletion(null);
        }
Ejemplo n.º 4
0
        private bool TextAreaKeyEventHandler(char key)
        {
            if (codeCompletionWindow != null)
            {
                if (codeCompletionWindow.ProcessKeyEvent(key))
                {
                    return(true);
                }
            }
            if (key == '.')
            {
                ICompletionDataProvider completionDataProvider = new CodeCompletionProvider(this);

                codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(
                    this,                       // The parent window for the completion window
                    _textEditor,                // The text editor to show the window for
                    this.ContentFile.FullName,  // Filename - will be passed back to the provider
                    completionDataProvider,     // Provider to get the list of possible completions
                    key                         // Key pressed - will be passed to the provider
                    );
                if (codeCompletionWindow != null)
                {
                    codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
                }
            }
            return(false);
        }
        // Was part of the CodeCompletionKeyHandler file
        /// <summary>
        /// Return true to handle the keypress, return false to let the text area handle the keypress
        /// </summary>
        public bool TextAreaKeyEventHandler(char key)
        {
            if (codeCompletionWindow != null)
            {
                // If completion window is open and wants to handle the key, don't let the text area
                // handle it

                if (codeCompletionWindow != null)
                {
                    if (codeCompletionWindow.ProcessKeyEvent(key))
                    {
                        return(true);
                    }
                }
            }
            //         "key pressed:{0}".format(key).info();
            //   if (key == '.')// || key == ' ')
            if (key == '.')
            {
                showCodeCompleteWindow(key);

                //});
//                return true;
            }
            return(false);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Return true to handle the keypress, return false to let the text area handle the keypress
 /// </summary>
 bool TextAreaKeyEventHandler(char key)
 {
     if (m_handlingCtrlSpace)
     {
         return(true);
     }
     if (m_codeCompletionWindow != null)
     {
         // If completion window is open and wants to handle the key, don't let the text area
         // handle it
         if (m_codeCompletionWindow.ProcessKeyEvent(key))
         {
             return(true);
         }
     }
     if (key == '.')
     {
         ShowCompletationWindow(key);
     }
     else
     {
         //if (m_codeCompletionWindow == null && (Char.IsLetterOrDigit(key) || key == '_'))
         //{
         //    ShowCompletationWindow('\0');
         //}
     }
     return(false);
 }
        /// <summary>
        /// Return true to handle the keypress, return false to let the text area handle the keypress
        /// </summary>
        bool TextAreaKeyEventHandler(char key)
        {
            if (codeCompletionWindow != null)
            {
                // If completion window is open and wants to handle the key, don't let the text area
                // handle it
                if (codeCompletionWindow.ProcessKeyEvent(key))
                {
                    return(true);
                }
            }
            if (key == '.')
            {
                ICompletionDataProvider completionDataProvider = new CodeCompletionProvider(mainForm);

                codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(
                    mainForm,                                           // The parent window for the completion window
                    editor,                                             // The text editor to show the window for
                    MainForm.DummyFileName,                             // Filename - will be passed back to the provider
                    completionDataProvider,                             // Provider to get the list of possible completions
                    key                                                 // Key pressed - will be passed to the provider
                    );
                if (codeCompletionWindow != null)
                {
                    // ShowCompletionWindow can return null when the provider returns an empty list
                    codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
                }
            }
            return(false);
        }
Ejemplo n.º 8
0
        // Was part of the CodeCompletionKeyHandler file

        /// <summary>
        /// Return true to handle the keypress, return false to let the text area handle the keypress
        /// </summary>
        public bool TextAreaKeyEventHandler(char key)
        {
            if (codeCompletionWindow != null)
            {
                // If completion window is open and wants to handle the key, don't let the text area
                // handle it

                if (codeCompletionWindow != null)
                {
                    if (codeCompletionWindow.ProcessKeyEvent(key))
                    {
                        return(true);
                    }
                }
            }
            //         "key pressed:{0}".format(key).info();
            if (key == '.')
            {
                //O2Thread.mtaThread(   //I really want to run this on a separate thread but It is causing a weird problem where the codecomplete only happens after the 2nd char
                //() =>
                //{
                currentExpression = FindExpression();
                //var o2Timer = new O2Timer("Code Completion").start();
                //textEditor.invokeOnThread(()=> textEditor.textArea().Caret.Column ++ );
                try
                {
                    //startOffset = textEditor.currentOffset() + 1;   // it was +1 before we made this run on an mta thread
                    ICompletionDataProvider completionDataProvider = this;    //new CodeCompletionProvider(this);

                    codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(
                        textEditor.ParentForm,                                          // The parent window for the completion window
                        textEditor,                                                     // The text editor to show the window for
                        DummyFileName,                                                  // Filename - will be passed back to the provider
                        completionDataProvider,                                         // Provider to get the list of possible completions
                        key                                                             // Key pressed - will be passed to the provider
                        );

                    if (codeCompletionWindow != null)
                    {
                        // ShowCompletionWindow can return null when the provider returns an empty list
                        codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
                    }
                    //textEditor.insertTextAtCurrentCaretLocation(".");
                }
                catch (Exception ex)
                {
                    ex.log("in O2CodeCompletion.TextAreaKeyEventHandler");
                }
                //  o2Timer.stop();
                //});
//                return true;
            }
            return(false);
        }
Ejemplo n.º 9
0
        private bool TextArea_KeyDown(char key)
        {
            if (mCompletionWindow != null)
            {
                if (mCompletionWindow.ProcessKeyEvent(key) == true)
                {
                    return(true);
                }
            }

            ShowIntellisense(key);
            return(false);
        }
Ejemplo n.º 10
0
 /// <summary>
 ///   Called whenever a character is about to be added to the document.
 /// </summary>
 /// <param name="p_chrChar">The character about to be added.</param>
 /// <returns><lang langref="true" /> if the character has been handled; <lang langref="false" /> otherwise.</returns>
 private bool TextArea_KeyEventHandler(char p_chrChar)
 {
     if ((m_ccwCodeCompletionWindow != null) && m_ccwCodeCompletionWindow.ProcessKeyEvent(p_chrChar))
     {
         return(true);
     }
     m_chrLastChar = p_chrChar;
     if (p_chrChar.Equals('<') || p_chrChar.Equals(' ') || m_booGenerateOnNextKey)
     {
         m_booGenerateOnNextKey = false;
         ShowCodeCompletionWindow(p_chrChar);
     }
     return(false);
 }
Ejemplo n.º 11
0
        private bool TextAreaKeyEventHandler(char key)
        {
            if (_codeCompletionWindow != null)
            {
                // If completion window is open and wants to handle the key, don't let the text area
                // handle it
                if (_codeCompletionWindow.ProcessKeyEvent(key))
                {
                    return(true);
                }
            }

            if (key == '.')
            {
                ICompletionDataProvider completionDataProvider = new CodeCompletionProvider(_iForm);

                _codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(
                    _iForm,                         // The parent window for the completion window
                    _editor,                        // The text editor to show the window for
                    IntellisenseForm.DummyFileName, // Filename - will be passed back to the provider
                    completionDataProvider,         // Provider to get the list of possible completions
                    key                             // Key pressed - will be passed to the provider
                    );
                if (_codeCompletionWindow != null)
                {
                    // ShowCompletionWindow can return null when the provider returns an empty list
                    _codeCompletionWindow.Closed += CloseCodeCompletionWindow;
                }
            }
            else if (key == '(')
            {
                if (_insightWindow != null && (!_insightWindow.IsDisposed))
                {
                    // provider returned an empty list, so the window never been opened
                    CloseInsightWindow(this, EventArgs.Empty);
                }

                IInsightDataProvider insightdataprovider = new MethodInsightDataProvider(_iForm);
                _insightWindow         = new InsightWindow(_iForm, _editor);
                _insightWindow.Closed += CloseInsightWindow;
                _insightWindow.AddInsightDataProvider(insightdataprovider, IntellisenseForm.DummyFileName);
                _insightWindow.ShowInsightWindow();
            }

            return(false);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Captures the user's key presses.
        /// </summary>
        /// <remarks>
        /// <para>The code completion window ProcessKeyEvent is not perfect
        /// when typing xml.  If enter a space or ':' the text is
        /// autocompleted when it should not be.</para>
        /// <para>The code completion window has one predefined width,
        /// which cuts off any long namespaces that we show.</para>
        /// <para>The above issues have been resolved by duplicating
        /// the code completion window and fixing the problems in the
        /// duplicated class.</para>
        /// </remarks>
        protected bool HandleKeyPress(char ch)
        {
            if (IsCodeCompletionWindowOpen)
            {
                if (codeCompletionWindow.ProcessKeyEvent(ch))
                {
                    return(false);
                }
            }

            try
            {
                switch (ch)
                {
                case '<':
                case ' ':
                case '=':
                    ShowCompletionWindow(ch);
                    return(false);

                default:
                    if (XmlParser.IsAttributeValueChar(ch))
                    {
                        if (IsInsideQuotes(ActiveTextAreaControl.TextArea))
                        {
                            // Have to insert the character ourselves since
                            // it is not actually inserted yet.  If it is not
                            // inserted now the code completion will not work
                            // since the completion data provider attempts to
                            // include the key typed as the pre-selected text.
                            InsertCharacter(ch);
                            ShowCompletionWindow(ch);
                            return(true);
                        }
                    }
                    break;
                }
            }
            catch (Exception e)
            {
                ErrorDialog.Show(e);
            }

            return(false);
        }
        private bool TextArea_KeyEventHandler(char ch)
        {
            if (_inHandleKeyPress)
            {
                return(false);
            }

            _inHandleKeyPress = true;
            try
            {
                if (_codeCompletionWindow != null && !_codeCompletionWindow.IsDisposed)
                {
                    if (_codeCompletionWindow.ProcessKeyEvent(ch))
                    {
                        return(true);
                    }
                    if (_codeCompletionWindow != null && !_codeCompletionWindow.IsDisposed)
                    {
                        // code-completion window is still opened but did not want to handle
                        // the keypress -> don't try to restart code-completion
                        return(false);
                    }
                }

                if (Settings.Default.EnableAutoComplete)
                {
                    string extension = string.IsNullOrEmpty(FileName) ? ".asm" : Path.GetExtension(FileName);
                    if (_codeCompletionFactory.GetBindingForExtension(extension)
                        .Any(ccBinding => ccBinding.HandleKeyPress(this, ch)))
                    {
                        return(false);
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log("Code completion exception", ex);
            }
            finally
            {
                _inHandleKeyPress = false;
            }

            return(false);
        }
        bool HandleKeyPress(char ch)
        {
            if (inHandleKeyPress)
            {
                return(false);
            }
            inHandleKeyPress = true;
            try {
                if (codeCompletionWindow != null && !codeCompletionWindow.IsDisposed)
                {
                    if (codeCompletionWindow.ProcessKeyEvent(ch))
                    {
                        return(true);
                    }
                    if (codeCompletionWindow != null && !codeCompletionWindow.IsDisposed)
                    {
                        // code-completion window is still opened but did not want to handle
                        // the keypress -> don't try to restart code-completion
                        return(false);
                    }
                }

                if (CodeCompletionOptions.EnableCodeCompletion)
                {
                    foreach (ICodeCompletionBinding ccBinding in CodeCompletionBindings)
                    {
                        if (ccBinding.HandleKeyPress(this, ch))
                        {
                            return(false);
                        }
                    }
                    if (ch == '\n')
                    {
                        StartDelayedReparse();
                    }
                }
            } catch (Exception ex) {
                LogException(ex);
            } finally {
                inHandleKeyPress = false;
            }
            return(false);
        }
Ejemplo n.º 15
0
 bool HandleKeyPress(char ch)
 {
     if (codeCompletionWindow != null && !codeCompletionWindow.IsDisposed)
     {
         if (codeCompletionWindow.ProcessKeyEvent(ch))
         {
             return(true);
         }
         if (codeCompletionWindow != null && !codeCompletionWindow.IsDisposed)
         {
             return(false);
         }
     }
     foreach (ICodeCompletionBinding ccBinding in CodeCompletionBindings)
     {
         if (ccBinding.HandleKeyPress(this, ch))
         {
             return(false);
         }
     }
     return(false);
 }
Ejemplo n.º 16
0
        /// <summary>
        /// キー入力があったとき
        /// </summary>
        /// <param name="ch">入力された文字</param>
        /// <returns>入力をキャンセルするときはtrue</returns>
        bool ActiveTextArea_KeyEventHandler(char ch)
        {
            if (m_useCodeComp)                  //入力補完を行うとき
            {
                FileType.KrkrType type = FileType.GetKrkrType(this.FileName);
                if (m_codeCompletionWindow != null && !m_codeCompletionWindow.IsDisposed)
                {
                    if (type == FileType.KrkrType.Kag && (ch == ' ' || ch == '='))
                    {
                        //次の入力補完へ移行させるためここでは何もしない
                    }
                    else if (type == FileType.KrkrType.Kag && ch == ']')
                    {
                        //タグ入力が終了したので入力補完を終了させる
                        m_codeCompletionWindow.Close();
                        return(false);
                    }
                    else
                    {
                        //入力補完リストにイベントを投げる
                        return(m_codeCompletionWindow.ProcessKeyEvent(ch));
                    }
                }

                switch (type)
                {
                case FileType.KrkrType.Kag:
                    kagKeyEventHandler(ch);
                    break;

                case FileType.KrkrType.Tjs:
                    tjsKeyEventHandler(ch);
                    break;
                }
            }

            return(false);
        }
Ejemplo n.º 17
0
        bool HandleKeyPress(char ch)
        {
            if (inHandleKeyPress)
            {
                return(false);
            }
            inHandleKeyPress = true;
            try {
                if (codeCompletionWindow != null && !codeCompletionWindow.IsDisposed)
                {
                    if (codeCompletionWindow.ProcessKeyEvent(ch))
                    {
                        return(true);
                    }
                    if (codeCompletionWindow != null && !codeCompletionWindow.IsDisposed)
                    {
                        // code-completion window is still opened but did not want to handle
                        // the keypress -> don't try to restart code-completion
                        return(false);
                    }
                }

                if (CodeCompletionOptions.EnableCodeCompletion)
                {
                    foreach (ICodeCompletionBinding ccBinding in CodeCompletionBindings)
                    {
                        if (ccBinding.HandleKeyPress(this, ch))
                        {
                            return(false);
                        }
                    }
                }
                if (ch == ' ')
                {
                    string word = GetWordBeforeCaret();
                    if (word != null)
                    {
                        CodeTemplateGroup templateGroup = CodeTemplateLoader.GetTemplateGroupPerFilename(FileName);
                        if (templateGroup != null)
                        {
                            foreach (CodeTemplate template in templateGroup.Templates)
                            {
                                if (template.Shortcut == word)
                                {
                                    if (word.Length > 0)
                                    {
                                        int newCaretOffset = DeleteWordBeforeCaret();
                                        //// set new position in text area
                                        ActiveTextAreaControl.TextArea.Caret.Position = Document.OffsetToPosition(newCaretOffset);
                                    }

                                    InsertTemplate(template);
                                    return(true);
                                }
                            }
                        }
                    }
                }
            } catch (Exception ex) {
                LogException(ex);
            } finally {
                inHandleKeyPress = false;
            }
            return(false);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Return true to handle the keypress, return false to let the text area handle the keypress
        /// </summary>
        bool TextAreaKeyEventHandler(char key)
        {
            try
            {
                if (codeCompletionWindow != null)
                {
                    // If completion window is open and wants to handle the key, don't let the text area
                    // handle it
                    System.Diagnostics.Debug.WriteLine("---" + key);

                    if (codeCompletionWindow.ProcessKeyEvent(key))
                    {
                        System.Diagnostics.Debug.WriteLine("---" + key + "===");
                        return(true);
                    }
                    else
                    {
                        if (codeCompletionWindow != null && codeCompletionWindow.dataProvider is CodeCompletionProvider)
                        {
                            System.Diagnostics.Debug.WriteLine("---" + key + "===inin");
                            ICompletionData[] data = (codeCompletionWindow.dataProvider as CodeCompletionProvider).GenerateCompletionList(key);
                            if (data == null)
                            {
                                System.Diagnostics.Debug.WriteLine("---" + key + "===close");
                                codeCompletionWindow.Close();
                                //codeCompletionWindow = null;
                            }
                            return(false);
                        }
                    }
                }

                //bool insideMoScript = false;

                //List<KeyValuePair<int, int>> values = new List<KeyValuePair<int, int>>();
                //int index = editor.Document.TextContent.IndexOf("<moscript>", 0, StringComparison.CurrentCultureIgnoreCase);
                //while (index != -1)
                //{
                //    int endindex = editor.Document.TextContent.IndexOf("</moscript>", index + 1, StringComparison.CurrentCultureIgnoreCase);
                //    if (endindex != -1)
                //    {
                //        KeyValuePair<int, int> pair = new KeyValuePair<int, int>(index, endindex);
                //        values.Add(pair);
                //    }

                //    index = editor.Document.TextContent.IndexOf("<moscript>", index + 1, StringComparison.CurrentCultureIgnoreCase);
                //}

                //foreach (KeyValuePair<int, int> pair in values)
                //{
                //    if (editor.ActiveTextAreaControl.Caret.Offset > pair.Key && editor.ActiveTextAreaControl.Caret.Offset < pair.Value)
                //    {
                //        insideMoScript = true;
                //        break;
                //    }
                //}


                //if (insideMoScript)
                //{
                //if (key == '.')
                //{
                //    ICompletionDataProvider completionDataProvider = new CodeCompletionProviderDot(mainForm);

                //    codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(
                //        mainForm, // The parent window for the completion window
                //        editor, // The text editor to show the window for
                //        "x.cs", // Filename - will be passed back to the provider
                //        completionDataProvider, // Provider to get the list of possible completions
                //        key // Key pressed - will be passed to the provider
                //        );



                //    if (codeCompletionWindow != null)
                //    {
                //        // ShowCompletionWindow can return null when the provider returns an empty list
                //        codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);

                //    }
                //}

                try
                {
                    var    seg      = editor.Document.GetLineSegment(editor.ActiveTextAreaControl.Caret.Line);
                    string textline = editor.Document.GetText(seg);
                    int    index    = textline.IndexOf("//");

                    if (index != -1 && index < editor.ActiveTextAreaControl.Caret.Offset)
                    {
                        return(false);
                    }
                }
                catch (Exception)
                {
                }


                if (char.IsLetter(key) || key == '#')
                {
                    ICompletionDataProvider completionDataProvider = new CodeCompletionProvider(mainForm, key.ToString());

                    codeCompletionWindow = CodeCompletionWindow.ShowCompletionWindow(
                        mainForm,               // The parent window for the completion window
                        editor,                 // The text editor to show the window for
                        "x.cs",                 // Filename - will be passed back to the provider
                        completionDataProvider, // Provider to get the list of possible completions
                        key                     // Key pressed - will be passed to the provider
                        );



                    if (codeCompletionWindow != null)
                    {
                        // ShowCompletionWindow can return null when the provider returns an empty list
                        codeCompletionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
                        codeCompletionWindow.SetPre();
                        //return true;
                    }
                }
                else if (key == '(' && mainForm.Specification != null)
                {
                    //if (EnableMethodInsight && CodeCompletionOptions.InsightEnabled)
                    {
                        mainForm.CodeEditor.ShowInsightWindow(new MethodInsightDataProvider(mainForm));
                        return(false);
                    }
                }
                if (key == ',') //&& CodeCompletionOptions.InsightRefreshOnComma && CodeCompletionOptions.InsightEnabled
                {
                    mainForm.CodeEditor.ShowInsightWindow(new MethodInsightDataProvider(mainForm));
                    return(false);
                }


                // }
            }
            catch (Exception ex)
            {
                string msg = ex.Message;
            }

            return(false);
        }
Ejemplo n.º 19
0
        bool TextArea_KeyEventHandler(char key)
        {
            var doc = _area.Document;
            int row = _area.Caret.Line;
            int col = _area.Caret.Column;

            if (completionWindow != null)
            {
                // If completion window is open and wants to handle the key, don't let the text area
                // handle it
                if (completionWindow.ProcessKeyEvent(key))
                {
                    return(true);
                }
            }
            else if (char.IsLetter(key) || key == '_')
            {
                LineSegment seg  = doc.GetLineSegment(row);
                TextWord    word = seg.GetWord(col);

                if (!IsNullWord(word) && IsVariateOrDigit(word.Word))
                {
                    return(false);
                }

                //获取前一个单词
                while (IsNullWord(word) && col > 0)
                {
                    word = seg.GetWord(--col);
                }

                //如果有单词,将本句的单词加入队列
                Queue <TextWord> allWords = new Queue <TextWord>();
                if (!IsNullWord(word))
                {
                    for (int i = seg.Words.IndexOf(word); i > -1; i--)
                    {
                        word = seg.Words[i];
                        if (!string.IsNullOrEmpty(word.Word))
                        {
                            allWords.Enqueue(word);
                        }
                    }
                }

                //加入之前的所有单词
                for (int i = row - 1; i > -1; i--)
                {
                    seg = doc.GetLineSegment(i);
                    for (int j = seg.Words.Count - 1; j > -1; j--)
                    {
                        word = seg.Words[j];
                        if (!string.IsNullOrEmpty(word.Word))
                        {
                            allWords.Enqueue(word);
                        }
                    }
                }

                List <TextWord> pWords = new List <TextWord>();
                List <TextWord> cWords = new List <TextWord>();

                //找到当前语句
                while (allWords.Count > 0)
                {
                    if (IsRangeEnd(allWords.Peek()))
                    {
                        break;
                    }
                    cWords.Add(allWords.Dequeue());
                }

                //找到之前的所有语句
                while (allWords.Count > 0)
                {
                    pWords.Insert(0, allWords.Dequeue());
                }

                _vars.Clear();

                int num;

                //确定当前单词的类型
                string typeName   = null;
                bool   isDataType = false;
                if (cWords.Count == 0 || (cWords[0].Word == "(" && cWords[1].Word == "for"))
                {
                    isDataType = true;
                }
                else
                {
                    List <TextWord> words       = new List <TextWord>();
                    bool            hasDataType = false;
                    for (int i = 0; i < cWords.Count; i++)
                    {
                        words.Add(cWords[i]);
                        if (IsKeyWord("DataType", cWords[i]))
                        {
                            typeName    = cWords[i].Word;
                            hasDataType = true;
                            break;
                        }
                    }

                    //如果当前句有声明语句,在变量表中加入声明过的变量
                    if (hasDataType)
                    {
                        num = 0;
                        for (int i = 0; i < words.Count; i++)
                        {
                            string s = words[i].Word;
                            if (s == "(")
                            {
                                num++;
                            }
                            else if (s == ")")
                            {
                                num--;
                            }

                            if (num == 0 && IsDataType(words[i]))
                            {
                                if (i != words.Count - 1)
                                {
                                    AddVariate(words[i + 1], typeName);
                                }
                            }
                        }

                        if (num == 0 && (IsDataType(words[0]) || IsDataType(words[1])))
                        {
                            return(false);
                        }
                    }
                }

                //找到之前的所有语句中搜索变量声明,并加入变量表
                num = 0;
                bool atDataType = false;
                for (int i = 0; i < pWords.Count; i++)
                {
                    string s = pWords[i].Word;
                    if (IsKeyWord("DataType", pWords[i]))
                    {
                        typeName   = pWords[i].Word;
                        atDataType = true;
                        num        = 0;
                    }
                    else if (s == "(")
                    {
                        num++;
                    }
                    else if (s == ")")
                    {
                        num--;
                    }
                    else if (IsRange(pWords[i]))
                    {
                        atDataType = false;
                    }

                    if (atDataType && num == 0 && IsDataType(pWords[i]))
                    {
                        AddVariate(pWords[i + 1], typeName);
                    }
                }

                //为智能提示准备单词
                _datas.Clear();
                if (isDataType)
                {
                    _datas.AddRange(_words["DataType"]);
                }
                _datas.AddRange(_args);
                _datas.AddRange(_vars);
                _datas.AddRange(_words["KeyWord"]);
                _datas.AddRange(_words["Method"]);
                _datas.AddRange(_words["Constant"]);

                //显示智能提示窗口
                completionWindow =
                    CodeCompletionWindow.ShowCompletionWindow(
                        _form,
                        _area.MotherTextEditorControl,
                        "",
                        this,
                        key);
                if (completionWindow != null)
                {
                    // ShowCompletionWindow can return null when the provider returns an empty list
                    completionWindow.Closed += new EventHandler(CloseCodeCompletionWindow);
                }
            }
            return(false);
        }