Esempio n. 1
0
 private void PushToAutoCompletion(CompletionItem item, ParsedBaseItem parsedItem)
 {
     item.FromParser     = true;
     item.ParsedBaseItem = parsedItem;
     item.Ranking        = AutoCompletion.FindRankingOfParsedItem(item.DisplayText);
     ParsedCompletionItemsList.Add(item);
 }
Esempio n. 2
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            _clearButton = GetTemplateChild("PART_ClearButton") as Button;
            if (_clearButton is null)
            {
                throw Log.ErrorAndCreateException <InvalidOperationException>("Can't find template part 'PART_ClearButton'");
            }
            _clearButton.SetCurrentValue(System.Windows.Controls.Primitives.ButtonBase.CommandProperty, _clearFilter);

            this.AttachBehavior <UpdateBindingOnTextChanged>();
            this.AttachBehavior <SelectTextOnFocus>();

            _autoCompletion = this.AttachBehavior <AutoCompletion>();
            UpdateAutoCompletion();

            var serviceEventArg = new InitializingAutoCompletionServiceEventArgs();

            OnInitializingAutoCompletionService(serviceEventArg);
            var autoCompletionService = serviceEventArg.AutoCompletionService;

            if (autoCompletionService == null)
            {
                return;
            }

            //Hack
            var autoCompletionServiceFieldInfo = _autoCompletion.GetType().GetField("_autoCompletionService", BindingFlags.Instance | BindingFlags.NonPublic);

            if (autoCompletionServiceFieldInfo != null)
            {
                autoCompletionServiceFieldInfo.SetValue(_autoCompletion, autoCompletionService);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Procedures
        /// </summary>
        public void Visit(ParsedProcedure pars)
        {
            // to code explorer
            var parentNode = pars.Flags.HasFlag(ParseFlag.External) ? GetExplorerListNode("External procedures", CodeExplorerIconType.ExternalProcedure) : GetExplorerListNode("Procedures", CodeExplorerIconType.Procedure);
            var newNode    = CodeItem.Factory.New(pars.Flags.HasFlag(ParseFlag.External) ? CodeExplorerIconType.ExternalProcedure : CodeExplorerIconType.Procedure);

            newNode.DisplayText   = pars.Name;
            newNode.Flags         = pars.Flags;
            newNode.SubText       = pars.Flags.HasFlag(ParseFlag.External) ? pars.ExternalDllName : null;
            newNode.DocumentOwner = pars.FilePath;
            newNode.GoToLine      = pars.Line;
            newNode.GoToColumn    = pars.Column;
            PushToCodeExplorer(parentNode, newNode);

            // to completion data
            var proc = CompletionItem.Factory.New(pars.Flags.HasFlag(ParseFlag.External) ? CompletionType.ExternalProcedure : CompletionType.Procedure);

            proc.DisplayText    = pars.Name;
            proc.ParsedBaseItem = pars;
            proc.FromParser     = true;
            proc.SubText        = pars.Flags.HasFlag(ParseFlag.External) ? pars.ExternalDllName : null;
            proc.Ranking        = AutoCompletion.FindRankingOfParsedItem(pars.Name);
            proc.Flags          = pars.Flags;
            PushToAutoCompletion(proc, pars);
        }
Esempio n. 4
0
        /// <summary>
        /// Methods
        /// </summary>
        public void Visit(ParsedMethod pars)
        {
            pars.ReturnType = ConvertStringToParsedPrimitiveType(pars.TempReturnType, false);

            // to code explorer
            var classNode  = GetExplorerListNode(pars.ClassName, CodeExplorerIconType.Block);
            var parentNode = GetExplorerListNode("Methods", CodeExplorerIconType.Method, classNode);
            var newNode    = CodeItem.Factory.New(CodeExplorerIconType.Method);

            newNode.DisplayText   = pars.Name;
            newNode.Flags         = pars.Flags;
            newNode.DocumentOwner = pars.FilePath;
            newNode.GoToLine      = pars.Line;
            newNode.GoToColumn    = pars.Column;
            PushToCodeExplorer(parentNode, newNode);

            // to completion data
            var method = CompletionItem.Factory.New(CompletionType.Method);

            method.DisplayText    = pars.Name;
            method.ParsedBaseItem = pars;
            method.FromParser     = true;
            method.SubText        = null;
            method.Ranking        = AutoCompletion.FindRankingOfParsedItem(pars.Name);
            method.Flags          = pars.Flags;
            PushToAutoCompletion(method, pars);
        }
Esempio n. 5
0
File: Plug.cs Progetto: massreuy/3P
        /// <summary>
        /// Called on Npp shutdown
        /// </summary>
        internal static void DoNppShutDown()
        {
            try {
                if (OnShutDown != null)
                {
                    OnShutDown();
                }

                // clean up timers
                RecurentAction.CleanAll();
                DelayedAction.CleanAll();
                AsapButDelayableAction.CleanAll();

                // Triggered when the resolution of an assembly fails, gives us the opportunity to feed the required assembly
                AppDomain.CurrentDomain.AssemblyResolve -= LibLoader.AssemblyResolver;

                // catch unhandled errors to log them
                AppDomain.CurrentDomain.UnhandledException -= ErrorHandler.UnhandledErrorHandler;
                Application.ThreadException           -= ErrorHandler.ThreadErrorHandler;
                TaskScheduler.UnobservedTaskException -= ErrorHandler.UnobservedErrorHandler;

                // unsubscribe to static events
                ProEnvironment.OnEnvironmentChange -= FileExplorer.Instance.RebuildFileList;
                ProEnvironment.OnEnvironmentChange -= DataBase.Instance.UpdateDatabaseInfo;
                ProEnvironment.OnEnvironmentChange -= ParserHandler.ClearStaticData;

                Keywords.Instance.OnImport         -= AutoCompletion.SetStaticItems;
                DataBase.Instance.OnDatabaseUpdate -= AutoCompletion.SetStaticItems;
                AutoCompletion.OnUpdateStaticItems -= ParserHandler.UpdateKnownStaticItems;

                ParserHandler.OnEndSendCompletionItems -= AutoCompletion.SetDynamicItems;
                ParserHandler.OnStart -= CodeExplorer.Instance.OnStart;
                ParserHandler.OnEndSendParserItems       -= CodeExplorer.Instance.OnParseEndParserItems;
                ParserHandler.OnEndSendCodeExplorerItems -= CodeExplorer.Instance.OnParseEndCodeExplorerItems;
                ParserHandler.OnEnd -= CodeExplorer.Instance.OnParseEnd;

                ProExecutionHandleCompilation.OnEachCompilationOk -= FilesInfo.ProExecutionHandleCompilationOnEachCompilationOk;

                // export modified conf
                FileTag.Export();

                // save config (should be done but just in case)
                Config.Save();

                // remember the most used keywords
                Keywords.Instance.SaveRanking();

                // close every form
                FileExplorer.Instance.ForceClose();
                CodeExplorer.Instance.ForceClose();
                AutoCompletion.ForceClose();
                InfoToolTip.ForceClose();
                Appli.ForceClose();
                UserCommunication.ForceClose();
                AppliMenu.ForceClose();
            } catch (Exception e) {
                ErrorHandler.ShowErrors(e, "Stop");
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Method called when the tooltip is opened from the mouse being inactive on scintilla
        /// </summary>
        public static void ShowToolTipFromDwell(bool openTemporary = true)
        {
            if (Config.Instance.ToolTipDeactivate)
            {
                return;
            }
            InitIfneeded();

            var position = Sci.GetPositionFromMouseLocation();

            if (position < 0)
            {
                return;
            }

            // check caret context, dont display a tooltip for comments
            var curContext = (UdlStyles)Sci.GetStyleAt(position);

            if (curContext == UdlStyles.Comment || curContext == UdlStyles.Delimiter8)
            {
                return;
            }

            // sets the tooltip content
            var data = AutoCompletion.FindInCompletionData(Sci.GetWordAtPosition(position, AutoCompletion.CurrentLangAllChars, AutoCompletion.CurrentLangAdditionalChars), Sci.LineFromPosition(position));

            if (data != null && data.Count > 0)
            {
                _currentCompletionList = data;
            }
            else
            {
                return;
            }

            // in strings, only functions trigger the tooltip
            if ((curContext == UdlStyles.Delimiter1 || curContext == UdlStyles.Delimiter2 || curContext == UdlStyles.Delimiter4 || curContext == UdlStyles.Delimiter5) && _currentCompletionList.First().Type != CompletionType.Function)
            {
                return;
            }

            SetToolTip();

            // update position
            var point = Sci.GetPointXyFromPosition(position);

            point.Offset(Sci.GetScintillaRectangle().Location);
            var lineHeight = Sci.TextHeight(Sci.Line.CurrentLine);

            point.Y       += lineHeight + 5;
            _form.Location = _form.GetBestAutocompPosition(point, lineHeight + 5);

            _openedFromDwell = openTemporary;
            if (!_form.Visible)
            {
                _form.UnCloak();
            }
        }
Esempio n. 7
0
 /// <summary>
 /// Called when a single char is deleted
 /// </summary>
 public static void OnCharDeleted(char c, int position)
 {
     try {
         // handles the autocompletion
         AutoCompletion.UpdateAutocompletion();
     } catch (Exception e) {
         ErrorHandler.ShowErrors(e, "Error in OnCharDeleted");
     }
 }
Esempio n. 8
0
 /// <summary>
 /// For certain config properties, we need to refresh stuff to see a difference
 /// </summary>
 private void ApplySettings()
 {
     YamuiThemeManager.TabAnimationAllowed = Config.Instance.AppliAllowTabAnimation;
     CodeExplorer.CodeExplorer.Instance.ApplyColorSettings();
     FileExplorer.FileExplorer.Instance.ApplyColorSettings();
     AutoCompletion.ForceClose();
     InfoToolTip.InfoToolTip.ForceClose();
     Plug.ApplyOptionsForScintilla();
     Sci.MouseDwellTime = Config.Instance.ToolTipmsBeforeShowing;
     Keywords.Instance.ResetCompletionItems(); // when changing case
     DataBase.Instance.ResetCompletionItems();
 }
Esempio n. 9
0
 private void PushToAutoCompletion(TextCompletionItem item, Token origin)
 {
     item.DisplayText    = origin.Value;
     item.FromParser     = true;
     item.ParsedBaseItem = new ParsedWord(origin.Value, origin)
     {
         FilePath = FilePath,
         Scope    = _rootScope
     };
     item.Ranking = AutoCompletion.FindRankingOfParsedItem(item.DisplayText);
     ParsedCompletionItemsList.Add(item);
 }
Esempio n. 10
0
        /// <summary>
        /// force everything to redraw to apply a new theme
        /// </summary>
        public static void RefreshApplicationWithTheme(Theme theme)
        {
            Current = theme;
            Config.Instance.AccentColor = theme.AccentColor;

            // force the autocomplete to redraw
            AutoCompletion.ApplyColorSettings();
            CodeExplorer.CodeExplorer.Instance.ApplyColorSettings();
            FileExplorer.FileExplorer.Instance.ApplyColorSettings();
            Application.DoEvents();
            Appli.Appli.Refresh();
        }
Esempio n. 11
0
        public static bool TriggerCodeSnippetInsertion()
        {
            if (InsertionActive)
            {
                return(false);                 // do no insert a snippet within a snippet!
            }
            string token       = Sci.GetWord(null, Sci.CurrentPosition);
            var    curPos      = Sci.CurrentPosition;
            Point  tokenPoints = new Point(curPos - token.Length, curPos);

            if (Contains(token))
            {
                string replacement = GetTemplate(token);

                if (replacement != null)
                {
                    int line         = Sci.Line.CurrentLine;
                    int lineStartPos = Sci.GetLine(line).Position;

                    int horizontalOffset = tokenPoints.X - lineStartPos;

                    //relative selection in the replacement text
                    PrepareForIncertion(replacement, horizontalOffset, tokenPoints.X);

                    var indic = Sci.GetIndicator(SnippetContext.IndicatorId);
                    indic.IndicatorStyle = IndicatorStyle.Box;
                    indic.ForeColor      = Color.Blue;

                    foreach (var point in LocSnippetContext.Parameters)
                    {
                        indic.Add(point.X, point.Y);
                    }

                    if (LocSnippetContext.CurrentParameter.HasValue)
                    {
                        Sci.SetSelection(LocSnippetContext.CurrentParameter.Value.X, LocSnippetContext.CurrentParameter.Value.Y);
                        LocSnippetContext.CurrentParameterValue = Sci.GetTextBetween(LocSnippetContext.CurrentParameter.Value);
                    }

                    AutoCompletion.Cloak();

                    if (LocSnippetContext.Parameters.Count <= 1)
                    {
                        FinalizeCurrent();
                    }
                }

                return(true);
            }
            return(false);
        }
Esempio n. 12
0
 private static List <CompletionItem> GetTableCompletionItemChildren(TableCompletionItem table, List <ParsedField> parsedFields)
 {
     return(parsedFields.Select(field => {
         var curField = CompletionItem.Factory.New(field.Flags.HasFlag(ParseFlag.Primary) ? CompletionType.FieldPk : CompletionType.Field);
         curField.DisplayText = field.Name.ConvertCase(Config.Instance.AutoCompleteDatabaseWordCaseMode);
         curField.ParsedBaseItem = field;
         curField.FromParser = true;
         curField.SubText = field.PrimitiveType.ToString();
         curField.Ranking = AutoCompletion.FindRankingOfParsedItem(field.Name);
         curField.Flags = field.Flags & ~ParseFlag.Primary;
         curField.ParentItem = table;
         return curField;
     }).ToList());
 }
Esempio n. 13
0
        public void Save()
        {
            XmlDocument doc         = new XmlDocument();
            XmlElement  nppprojNode = doc.CreateElement("NppPIALexer2");

            nppprojNode.SetAttribute("visible", Main.FrmMain == null ? "False" : Main.FrmMain.Visible.ToString());
            nppprojNode.SetAttribute("autoCompletion", AutoCompletion.ToString());
            nppprojNode.SetAttribute("autoApplyTemplate", AutoApplyTemplate.ToString());
            nppprojNode.SetAttribute("autoApplyTemplateLangs", AutoApplyTemplateLangs);
            foreach (var project in ProjectManager.Projects)
            {
                XmlElement projNode = doc.CreateElement("project");
                projNode.SetAttribute("path", project.ProjectFile);
                nppprojNode.AppendChild(projNode);
            }
            doc.AppendChild(nppprojNode);
            File.WriteAllText(_configFile, doc.OuterXml);
        }
Esempio n. 14
0
        public static bool MouseMessageHandler(WinApi.Messages message, Win32Api.MOUSEHOOKSTRUCT mouseStruct)
        {
            switch (message)
            {
            // middle click : go to definition
            case WinApi.Messages.WM_MBUTTONDOWN:
                if (Npp.CurrentFileInfo.IsProgress)
                {
                    if (KeyboardMonitor.GetModifiers.IsCtrl)
                    {
                        Npp.GoBackFromDefinition();
                    }
                    else
                    {
                        ProMisc.GoToDefinition(true);
                    }
                }
                return(true);

            //break;
            // (CTRL + ) Right click : show main menu
            case WinApi.Messages.WM_RBUTTONUP:
                if (KeyboardMonitor.GetModifiers.IsCtrl)
                {
                    // we need the cursor to be in scintilla but not on the application or the autocompletion!
                    if ((!Appli.IsVisible || !Appli.IsMouseIn()) &&
                        (!InfoToolTip.IsVisible || !InfoToolTip.IsMouseIn()) &&
                        (!AutoCompletion.IsVisible || !AutoCompletion.IsMouseIn()))
                    {
                        AppliMenu.ShowMainMenu(true);
                        return(true);
                    }
                }
                break;
            }

            return(false);
        }
Esempio n. 15
0
        /// <summary>
        /// Defined Temptables
        /// </summary>
        public void Visit(ParsedTable pars)
        {
            string subStr = string.IsNullOrEmpty(pars.StringLikeTable) ? "" : (pars.LikeTable != null ? @"Like " + pars.LikeTable.Name : @"Like ??");

            // to auto completion
            var parsedTable = new TempTableCompletionItem {
                DisplayText    = pars.Name,
                Flags          = pars.Flags,
                SubText        = subStr,
                ChildSeparator = '.'
            };

            parsedTable.Children = pars.Fields.Select(field => {
                var curField            = CompletionItem.Factory.New(field.Flags.HasFlag(ParseFlag.Primary) ? CompletionType.FieldPk : CompletionType.Field);
                curField.DisplayText    = field.Name.ConvertCase(Config.Instance.AutoCompleteDatabaseWordCaseMode);
                curField.ParsedBaseItem = field;
                curField.FromParser     = true;
                curField.SubText        = field.Type.ToString();
                curField.Ranking        = AutoCompletion.FindRankingOfParsedItem(field.Name);
                curField.Flags          = field.Flags & ~ParseFlag.Primary;
                curField.ParentItem     = parsedTable;
                return(curField);
            }).ToList();
            PushToAutoCompletion(parsedTable, pars);

            // to code explorer
            PushToCodeExplorer(
                GetExplorerListNode("Defined temp-tables", CodeExplorerIconType.DefinedTempTable),
                new TempTableCodeItem {
                DisplayText   = pars.Name,
                Flags         = pars.Flags,
                SubText       = subStr,
                DocumentOwner = pars.FilePath,
                GoToLine      = pars.Line,
                GoToColumn    = pars.Column
            });
        }
Esempio n. 16
0
        /// <summary>
        /// Called when the user presses a key
        /// </summary>
        // ReSharper disable once RedundantAssignment
        public static bool KeyDownHandler(KeyEventArgs e)
        {
            // if set to true, the keyinput is completly intercepted, otherwise npp sill does its stuff
            bool handled = false;

            MenuItem menuItem = null;

            try {
                // Since it's a keydown message, we can receive this a lot if the user let a button pressed
                var isSpamming = Utils.IsSpamming(e.KeyCode.ToString(), 100, true);

                // check if the user triggered a 3P function defined in the AppliMenu
                menuItem = TriggeredMenuItem(AppliMenu.Instance.ShortcutableItemList, isSpamming, e, ref handled);
                if (handled)
                {
                    return(true);
                }

                // Autocompletion
                if (AutoCompletion.IsVisible)
                {
                    handled = AutoCompletion.PerformKeyDown(e);
                }

                // next tooltip
                if (!handled && InfoToolTip.IsVisible && e.Control && (e.KeyCode == Keys.Up || e.KeyCode == Keys.Down))
                {
                    if (e.KeyCode == Keys.Up)
                    {
                        InfoToolTip.IndexToShow--;
                    }
                    else
                    {
                        InfoToolTip.IndexToShow++;
                    }
                    InfoToolTip.TryToShowIndex();
                    handled = true;
                }

                if (handled)
                {
                    return(true);
                }

                // Ok so... when we open a form in notepad++, we can't use the overrides PreviewKeyDown / KeyDown
                // like we normally can, for some reasons, they don't react to certain keys (like enter!)
                // It only works "almost normally" if we ShowDialog() the form?!
                // So i gave up and handle things here!
                // Each control / form that should use a key not handled by Npp should implement a method
                // "PerformKeyDown" that will be triggered from here (see below)
                var curControl = Win32Api.GetFocusedControl();
                if (curControl != null)
                {
                    var invokeResponse = curControl.InvokeMethod("PerformKeyDown", new[] { (object)e });
                    if (invokeResponse != null && (bool)invokeResponse)
                    {
                        return(true);
                    }
                }
                var curWindow = Control.FromHandle(WinApi.GetForegroundWindow());
                if (curWindow != null)
                {
                    var invokeResponse = curWindow.InvokeMethod("PerformKeyDown", new[] { (object)e });
                    if (invokeResponse != null && (bool)invokeResponse)
                    {
                        return(true);
                    }
                }

                // Close interfacePopups
                if (e.KeyCode == Keys.PageDown || e.KeyCode == Keys.PageUp || e.KeyCode == Keys.Next || e.KeyCode == Keys.Prior)
                {
                    ClosePopups();
                }
            } catch (Exception ex) {
                ErrorHandler.ShowErrors(ex, "Occurred in : " + (menuItem == null ? new ShortcutKey(e.Control, e.Alt, e.Shift, e.KeyCode).ToString() : menuItem.ItemId));
            }

            return(handled);
        }
Esempio n. 17
0
        private AppliMenu()
        {
            // List of item that can be assigned to a shortcut
            ShortcutableItemList = new List <MenuItem> {
                // add the main menu here, so it can appear in the list of shortcut to set
                new MenuItem(null, "Open main menu", ImageResources.Logo20x20, item => ShowMainMenu(), "Show_main_menu_", "Alt+C")
                {
                    Generic = true
                }
            };

            #region Progress tools

            _progressTools = new List <MenuItem> {
                new MenuItem(this, "Progress desktop", ImageResources.ProDesktop, item => ProMisc.OpenProDesktop(), "Pro_desktop", "")
                {
                    Generic = true
                },
                new MenuItem(this, "Open in the AppBuilder", ImageResources.SendToAppbuilder, item => ProMisc.OpenCurrentInAppbuilder(), "Send_appbuilder", "Alt+O"),
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "PROLINT code", ImageResources.ProlintCode, item => ProMisc.StartProgressExec(ExecutionType.Prolint), "Prolint", "F12"),
                new MenuItem(this, "Deploy current file", ImageResources.Deploy, item => ProMisc.DeployCurrentFile(), "Deploy", "Ctrl+Alt+Prior")
                {
                    Generic = true
                },
                new MenuItem(this, "Generate DEBUG-LIST", ImageResources.ExtDbg, item => ProMisc.StartProgressExec(ExecutionType.GenerateDebugfile, compilation => compilation.CompileWithDebugList = true), "Generate_debug-list", null),
                new MenuItem(this, "Generate LISTING", ImageResources.ExtLis, item => ProMisc.StartProgressExec(ExecutionType.GenerateDebugfile, compilation => compilation.CompileWithListing      = true), "Generate_listing", null),
                new MenuItem(this, "Generate XREF", ImageResources.ExtXrf, item => ProMisc.StartProgressExec(ExecutionType.GenerateDebugfile, compilation => compilation.CompileWithXref            = true), "Generate_xref", null),
                new MenuItem(this, "Generate XREF-XML", ImageResources.ExtXml, item => ProMisc.StartProgressExec(ExecutionType.GenerateDebugfile, compilation => {
                    compilation.CompileWithXref = true;
                    compilation.UseXmlXref      = true;
                }), "Generate_xrefxml", null),
            };

            #endregion

            #region Generate code

            _generateCodeMenuList = new List <MenuItem> {
                new MenuItem(this, "Insert new internal procedure", ImageResources.Procedure, item => ProGenerateCode.Factory.InsertCode <ParsedProcedure>(), "Insert_new_procedure", "Alt+P"),
                new MenuItem(this, "Insert new function", ImageResources.Function, item => ProGenerateCode.Factory.InsertCode <ParsedImplementation>(), "Insert_new_function", "Alt+F"),
                new MenuItem(true), // --------------------------
                new MenuItem(this, "Delete existing internal procedure", ImageResources.DeleteProcedure, item => ProGenerateCode.Factory.DeleteCode <ParsedProcedure>(), "Delete_procedure", ""),
                new MenuItem(this, "Delete existing function", ImageResources.DeleteFunction, item => ProGenerateCode.Factory.DeleteCode <ParsedImplementation>(), "Delete_function", ""),
                new MenuItem(true), // --------------------------
                new MenuItem(this, "Synchronize function prototypes", ImageResources.Synchronize, item => ProGenerateCode.Factory.UpdateFunctionPrototypesIfNeeded(), "Synchronize_prototypes", "Alt+S")
            };

            #endregion

            #region Edit code

            _editCodeList = new List <MenuItem> {
                new MenuItem(this, "Display parser errors", ImageResources.DisplayParserResults, item => ProCodeFormat.DisplayParserErrors(), "Check_parser_errors", null),
                new MenuItem(this, "Toggle comment line", ImageResources.ToggleComment, item => ProMisc.ToggleComment(), "Toggle_Comment", "Ctrl+Q"),
                new MenuItem(this, "Correct indentation (selection or all)", ImageResources.IndentCode, item => ProCodeFormat.CorrectCodeIndentation(), "Reindent_document", "Ctrl+I")
                //new MenuItem(this, "Format document", ImageResources.FormatCode, CodeBeautifier.CorrectCodeIndentation, "Format_document", "Ctrl+I"),
            };

            #endregion

            #region Misc

            _modificationTagMenuList = new List <MenuItem> {
                new MenuItem(this, "Edit current file info", ImageResources.FileInfo, item => Appli.Appli.GoToPage(PageNames.FileInfo), "Edit_file_info", "Ctrl+Shift+M"),
                new MenuItem(this, "Insert title block", ImageResources.TitleBlock, item => ModificationTag.AddTitleBlockAtCaret(), "Insert_title_block", "Ctrl+Alt+M"),
                new MenuItem(this, "Surround with modification tags", ImageResources.ModificationTag, item => ModificationTag.SurroundSelectionWithTag(), "Modif_tags", "Ctrl+M")
                //new MenuItem(this, "Insert mark", ImageResources.InsertMark, null, "Insert_mark", "Ctrl+T"),
            };

            #endregion

            #region database tools

            _databaseTools = new List <MenuItem> {
                new MenuItem(this, "Open data administration", ImageResources.DataAdmin, item => ProMisc.OpenDbAdmin(), "Data_admin", "")
                {
                    Generic = true
                },
                new MenuItem(this, "Open progress dictionary", ImageResources.Dictionary, item => ProMisc.OpenDictionary(), "Data_dictionary", "")
                {
                    Generic = true
                },
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "Explore and modify your data", ImageResources.DataDigger, item => ProMisc.OpenDataDigger(), "Data_digger", "")
                {
                    Generic = true
                },
                new MenuItem(this, "Explore (read-only) your data", ImageResources.DataReader, item => ProMisc.OpenDataReader(), "Data_reader", "")
                {
                    Generic = true
                }
            };

            #endregion

            #region Main menu

            var goToDefItem = new MenuItem(this, "Go to definition", ImageResources.GoToDefinition, item => ProMisc.GoToDefinition(false), "Go_To_Definition", "Ctrl+B")
            {
                Generic = true
            };
            goToDefItem.SubText = "Middle click  /  " + goToDefItem.SubText;
            var goToPreviousJump = new MenuItem(this, "Go to previous jump point", ImageResources.GoBackward, item => Npp.GoBackFromDefinition(), "Go_Backwards", "Ctrl+Shift+B")
            {
                Generic = true
            };
            goToPreviousJump.SubText = "Ctrl + Middle click  /  " + goToPreviousJump.SubText;

            MainMenuList = new List <MenuItem> {
                new MenuItem(this, "Show main window", ImageResources.MainWindow, item => Appli.Appli.ToggleView(), "Open_main_window", "Alt+Space")
                {
                    Generic = true
                },
                new MenuItem(this, "Show autocompletion at caret", ImageResources.Autocompletion, item => AutoCompletion.OnShowCompleteSuggestionList(), "Show_Suggestion_List", "Ctrl+Space")
                {
                    Generic = true
                },
                new MenuItem(this, "Toggle current file as progress", ImageResources.Progress, item => ProMisc.ReadCurrentFileAsProgress(), "Read_as_progress", null)
                {
                    Generic = true
                },
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "Open 4GL help", ImageResources.ProgressHelp, item => ProMisc.Open4GlHelp(), "Open_4GL_help", "F1")
                {
                    Generic = true
                },
                new MenuItem(this, "Check syntax", ImageResources.CheckCode, item => ProMisc.StartProgressExec(ExecutionType.CheckSyntax), "Check_syntax", "Shift+F1"),
                new MenuItem(this, "Run program", ImageResources.RunCode, item => ProMisc.StartProgressExec(ExecutionType.Run), "Run_program", "Ctrl+F1"),
                new MenuItem(this, "Compile", ImageResources.CompileCode, item => ProMisc.StartProgressExec(ExecutionType.Compile), "Compile", "Alt+F1"),
                new MenuItem(this, "Compile options", ImageResources.CompileOptions, item => ProMisc.OpenCompilationOptions(), "Compile_options", null),
                new MenuItem(this, "Progress tools", ImageResources.ProgressTools, item => ShowProgressToolsMenu(), "Progress_tools", "Alt+T")
                {
                    Generic  = true,
                    Children = _progressTools.Cast <FilteredTypeTreeListItem>().ToList()
                },
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "Start searching files", ImageResources.Search, item => FileExplorer.FileExplorer.Instance.StartSearch(), "Search_file", "Alt+Q")
                {
                    Generic = true
                },
                goToDefItem,
                goToPreviousJump,
                //new MenuItem(this, "New 4GL file", ImageResources.GenerateCode, ShowNewFileAtCursor, "New_file", "Ctrl+Shift+N") {
                //    Children = GenerateCodeMenuList.Select(item => (YamuiMenuItem)item).ToList(),
                //},
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "Switch environment", ImageResources.Env, item => ShowEnvMenu(), "Switch_env", "Ctrl+E")
                {
                    Generic = true
                },
                new MenuItem(this, "Database tools", ImageResources.DatabaseTools, item => ShowDatabaseToolsMenu(), "DatabaseTools", "Alt+D")
                {
                    Generic  = true,
                    Children = _databaseTools.Cast <FilteredTypeTreeListItem>().ToList()
                },
                new MenuItem(this, "Generate and revise code", ImageResources.GenerateCode, item => ShowGenerateCodeMenu(), "Generate_code", "Alt+Insert")
                {
                    Generic  = true,
                    Children = _generateCodeMenuList.Cast <FilteredTypeTreeListItem>().ToList()
                },
                new MenuItem(this, "Edit code", ImageResources.EditCode, item => ShowEditCodeMenu(), "Edit_code", "Alt+E")
                {
                    Generic  = true,
                    Children = _editCodeList.Cast <FilteredTypeTreeListItem>().ToList()
                },
                new MenuItem(this, "Modification tag", ImageResources.ModificationTagMenu, item => ShowMiscMenu(), "Modification_tag", "Alt+M")
                {
                    Generic  = true,
                    Children = _modificationTagMenuList.Cast <FilteredTypeTreeListItem>().ToList()
                },
                new MenuItem(true)
                {
                    Generic = true
                },                                   // --------------------------
                new MenuItem(this, "Options", ImageResources.ShowOptions, item => Appli.Appli.GoToPage(PageNames.OptionsGeneral), "Go_to_options", null)
                {
                    Generic = true
                }
            };

            #endregion

            #region special dev

            if (Config.IsDeveloper)
            {
                MainMenuList.Add(
                    new MenuItem(this, "Tests", ImageResources.Tests, null, null, null, new List <MenuItem> {
                    new MenuItem(this, "DebugTest1", ImageResources.TestTube, item => PlugDebug.DebugTest1(), "DebugTest1", "Ctrl+OemQuotes")
                    {
                        Generic = true
                    },
                    new MenuItem(this, "DebugTest2", ImageResources.TestTube, item => PlugDebug.DebugTest2(), "DebugTest2", "Alt+OemQuotes")
                    {
                        Generic = true
                    },
                    new MenuItem(this, "DebugTest3", ImageResources.TestTube, item => PlugDebug.DebugTest3(), "DebugTest3", "Shift+OemQuotes")
                    {
                        Generic = true
                    },
                    new MenuItem(this, "Parse current file", ImageResources.TestTube, item => PlugDebug.ParseCurrentFile(), "ParseCurrentFile", "")
                    {
                        Generic = false
                    },
                    new MenuItem(this, "GetCurrentFileParsedDebugfile", ImageResources.TestTube, item => PlugDebug.GetCurrentFileParsedDebugfile(), "GetCurrentFileParsedDebugfile", "")
                    {
                        Generic = false
                    },
                    new MenuItem(this, "Parse reference file", ImageResources.TestTube, item => PlugDebug.ParseReferenceFile(), "ParseReferenceFile", "")
                    {
                        Generic = true
                    },
                    new MenuItem(this, "Parse all files", ImageResources.TestTube, item => PlugDebug.ParseAllFiles(), "ParseAllFiles", "")
                    {
                        Generic = true
                    }
                })
                {
                    Generic = true
                });
            }

            #endregion
        }
