Beispiel #1
0
        private void ApplySpecialOperations(
            FormattingContext context, TokenStream tokenStream, NodeOperations nodeOperationsCollector, OperationApplier applier, CancellationToken cancellationToken)
        {
            // apply alignment operation
            using (Logger.LogBlock(FunctionId.Formatting_CollectAlignOperation, cancellationToken))
            {
                cancellationToken.ThrowIfCancellationRequested();

                // TODO : figure out a way to run alignment operations in parallel. probably find
                // unions and run each chunk in separate tasks
                var previousChangesMap  = new Dictionary <SyntaxToken, int>();
                var alignmentOperations = nodeOperationsCollector.AlignmentOperation;

                alignmentOperations.Do(operation =>
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    applier.ApplyAlignment(operation, previousChangesMap, cancellationToken);
                });

                // go through all relative indent block operation, and see whether it is affected by previous operations
                context.GetAllRelativeIndentBlockOperations().Do(o =>
                {
                    cancellationToken.ThrowIfCancellationRequested();
                    applier.ApplyBaseTokenIndentationChangesFromTo(FindCorrectBaseTokenOfRelativeIndentBlockOperation(o, tokenStream), o.StartToken, o.EndToken, previousChangesMap, cancellationToken);
                });
            }
        }
Beispiel #2
0
 private void BuildContext(
     FormattingContext context,
     TokenStream tokenStream,
     NodeOperations nodeOperations,
     CancellationToken cancellationToken)
 {
     // add scope operation (run each kind sequentially)
     using (Logger.LogBlock(FunctionId.Formatting_BuildContext, cancellationToken))
     {
         cancellationToken.ThrowIfCancellationRequested();
         context.AddIndentBlockOperations(nodeOperations.IndentBlockOperation, cancellationToken);
         context.AddSuppressOperations(nodeOperations.SuppressOperation, cancellationToken);
     }
 }
Beispiel #3
0
        private void ApplyTokenOperations(
            FormattingContext context,
            TokenStream tokenStream,
            NodeOperations nodeOperations,
            TokenPairWithOperations[] tokenOperations,
            CancellationToken cancellationToken)
        {
            var applier = new OperationApplier(context, tokenStream, _formattingRules);

            ApplySpaceAndWrappingOperations(context, tokenStream, tokenOperations, applier, cancellationToken);

            ApplyAnchorOperations(context, tokenStream, tokenOperations, applier, cancellationToken);

            ApplySpecialOperations(context, tokenStream, nodeOperations, applier, cancellationToken);
        }