Ejemplo n.º 1
0
        public static CodeCompletionWindow ShowCompletionWindow(Form parent, TextEditorControl control, string fileName, ICompletionDataProvider completionDataProvider, char firstChar, bool showDeclarationWindow, bool fixedListViewWidth)
        {
            if (busy)  // DC to prevent multiple calls
            {
                "CodeCompletionWindow.ShowCompletionWindow was busy, skipping ShowCompletionWindow calculation".info();
                return null;
            }

                busy = true;
                return (CodeCompletionWindow)parent.invokeOnThread(
                    () =>
                    {
                        try
                        {

                            var tempCompletionData = new ICompletionData[] { };
                            CodeCompletionWindow codeCompletionWindow = new CodeCompletionWindow(completionDataProvider, tempCompletionData, parent, control, showDeclarationWindow, fixedListViewWidth);
                            codeCompletionWindow.CloseWhenCaretAtBeginning = firstChar == '\0';
                            codeCompletionWindow.ShowCompletionWindow();

                            O2Thread.mtaThread(         // run in on a separate thread for performance reasons
                                () =>
                                {
                                    try
                                    {
                                        ICompletionData[] completionData = completionDataProvider.GenerateCompletionData(fileName, control.ActiveTextAreaControl.TextArea, firstChar);
                                        if (completionData == null || completionData.Length == 0)
                                        {
                                            //return null;
                                        }
                                        else
                                            codeCompletionWindow.setCodeCompletionData(completionData);
                                        busy = false;
                                    }
                                    catch (Exception ex)
                                    {
                                        ex.log("in CodeCompletionWindow.ShowCompletionWindow ");
                                    }
                                });

                            return codeCompletionWindow;
                        }
                        catch (Exception ex)
                        {
                            busy = false;
                            return null;
                        }
                    });
        }