Esempio n. 18
0
        /// <summary>
        /// Create the autocompletion list from the prefix entries ready for evaluation sorting and output
        /// </summary>
        /// <param name="allPrefixEntries"></param>
        /// <returns></returns>
        public virtual AutoCompletionList CreateAutoCompletionList(IEnumerable<BaseIndexEntry> allPrefixEntries, int defaultMinCutOff = 1)
        {
            // Min query log frequency to allow (heuristic optimisation)
            int minCutOff = defaultMinCutOff; // Absolute min cut-off - now 1, rather than 2

            if (allPrefixEntries.Count() > 500)
                minCutOff = 4;
            if (allPrefixEntries.Count() > 1000)
                minCutOff = 5;
            if (allPrefixEntries.Count() > 3000)
                minCutOff = 6;
            if (allPrefixEntries.Count() > 6000)
                minCutOff = 7;
            if (allPrefixEntries.Count() > 10000)
                minCutOff = 8;
            if (allPrefixEntries.Count() > 15000)
                minCutOff = 9;
            if (allPrefixEntries.Count() > 20000)
                minCutOff = 10;
            if (allPrefixEntries.Count() > 26000)
                minCutOff = 11;

            object listLock = new object();
            List<AutoCompletion> autoCompletions = new List<AutoCompletion>();

            ParallelOptions po = new ParallelOptions();
            po.MaxDegreeOfParallelism = 4;

            // Make parallel
            Parallel.ForEach(allPrefixEntries, po, indexEntry =>
            {
                if (indexEntry.QueryLogFrequency > minCutOff)
                {
                    AutoCompletion ac = new AutoCompletion(indexEntry.Query);
                    ac.RankingWeight = indexEntry.RankingWeight;
                    ac.IsWikiWeighted = indexEntry.IsWikiWeighted;

                    lock (listLock)
                        autoCompletions.Add(ac);
                }
            });

            return new AutoCompletionList(autoCompletions);
        }
