Exemplo n.º 1
0
        protected int CompareMatches(PatternMatch match1, PatternMatch match2, CompletionItem item1, CompletionItem item2)
        {
            int diff;

            diff = PatternMatch.CompareType(match1, match2);
            if (diff != 0)
            {
                return(diff);
            }

            diff = PatternMatch.CompareCamelCase(match1, match2);
            if (diff != 0)
            {
                return(diff);
            }

            // argument names are not prefered
            if (IsArgumentName(item1) && !IsArgumentName(item2))
            {
                return(1);
            }
            else if (IsArgumentName(item2) && !IsArgumentName(item1))
            {
                return(-1);
            }

            // preselected items are prefered
            if (item1.Rules.Preselect && !item2.Rules.Preselect)
            {
                return(-1);
            }
            else if (item2.Rules.Preselect && !item1.Rules.Preselect)
            {
                return(1);
            }

            diff = PatternMatch.CompareCase(match1, match2);
            if (diff != 0)
            {
                return(diff);
            }

            diff = PatternMatch.ComparePunctuation(match1, match2);
            if (diff != 0)
            {
                return(diff);
            }

            return(0);
        }