Beispiel #1
0
        private static IList <AbstractHead> CreateSimpleHeads(string patternPart, char?invalidWildgetCharacter
                                                              )
        {
            IList <AbstractHead> heads = new AList <AbstractHead>(patternPart.Length);

            for (int i = 0; i < patternPart.Length; i++)
            {
                char c = patternPart[i];
                switch (c)
                {
                case '*':
                {
                    AbstractHead head = CreateWildCardHead(invalidWildgetCharacter, true);
                    heads.AddItem(head);
                    break;
                }

                case '?':
                {
                    AbstractHead head = CreateWildCardHead(invalidWildgetCharacter, false);
                    heads.AddItem(head);
                    break;
                }

                default:
                {
                    CharacterHead head_1 = new CharacterHead(c);
                    heads.AddItem(head_1);
                    break;
                }
                }
            }
            return(heads);
        }
Beispiel #2
0
        /// <exception cref="NGit.Errors.InvalidPatternException"></exception>
        private static IList <Head> CreateHeadsStartValues(string patternString, char?invalidWildgetCharacter
                                                           )
        {
            IList <AbstractHead> allHeads            = ParseHeads(patternString, invalidWildgetCharacter);
            IList <Head>         nextHeadsSuggestion = new AList <Head>(2);

            nextHeadsSuggestion.AddItem(LastHead.INSTANCE);
            for (int i = allHeads.Count - 1; i >= 0; i--)
            {
                AbstractHead head = allHeads[i];
                // explanation:
                // a and * of the pattern "a*b"
                // need *b as newHeads
                // that's why * extends the list for it self and it's left neighbor.
                if (head.IsStar())
                {
                    nextHeadsSuggestion.AddItem(head);
                    head.SetNewHeads(nextHeadsSuggestion);
                }
                else
                {
                    head.SetNewHeads(nextHeadsSuggestion);
                    nextHeadsSuggestion = new AList <Head>(2);
                    nextHeadsSuggestion.AddItem(head);
                }
            }
            return(nextHeadsSuggestion);
        }