Esempio n. 19
0
 /// <summary>
 /// Call this method to close all popup/autocompletion form and alike
 /// </summary>
 public static void ClosePopups()
 {
     AutoCompletion.Cloak();
     InfoToolTip.Cloak();
 }
Esempio n. 20
0
        /// <summary>
        /// This method allows the user to GOTO a word definition, if a tooltip is opened then it tries to
        /// go to the definition of the displayed word, otherwise it tries to find the declaration of the parsed word under the
        /// caret. At last, it tries to find a file in the propath
        /// </summary>
        public static void GoToDefinition(bool fromMouseClick)
        {
            // if a tooltip is opened, try to execute the "go to definition" of the tooltip first
            if (InfoToolTip.InfoToolTip.IsVisible)
            {
                if (!string.IsNullOrEmpty(InfoToolTip.InfoToolTip.GoToDefinitionFile))
                {
                    Npp.Goto(InfoToolTip.InfoToolTip.GoToDefinitionFile, InfoToolTip.InfoToolTip.GoToDefinitionPoint.X, InfoToolTip.InfoToolTip.GoToDefinitionPoint.Y);
                    InfoToolTip.InfoToolTip.Cloak();
                    return;
                }
                InfoToolTip.InfoToolTip.Cloak();
            }

            // try to go to the definition of the selected word
            var position = fromMouseClick ? Sci.GetPositionFromMouseLocation() : Sci.CurrentPosition;

            if (fromMouseClick && position <= 0)
            {
                return;
            }
            var curWord = Sci.GetWordAtPosition(position, AutoCompletion.CurrentLangAdditionalChars);

            if (string.IsNullOrEmpty(curWord))
            {
                return;
            }

            // match a word in the autocompletion? go to definition
            var listKeywords = AutoCompletion.FindInCompletionData(curWord, Sci.LineFromPosition(position));

            if (listKeywords != null)
            {
                var listItems = listKeywords.Where(item => item.FromParser && item.ParsedBaseItem is ParsedItem).ToList();
                if (listItems.Count > 0)
                {
                    // only one match, then go to the definition
                    if (listItems.Count == 1)
                    {
                        var pItem = listItems.First().ParsedBaseItem as ParsedItem;
                        if (pItem != null)
                        {
                            Npp.Goto(pItem.FilePath, pItem.Line, pItem.Column);
                            return;
                        }
                    }
                    if (listItems.Count > 1)
                    {
                        // otherwise, list the items and notify the user
                        var output = new StringBuilder(@"Found several matching items, please choose the correct one :<br>");
                        foreach (var cData in listItems)
                        {
                            var pItem = listItems.First().ParsedBaseItem as ParsedItem;
                            if (pItem != null)
                            {
                                output.Append("<div>" + (pItem.FilePath + "|" + pItem.Line + "|" + pItem.Column).ToHtmlLink("In " + Path.GetFileName(pItem.FilePath) + " (line " + pItem.Line + ")"));
                                cData.DoForEachFlag((s, flag) => { output.Append("<img style='padding-right: 0px; padding-left: 5px;' src='" + s + "' height='15px'>"); });
                                output.Append("</div>");
                            }
                        }
                        UserCommunication.NotifyUnique("GoToDefinition", output.ToString(), MessageImg.MsgQuestion, "Question", "Go to the definition", args => {
                            Utils.OpenPathClickHandler(null, args);
                            UserCommunication.CloseUniqueNotif("GoToDefinition");
                        }, 0, 500);
                        return;
                    }
                }
            }

            // last resort, try to find a matching file in the propath

            // if in a string, read the whole string

            // try to read all the . and \

            // first look in the propath
            var fullPaths = ProEnvironment.Current.FindFiles(curWord, Config.Instance.FilesPatternProgress.Replace("*", ""));

            if (fullPaths.Count > 0)
            {
                if (fullPaths.Count > 1)
                {
                    var output = new StringBuilder(@"Found several files matching this name, please choose the correct one :<br>");
                    foreach (var fullPath in fullPaths)
                    {
                        output.Append("<div>" + fullPath.ToHtmlLink() + "</div>");
                    }
                    UserCommunication.NotifyUnique("GoToDefinition", output.ToString(), MessageImg.MsgQuestion, "Question", "Open a file", args => {
                        Npp.Goto(args.Link);
                        UserCommunication.CloseUniqueNotif("GoToDefinition");
                        args.Handled = true;
                    }, 0, 500);
                }
                else
                {
                    Npp.Goto(fullPaths[0]);
                }
                return;
            }

            UserCommunication.Notify("Sorry, couldn't go to the definition of <b>" + curWord + "</b>", MessageImg.MsgInfo, "Information", "Failed to find an origin", 5);
        }
