Exemplo n.º 1
0
 private OmniSharpRefactoringContext GetRefactoringContext(Request req)
 {
     var q = _bufferParser.ParsedContent(req.Buffer, req.FileName);
     var resolver = new CSharpAstResolver(q.Compilation, q.SyntaxTree, q.UnresolvedFile);
     var doc = new StringBuilderDocument(req.Buffer);
     var location = new TextLocation(req.Line, req.Column);
     var refactoringContext = new OmniSharpRefactoringContext(doc, location, resolver);
     return refactoringContext;
 }
Exemplo n.º 2
0
        private IEnumerable<CodeAction> GetContextualCodeActions(Request req)
        {
            var refactoringContext = GetRefactoringContext(req);

            var actions = new List<CodeAction>();
            var providers = new CodeActionProviders().GetProviders();
            foreach (var provider in providers)
            {
                var providerActions = provider.GetActions(refactoringContext);
                actions.AddRange(providerActions);
            }
            return actions;
        }
Exemplo n.º 3
0
        public SyntaxErrorsResponse FindSyntaxErrors(Request request)
        {
            var res = _bufferParser.ParsedContent(request.Buffer, request.FileName);

            var errors = res.SyntaxTree.Errors.Select(error => new Error
                {
                    Message = error.Message.Replace("'", "''"),
                    Column = error.Region.BeginColumn,
                    Line = error.Region.BeginLine,
                    FileName = request.FileName
                });

            return new SyntaxErrorsResponse {Errors = errors};
        }
Exemplo n.º 4
0
        public GetCodeActionsResponse GetCodeActions(Request req)
        {
            var actions = GetContextualCodeActions(req);

            return new GetCodeActionsResponse { CodeActions = actions.Select(a => a.Description) };
        }