Пример #1
0
        private void CreateWarningsForUnknownSteps(string path, AuthoringSink sink, ParseTree parseTree, Source source)
        {
            var warningCreator = new WarningCreator
                                     {
                                         Grammar = GherkinGrammar,
                                         Root = parseTree.Root,
                                         Source = source,
                                         StepProvider = _stepProvider
                                     };
            warningCreator.CreateSpansForUndefinedSteps();

            foreach (var textSpan in warningCreator.Result)
                sink.AddError(path, "Step not (yet) defined.", textSpan, Severity.Warning);
        }
Пример #2
0
        private void AddMessages(Source source, AuthoringSink sink, ParseTree parseTree)
        {
            var messages = parseTree.ParserMessages;
            foreach (var message in messages)
            {
                var line = source.GetLine(message.Location.Line);
                var nextSpace = line.Length;

                if (line.Length > message.Location.Column)
                    nextSpace = line.IndexOfAny(" \t\n\r".ToCharArray(), message.Location.Column + 1);

                if (nextSpace == -1)
                    nextSpace = line.Length;

                var span = new TextSpan
                                {
                                    iStartLine = message.Location.Line,
                                    iStartIndex = message.Location.Column,
                                    iEndLine = message.Location.Line,
                                    iEndIndex = nextSpace
                                };

                var severity = Severity.Hint;
                switch (message.Level)
                {
                    case ParserErrorLevel.Info:
                        severity = Severity.Hint;
                        break;

                    case ParserErrorLevel.Warning:
                        severity = Severity.Warning;
                        break;

                    case ParserErrorLevel.Error:
                        severity = Severity.Error;
                        break;
                }
                sink.AddError(source.GetFilePath(), message.Message, span, severity);
            }
        }