Esempio n. 21
0
        /// <summary>
        /// Called when the user switches tab document
        /// You can use Npp.CurrentFile and Npp.PreviousFile in this method
        /// </summary>
        public static void DoNppBufferActivated(bool initiating = false)
        {
            // Apply options to npp and scintilla depending if we are on a progress file or not
            ApplyOptionsForScintilla();

            // if the file has just been opened
            if (!_openedFileList.Contains(Npp.CurrentFileInfo.Path))
            {
                _openedFileList.Add(Npp.CurrentFileInfo.Path);

                // need to auto change encoding?
                if (Config.Instance.AutoSwitchEncodingTo != NppEncodingFormat._Automatic_default && !string.IsNullOrEmpty(Config.Instance.AutoSwitchEncodingForFilePatterns))
                {
                    if (Npp.CurrentFileInfo.Path.TestAgainstListOfPatterns(Config.Instance.AutoSwitchEncodingForFilePatterns))
                    {
                        NppMenuCmd cmd;
                        if (Enum.TryParse(((int)Config.Instance.AutoSwitchEncodingTo).ToString(), true, out cmd))
                        {
                            Npp.RunCommand(cmd);
                        }
                    }
                }
            }

            // activate show space for conf files / deactivate if coming from a conf file
            if (ShareExportConf.IsFileExportedConf(Npp.PreviousFileInfo.Path))
            {
                if (Sci.ViewWhitespace != WhitespaceMode.Invisible && !Sci.ViewEol)
                {
                    Sci.ViewWhitespace = _whitespaceMode;
                }
            }
            if (ShareExportConf.IsFileExportedConf(Npp.CurrentFileInfo.Path))
            {
                Sci.ViewWhitespace = WhitespaceMode.VisibleAlways;
            }

            // close popups..
            ClosePopups();

            if (initiating)
            {
                // make sure to use the ProEnvironment and colorize the error counter
                OpenedFilesInfo.UpdateFileStatus();
            }
            else
            {
                if (Config.Instance.CodeExplorerAutoHideOnNonProgressFile)
                {
                    CodeExplorer.Instance.Toggle(Npp.CurrentFileInfo.IsProgress);
                }
                if (Config.Instance.FileExplorerAutoHideOnNonProgressFile)
                {
                    FileExplorer.Instance.Toggle(Npp.CurrentFileInfo.IsProgress);
                }
            }

            // Update info on the current file
            OpenedFilesInfo.UpdateErrorsInScintilla();
            ProEnvironment.Current.ReComputeProPath();

            AutoCompletion.SetStaticItems();

            // Parse the document
            ParserHandler.ParseDocumentNow();

            // publish the event
            if (OnDocumentChangedEnd != null)
            {
                OnDocumentChangedEnd();
            }
        }
