コード例 #1
0
        internal bool UpdateForFunctionArgument(int line, int column, string function, int argument)
        {
            if (string.IsNullOrEmpty(function))
            {
                return(false);
            }

            IScriptObject activeScript = Solution.Current.ActiveScript;
            string        filePath     = activeScript.GetParsedScript().GetScriptPath();

            if (string.IsNullOrEmpty(filePath))
            {
                filePath = null;
            }

            bool updateVisual = false;

            if (currentFunctionName != function)
            {
                AutoCompletionHelper.SetSearchPaths(ExtensionFactory.GetSearchPaths());

                signatures = AutoCompletionHelper.GetMethodParameterList(
                    line, column, function, filePath);

                currentFunctionName = function;
                updateVisual        = true;
            }

            if (null == signatures || (signatures.Count == 0))
            {
                return(false); // Could not retrieve any function information.
            }
            // Update visual if there's change in argument index.
            updateVisual = (updateVisual || (this.currentArgumentIndex != argument));
            this.currentArgumentIndex = argument;

            if (false == updateVisual)
            {
                return(true); // Visual remains the same.
            }
            if (0 == CurrentOverload || (CurrentOverload > TotalOverloads))
            {
                CurrentOverload = 1;
            }

            NotifyPropertyChanged("CurrentOverload");
            NotifyPropertyChanged("TotalOverloads");
            NotifyPropertyChanged("IsOverloaded");
            UpdateFormattedOutput();

            Logger.LogInfo("AutoComplete-UpdateToolTip", GetLoggingInfo());
            return(true);
        }
コード例 #2
0
        /// <summary>
        /// Method to retrieve AutoComplete list and bind it to visual element
        /// </summary>
        private void DoAutoComplete(string variable)
        {
            Logger.LogInfo("DoAutoComplete", variable);


            EnsureAutoCompleteListCreated();

            IScriptObject activeScript = Solution.Current.ActiveScript;
            string        filePath     = activeScript.GetParsedScript().GetScriptPath();

            if (filePath == string.Empty)
            {
                filePath = null;
            }

            int[]       linesToExclude = new int[] { textCore.CursorPosition.Y };
            ITextBuffer textBuffer     = textCore.CurrentTextBuffer;
            string      partialContent = textBuffer.GetPartialContent(linesToExclude, " \n");

            if (null == AutoCompletionHelper.MessageHandler)
            {
                AutoCompletionHelper.MessageHandler = new AutoCompleteMessageHandler(textEditorControl);
            }

            // Clear output stream messages before attempting another compilation.
            AutoCompleteMessageHandler messageHandler = null;

            messageHandler = AutoCompletionHelper.MessageHandler as AutoCompleteMessageHandler;
            messageHandler.ClearMessages();

            AutoCompletionHelper.SetSearchPaths(ExtensionFactory.GetSearchPaths());

            // Method to contact IDECodeGen.dll to retrieve the list for AutoComplete items
            List <KeyValuePair <AutoCompletionHelper.MemberType, string> > list =
                AutoCompletionHelper.GetList(textCore.CursorPosition.Y,
                                             textCore.CursorPosition.X, partialContent, variable, filePath);

            messageHandler.DisplayPossibleErrors();
            if (list.Count == 0)
            {
                return;
            }

            CharPosition position = activeScript.CreateCharPosition();

            position.SetCharacterPosition(textCore.CursorPosition.X, textCore.CursorPosition.Y);

            // Add each AutoComplete Item one at a time
            Keyboard.Focus(textEditorCanvas);
            autoCompleteList.ClearList();
            autoCompleteList.AddItemsToList(list);

            autoCompletePopup.Placement       = PlacementMode.Custom;
            autoCompletePopup.PlacementTarget = textEditorCanvas;
            autoCompletePopup.CursorPosition  = textCore.CursorPosition;
            autoCompletePopup.IsOpen          = true;

            // The focus shift is important as the AutoCompleteList will
            // be re-routing events back to the main control now.
            autoCompleteList.DoFocusOnFirstItem();
            autoCompletePopup.Width  = autoCompleteList.Width;
            autoCompletePopup.Height = autoCompleteList.Height;
        }