예제 #1
0
        public RegularExpressionScanner(CultureInfo defaultLanguage)
        {
            var            dialectServices = new GherkinDialectServices(defaultLanguage);
            GherkinDialect gherkinDialect  = dialectServices.GetDefaultDialect();

            patternTable = gherkinDialect.GetKeywords().ToList().ConvertAll(x => new Regex(Regex.Escape(x))).ToArray();
        }
예제 #2
0
        static internal bool IsKeywordPrefix(SnapshotPoint triggerPoint, GherkinLanguageService languageService)
        {
            var           line  = triggerPoint.GetContainingLine();
            SnapshotPoint start = line.Start;

            ForwardWhile(ref start, triggerPoint, p => char.IsWhiteSpace(p.GetChar()));
            SnapshotPoint end = start;

            ForwardWhile(ref end, triggerPoint, p => !char.IsWhiteSpace(p.GetChar()));
            if (start >= end)
            {
                return(true); // returns true for empty word
            }
            end = triggerPoint;
//            if (end < triggerPoint)
//                return false;

            var            firstWord = triggerPoint.Snapshot.GetText(start, end.Position - start);
            GherkinDialect dialect   = GetDialect(languageService);

            return(dialect.GetKeywords().Any(k => k.StartsWith(firstWord, StringComparison.CurrentCultureIgnoreCase)));
        }