Esempio n. 22
0
        /// <summary>
        /// Defined Temptables
        /// </summary>
        public void Visit(ParsedTable pars)
        {
            if (!string.IsNullOrEmpty(pars.TempLikeTable))
            {
                pars.LikeTable = FindAnyTableByName(pars.TempLikeTable);
            }

            foreach (var field in pars.Fields)
            {
                field.PrimitiveType = ConvertStringToParsedPrimitiveType(field.TempPrimitiveType, field.AsLike == ParsedAsLike.Like);
            }

            // temp table is LIKE another table? copy fields
            if (pars.LikeTable != null)
            {
                // add the fields of the found table (minus the primary information)
                foreach (var field in pars.LikeTable.Fields)
                {
                    pars.Fields.Add(
                        new ParsedField(field.Name, field.TempPrimitiveType, field.Format, field.Order, 0, field.InitialValue, field.Description, field.AsLike)
                    {
                        PrimitiveType = field.PrimitiveType
                    });
                }

                // handles the use-index
                if (!string.IsNullOrEmpty(pars.UseIndex))
                {
                    // add only the indexes that are used
                    foreach (var index in pars.UseIndex.Split(','))
                    {
                        var foundIndex = pars.LikeTable.Indexes.Find(index2 => index2.Name.EqualsCi(index.Replace("!", "")));
                        if (foundIndex != null)
                        {
                            pars.Indexes.Add(new ParsedIndex(foundIndex.Name, foundIndex.Flag, foundIndex.FieldsList.ToList()));
                            // if one of the index used is marked as primary
                            if (index.ContainsFast("!"))
                            {
                                pars.Indexes.ForEach(parsedIndex => parsedIndex.Flag &= ~ParsedIndexFlag.Primary);
                                pars.Indexes.Last().Flag |= ParsedIndexFlag.Primary;
                            }
                        }
                    }
                }
                else
                {
                    // if there is no "use index" and we didn't define new indexes, the tt uses the same index as the original table
                    if (pars.Indexes == null || pars.Indexes.Count == 0)
                    {
                        pars.Indexes = pars.LikeTable.Indexes.ToList();
                    }
                }
            }

            // browse all the indexes and set the according flags to each field of the index
            foreach (var index in pars.Indexes)
            {
                foreach (var fieldName in index.FieldsList)
                {
                    var foundfield = pars.Fields.Find(field => field.Name.EqualsCi(fieldName.Substring(0, fieldName.Length - 1)));
                    if (foundfield != null)
                    {
                        if (index.Flag.HasFlag(ParsedIndexFlag.Primary))
                        {
                            foundfield.Flags |= ParseFlag.Primary;
                        }
                        foundfield.Flags |= ParseFlag.Index;
                    }
                }
            }


            string subStr = string.IsNullOrEmpty(pars.TempLikeTable) ? "" : (pars.LikeTable != null ? @"Like " + pars.LikeTable.Name : @"Like ??");

            // to auto completion
            var parsedTable = new TempTableCompletionItem {
                DisplayText    = pars.Name,
                Flags          = pars.Flags,
                SubText        = subStr,
                ChildSeparator = '.'
            };

            parsedTable.Children = pars.Fields.Select(field => {
                var curField            = CompletionItem.Factory.New(field.Flags.HasFlag(ParseFlag.Primary) ? CompletionType.FieldPk : CompletionType.Field);
                curField.DisplayText    = field.Name.ConvertCase(Config.Instance.AutoCompleteDatabaseWordCaseMode);
                curField.ParsedBaseItem = field;
                curField.FromParser     = true;
                curField.SubText        = field.PrimitiveType.ToString();
                curField.Ranking        = AutoCompletion.FindRankingOfParsedItem(field.Name);
                curField.Flags          = field.Flags & ~ParseFlag.Primary;
                curField.ParentItem     = parsedTable;
                return(curField);
            }).ToList();
            PushToAutoCompletion(parsedTable, pars);

            // to code explorer
            PushToCodeExplorer(
                GetExplorerListNode("Defined temp-tables", CodeExplorerIconType.DefinedTempTable),
                new TempTableCodeItem {
                DisplayText   = pars.Name,
                Flags         = pars.Flags,
                SubText       = subStr,
                DocumentOwner = pars.FilePath,
                GoToLine      = pars.Line,
                GoToColumn    = pars.Column
            });
        }
