private CodeAnalysisError CreateAnalysisError(DslSyntaxException e)
        {
            var lineChr = new LineChr(e.FilePosition.BeginLine - 1, e.FilePosition.BeginColumn - 1);

            return(new CodeAnalysisError()
            {
                LineChr = lineChr, Message = e.Message
            });
        }
Example #2
0
        private CodeAnalysisError CreateAnalysisError(DslSyntaxException e)
        {
            var beginLineChr = new LineChr(e.FilePosition.BeginLine - 1, e.FilePosition.BeginColumn - 1);
            var endLineChr   = new LineChr(e.FilePosition.EndLine - 1, e.FilePosition.EndColumn - 1);

            return(new CodeAnalysisError()
            {
                BeginLineChr = beginLineChr, EndLineChr = endLineChr, Code = e.ErrorCode, Message = e.Message
            });
        }
Example #3
0
        /// <summary>
        /// Outputs error in canonical message format. This format can be recognized by MSBuild and reported in IDE with link directly to position in source file.
        /// See https://github.com/dotnet/msbuild/blob/master/src/Shared/CanonicalError.cs for more details.
        /// </summary>
        public static void PrintCanonicalError(DslSyntaxException dslException)
        {
            string origin         = dslException.FilePosition?.CanonicalOrigin ?? "Rhetos DSL";
            string canonicalError = $"{origin}: error {dslException.ErrorCode ?? "RH0000"}: {dslException.Message.Replace('\r', ' ').Replace('\n', ' ')}";

            var oldColor = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Red;
            Console.WriteLine(canonicalError);
            Console.ForegroundColor = oldColor;
        }
Example #4
0
        private static void DslParser_ErrorReporting(string dsl)
        {
            DslSyntaxException exception = null;

            try
            {
                DslParserParse(dsl);
            }
            catch (DslSyntaxException ex)
            {
                exception = ex;
            }

            Assert.IsNotNull(exception);
            Console.WriteLine("=============================");
            Console.WriteLine(exception.Message);
            Assert.IsTrue(exception.Message.Contains(MockDslScript.TestScriptName), "Error message should contain script name.");
        }