示例#1
0
        public IEnumerable <QuickFix> CodeCheck(Request request)
        {
            var errors = new List <QuickFix>();

            var syntaxErrors =
                _syntaxErrorsHandler.FindSyntaxErrors(request)
                .Errors.Select(
                    x => new QuickFix {
                FileName  = x.FileName,
                Column    = x.Column,
                Line      = x.Line,
                EndColumn = x.EndColumn,
                EndLine   = x.EndLine,
                Text      = x.Message,
                LogLevel  = "Error"
            });

            errors.AddRange(syntaxErrors);

            if (errors.Any())
            {
                return(errors);
            }

            var semanticErrors =
                _semanticErrorsHandler.FindSemanticErrors(request)
                .Errors.Select(
                    x => new QuickFix {
                Column   = x.Column,
                FileName = x.FileName,
                Line     = x.Line,
                Text     = x.Message,
                LogLevel = "Error"
            });

            errors.AddRange(semanticErrors);

            if (errors.Any())
            {
                return(errors);
            }

            var codeErrors = _codeIssuesHandler.GetCodeIssues(request).QuickFixes;

            errors.AddRange(codeErrors);

            return(errors);
        }
示例#2
0
        private static Error[] GetErrors(string editorText)
        {
            var fileName = "test.cs";
            var solution = new FakeSolution();
            var project  = new FakeProject();

            project.AddFile(editorText, fileName);
            solution.Projects.Add(project);

            var handler = new SemanticErrorsHandler(solution);
            var request = new Request
            {
                Buffer   = editorText,
                FileName = fileName,
            };
            var semanticErrorsResponse = handler.FindSemanticErrors(request);

            return(semanticErrorsResponse.Errors.ToArray());
        }