Esempio n. 23
0
        public static bool MouseMessageHandler(WinApi.Messages message, Win32Api.MOUSEHOOKSTRUCT mouseStruct)
        {
            switch (message)
            {
            // middle click : go to definition
            case WinApi.Messages.WM_MBUTTONDOWN:
                if (Npp.CurrentFileInfo.IsProgress)
                {
                    if (KeyboardMonitor.GetModifiers.IsCtrl)
                    {
                        Npp.GoBackFromDefinition();
                    }
                    else
                    {
                        ProMisc.GoToDefinition(true);
                    }
                }
                return(true);

            //break;
            // (CTRL + ) Right click : show main menu
            case WinApi.Messages.WM_RBUTTONUP:
                if (KeyboardMonitor.GetModifiers.IsCtrl)
                {
                    // we need the cursor to be in scintilla but not on the application or the autocompletion!
                    if ((!Appli.IsVisible || !Appli.IsMouseIn()) &&
                        (!InfoToolTip.IsVisible || !InfoToolTip.IsMouseIn()) &&
                        (!AutoCompletion.IsVisible || !AutoCompletion.IsMouseIn()))
                    {
                        AppliMenu.ShowMainMenu(true);
                        return(true);
                    }
                }
                break;
            }

            // HACK: The following is to handle the MOVE/RESIZE event of npp's window.
            // It would be cleaner to use a WndProc bypass but it costs too much... this is a cheaper solution
            switch (message)
            {
            case WinApi.Messages.WM_NCLBUTTONDOWN:
                if (!WinApi.GetWindowRect(Npp.CurrentSci.Handle).Contains(Cursor.Position))
                {
                    MouseMonitor.Instance.Add(WinApi.Messages.WM_MOUSEMOVE);
                }
                break;

            case WinApi.Messages.WM_LBUTTONUP:
            case WinApi.Messages.WM_NCLBUTTONUP:
                if (MouseMonitor.Instance.Remove(WinApi.Messages.WM_MOUSEMOVE))
                {
                    if (OnNppWindowsMove != null)
                    {
                        OnNppWindowsMove();
                    }
                }
                break;

            case WinApi.Messages.WM_MOUSEMOVE:
                if (OnNppWindowsMove != null)
                {
                    OnNppWindowsMove();
                }
                break;
            }

            return(false);
        }
