Exemplo n.º 1
0
        /// <summary>
        /// Get current Gherkin language setting by scanning first 5 lines
        /// </summary>
        /// <param name="document"></param>
        /// <returns>language defined in tag or English as default language</returns>
        public static string CurrentLanguage(ICSharpCode.AvalonEdit.Document.TextDocument document)
        {
            var location = new Ast.Location();

            ICSharpCode.AvalonEdit.Document.DocumentLine line = document.GetLineByNumber(1);
            while (line != null)
            {
                string line_text = document.GetText(line.Offset, line.TotalLength);
                Token  token     = new Token(new GherkinLine(line_text, line.LineNumber), location);
                try
                {
                    if (s_TokenMatcher.Match_Language(token) && IsSupported(token.MatchedText))
                    {
                        return(token.MatchedText);
                    }
                    if (line.LineNumber > 5)
                    {
                        return(DEFAULT_LANGUAGE);
                    }
                    line = line.NextLine;
                }
                catch
                {
                    return(DEFAULT_LANGUAGE);
                }
            }
            return(DEFAULT_LANGUAGE);
        }
Exemplo n.º 2
0
 private bool SimpleMatchLanguage(Token token)
 {
     try
     {
         if (TokenMatcher.Match_Language(token))
         {
             return(true);
         }
         return(false);
     }
     catch (Exception)
     {
         return(false);
     }
 }
Exemplo n.º 3
0
        private void TryUpdateLanguage(string line)
        {
            Token token = ToToken(line);

            try
            {
                if (TokenMatcher.Match_Language(token))
                {
                    NotifyCurrentGherkinLanguage(token.MatchedText);
                }
            }
            catch (Exception ex)
            {
                EventAggregator <StatusChangedArg> .Instance.Publish(this, new StatusChangedArg(ex.Message));
            }
        }