Пример #1
0
 public CodeFormatResponse Format(CodeFormatRequest request)
 {
     var options = _config.TextEditorOptions;
     var policy = _config.CSharpFormattingOptions;
     var formatter = new CSharpFormatter(policy, options);
     formatter.FormattingMode = FormattingMode.Intrusive;
     var output = formatter.Format(request.Buffer);
     return new CodeFormatResponse(output);
 }
Пример #2
0
        public CodeFormatResponse Format(CodeFormatRequest request)
        {
            var options   = _config.TextEditorOptions;
            var policy    = _config.CSharpFormattingOptions;
            var formatter = new CSharpFormatter(policy, options);

            formatter.FormattingMode = FormattingMode.Intrusive;
            var output = formatter.Format(request.Buffer);

            return(new CodeFormatResponse(output));
        }
Пример #3
0
 public CodeFormatResponse Format(CodeFormatRequest request)
 {
     var document = new StringBuilderDocument(request.Buffer);
     var options = new TextEditorOptions();
     options.EolMarker = Environment.NewLine;
     options.WrapLineLength = 80;
     options.TabsToSpaces = request.ExpandTab;
     var policy = FormattingOptionsFactory.CreateAllman();
     var visitor = new AstFormattingVisitor(policy, document, options);
     visitor.FormattingMode = FormattingMode.Intrusive;
     var syntaxTree = new CSharpParser().Parse(document, request.FileName);
     syntaxTree.AcceptVisitor(visitor);
     visitor.ApplyChanges();
     return new CodeFormatResponse(document.Text);
 }
Пример #4
0
        public CodeFormatResponse Format(CodeFormatRequest request)
        {
            var document = new StringBuilderDocument(request.Buffer);
            var options  = new TextEditorOptions();

            options.EolMarker      = Environment.NewLine;
            options.WrapLineLength = 80;
            options.TabsToSpaces   = request.ExpandTab;
            var policy  = FormattingOptionsFactory.CreateAllman();
            var visitor = new AstFormattingVisitor(policy, document, options);

            visitor.FormattingMode = FormattingMode.Intrusive;
            var syntaxTree = new CSharpParser().Parse(document, request.FileName);

            syntaxTree.AcceptVisitor(visitor);
            visitor.ApplyChanges();
            return(new CodeFormatResponse(document.Text));
        }