Ejemplo n.º 1
0
        private void DoCodeCompletion(bool showCompletionWords)
        {
            if (!CanShowCodeCompletion())
            {
                return;
            }

            var caret = TextEditor.TextArea.Caret;
            TextEnteredPosition enteredText = new TextEnteredPosition(caret.Line, caret.Column);
            GherkinCodeCompletionWordsProvider completionWordsProvider = new GherkinCodeCompletionWordsProvider(Document, enteredText, m_AppSettings);
            bool isEditingDescription;
            List <GherkinCodeCompletionWord> completionWords = completionWordsProvider.CompletionWords(out isEditingDescription);

            if ((completionWords.Count > 0) && (!isEditingDescription || showCompletionWords))
            {
                // open code completion after the user has pressed dot:
                m_CompletionWindow = new CompletionWindow(TextEditor.TextArea);
                // provide AvalonEdit with the data:
                IList <ICompletionData> data = m_CompletionWindow.CompletionList.CompletionData;
                foreach (var word in completionWords)
                {
                    data.Add(word);
                }

                m_CompletionWindow.Show();
                m_CompletionWindow.Closed += delegate { m_CompletionWindow = null; };
            }
        }
Ejemplo n.º 2
0
 public GherkinCodeCompletionWordsProvider(TextDocument document, TextEnteredPosition enteredText, IAppSettings appSettings)
 {
     Document             = document;
     TextEnteredPosition  = enteredText;
     m_AppSettings        = appSettings;
     IsEditingDescription = false;
     Parser = new GherkinSimpleParser(document);
 }