Esempio n. 24
0
        public override AutoCompletionList CreateAutoCompletionList(IEnumerable<BaseIndexEntry> allPrefixEntries, int defaultMinCutOff = 1)
        {
            // Min query log frequency to allow (heuristic optimisation)
            double minCutOff = minProbability; // Absolute min cut-off - now 1, rather than 2

            /*if (allPrefixEntries.Count() > 500)
                minCutOff = 4;
            if (allPrefixEntries.Count() > 1000)
                minCutOff = 5;
            if (allPrefixEntries.Count() > 3000)
                minCutOff = 6;
            if (allPrefixEntries.Count() > 6000)
                minCutOff = 7;
            if (allPrefixEntries.Count() > 10000)
                minCutOff = 8;
            if (allPrefixEntries.Count() > 15000)
                minCutOff = 9;
            if (allPrefixEntries.Count() > 20000)
                minCutOff = 10;
            if (allPrefixEntries.Count() > 26000)
                minCutOff = 11;
            */

            object listLock = new object();
            List<AutoCompletion> autoCompletions = new List<AutoCompletion>();

            ParallelOptions po = new ParallelOptions();
            po.MaxDegreeOfParallelism = 4;

            // Make parallel
            Parallel.ForEach(allPrefixEntries, po, indexEntry =>
            {
                if (indexEntry.QueryLogFrequency > minCutOff)
                {
                    AutoCompletion ac = new AutoCompletion(indexEntry.Query);
                    ac.RankingWeight = 2 + indexEntry.RankingWeight; // Will either be the NTB count or predicted likelihood

                    lock (listLock)
                        autoCompletions.Add(ac);
                }
            });

            return new AutoCompletionList(autoCompletions);
        }