Пример #1
0
 /// <summary>
 /// Update the current scope in the form
 /// </summary>
 private void UpdateCurrentScope(ParsedScopeItem currentScope)
 {
     if (currentScope != null)
     {
         Form.SafeInvoke(form => form.UpdateCurrentScope(currentScope.Name, Utils.GetImageFromStr(currentScope.ScopeType.ToString())));
     }
     else
     {
         Form.SafeInvoke(form => form.UpdateCurrentScope(@"Not applicable", ImageResources.NotApplicable));
     }
 }
Пример #2
0
        /// <summary>
        /// this methods sorts the items to put the best match on top and then filter it with modelFilter
        /// </summary>
        private void ApplyFilter()
        {
            Keyword.Width = _normalWidth - (Config.Instance.AutoCompleteHideScrollBar ? 0 : 17);

            // save position in the list
            var curPos = new Point(fastOLV.SelectedIndex, fastOLV.TopItemIndex);

            // apply filter to each item in the list then set the list
            try {
                _initialObjectsList.ForEach(data => data.FilterApply(_filterByText));
            } catch (Exception e) {
                if (!(e is NullReferenceException))
                {
                    ErrorHandler.LogError(e);
                }
            }
            if (String.IsNullOrEmpty(_filterByText))
            {
                fastOLV.SetObjects(_initialObjectsList);
            }
            else
            {
                fastOLV.SetObjects(_initialObjectsList.OrderBy(data => data.FilterDispertionLevel).ToList());
            }

            // apply the filter, need to match the filter + need to be an active type (Selector button activated)
            // + need to be in the right scope for variables
            _currentLineNumber = Npp.Line.CurrentLine;
            _currrentScope     = ParserHandler.GetScopeOfLine(_currentLineNumber);
            if (!Config.Instance.AutoCompleteOnlyShowDefinedVar)
            {
                _currentLineNumber = -1;
            }
            _useTypeFiltering   = true;
            _useTextFiltering   = true;
            fastOLV.ModelFilter = new ModelFilter(FilterPredicate);

            // update total items
            TotalItems   = ((ArrayList)fastOLV.FilteredObjects).Count;
            nbitems.Text = TotalItems + StrItems;

            if (TotalItems <= Config.Instance.AutoCompleteShowListOfXSuggestions)
            {
                Keyword.Width = _normalWidth;
            }

            // reposition the cursor in the list
            if (TotalItems > 0)
            {
                fastOLV.SelectedIndex = Math.Max(0, Math.Min(curPos.X, TotalItems - 1));
                fastOLV.TopItemIndex  = Math.Max(0, Math.Min(curPos.Y, TotalItems - 1));
            }
        }
Пример #3
0
 /// <summary>
 /// Check the parse scope has too much char to allow it to be displayed in the appbuilder
 /// </summary>
 /// <param name="pars"></param>
 private static bool CheckForTooMuchChar(ParsedScopeItem pars)
 {
     // check length of block
     if (!pars.Flags.HasFlag(ParseFlag.FromInclude))
     {
         pars.TooLongForAppbuilder = NbExtraCharBetweenLines(pars.Line, pars.EndBlockLine) > 0;
         if (pars.TooLongForAppbuilder)
         {
             return(true);
         }
     }
     return(false);
 }
Пример #4
0
 /// <summary>
 /// Applies the same sorting / filtering as the autocompletion form to a given list
 /// of items
 /// </summary>
 public static List <CompletionItem> ExternalFilterItems(List <CompletionItem> objectsList, int line, bool dontCheckLine = false)
 {
     objectsList.Sort(new CompletionDataSortingClass());
     if (_displayedTypes == null)
     {
         _displayedTypes = new Dictionary <CompletionType, SelectorButton <CompletionType> >();
     }
     _useTypeFiltering  = false;
     _useTextFiltering  = false;
     _currrentScope     = ParserHandler.GetScopeOfLine(line);
     _currentLineNumber = (!Config.Instance.AutoCompleteOnlyShowDefinedVar || dontCheckLine) ? -1 : line;
     return(objectsList.Where(FilterPredicate).ToList());
 }
Пример #5
0
 /// <summary>
 /// Should return true when the completion item survives the filter
 /// </summary>
 public virtual bool SurvivesFilter(int currentLine, ParsedScopeItem currentScope)
 {
     // check for scope
     if (ParsedBaseItem != null)
     {
         var parsedItem = ParsedBaseItem as ParsedItem;
         if (parsedItem != null && parsedItem.Scope != null && currentScope != null && !(parsedItem.Scope is ParsedFile))
         {
             // must be in the right scope!
             return(parsedItem.Scope.ScopeType == currentScope.ScopeType && parsedItem.Scope.Name.Equals(currentScope.Name));
         }
     }
     return(true);
 }
Пример #6
0
        public override bool SurvivesFilter(int currentLine, ParsedScopeItem currentScope)
        {
            var output = true;

            if (currentLine >= 0)
            {
                // if preproc, check line of definition and undefine
                output = currentLine >= (ParsedPreProcVariable.IncludeLine >= 0 ? ParsedPreProcVariable.IncludeLine : ParsedPreProcVariable.Line);
                if (ParsedPreProcVariable.UndefinedLine > 0)
                {
                    output = output && currentLine <= ParsedPreProcVariable.UndefinedLine;
                }
            }
            return(output);
        }
Пример #7
0
        public override bool SurvivesFilter(int currentLine, ParsedScopeItem currentScope)
        {
            // check for scope
            if (!base.SurvivesFilter(currentLine, currentScope))
            {
                return(false);
            }

            // check for the definition line
            if (currentLine >= 0)
            {
                return(currentLine >= (ParsedDefine.IncludeLine >= 0 ? ParsedDefine.IncludeLine : ParsedDefine.Line));
            }
            return(true);
        }
Пример #8
0
        /// <summary>
        /// Returns true if the conditions have changed
        /// </summary>
        public bool UpdateConditions(int currentLineNumber, bool checkLine = true)
        {
            if (currentLineNumber != _currentLineNumber)
            {
                _currentLineNumber = currentLineNumber;
                _currentScope      = ParserHandler.GetScopeOfLine(currentLineNumber);
                if (!checkLine || !Config.Instance.AutoCompleteOnlyShowDefinedVar)
                {
                    _currentLineNumber = -1;
                }
                return(true);
            }

            return(false);
        }
Пример #9
0
        public override bool SurvivesFilter(int currentLine, ParsedScopeItem currentScope)
        {
            // check for scope
            if (!base.SurvivesFilter(currentLine, currentScope))
            {
                return(false);
            }

            // check for the definition line
            var output = true;

            if (currentLine >= 0)
            {
                output = currentLine >= (ParsedLabel.IncludeLine >= 0 ? ParsedLabel.IncludeLine : ParsedLabel.Line);

                // for labels, only display them in the block which they label
                output = output && currentLine <= ParsedLabel.UndefinedLine;
            }
            return(output);
        }
Пример #10
0
 public override bool SurvivesFilter(int currentLine, ParsedScopeItem currentScope)
 {
     return(true);
 }