Пример #1
0
        public FormattingContext(AbstractFormatEngine engine, TokenStream tokenStream, string language)
        {
            Contract.ThrowIfNull(engine);
            Contract.ThrowIfNull(tokenStream);

            _engine = engine;
            _tokenStream = tokenStream;
            _language = language;

            _relativeIndentationTree = new ContextIntervalTree<RelativeIndentationData>(this);

            _indentationTree = new ContextIntervalTree<IndentationData>(this);
            _suppressWrappingTree = new ContextIntervalTree<SuppressWrappingData>(SuppressIntervalIntrospector.Instance);
            _suppressSpacingTree = new ContextIntervalTree<SuppressSpacingData>(SuppressIntervalIntrospector.Instance);
            _anchorTree = new ContextIntervalTree<AnchorData>(this);

            _anchorBaseTokenMap = new Dictionary<SyntaxToken, AnchorData>();

            _indentationMap = new HashSet<TextSpan>();
            _suppressWrappingMap = new HashSet<TextSpan>();
            _suppressSpacingMap = new HashSet<TextSpan>();
            _anchorMap = new HashSet<TextSpan>();

            _initialIndentBlockOperations = new List<IndentBlockOperation>();
        }
            public Partitioner(FormattingContext context, TokenStream tokenStream, TokenPairWithOperations[] operationPairs)
            {
                Contract.ThrowIfNull(context);
                Contract.ThrowIfNull(tokenStream);
                Contract.ThrowIfNull(operationPairs);

                _context = context;
                _tokenStream = tokenStream;
                _operationPairs = operationPairs;
            }
        public BottomUpBaseIndentationFinder(
            ChainedFormattingRules formattingRules,
            int tabSize,
            int indentationSize,
            TokenStream tokenStream)
        {
            Contract.ThrowIfNull(formattingRules);

            _formattingRules = formattingRules;
            _tabSize = tabSize;
            _indentationSize = indentationSize;
            _tokenStream = tokenStream;
        }
            public InitialContextFinder(
                TokenStream tokenStream,
                ChainedFormattingRules formattingRules,
                SyntaxNode rootNode)
            {
                Contract.ThrowIfNull(tokenStream);
                Contract.ThrowIfNull(formattingRules);
                Contract.ThrowIfNull(rootNode);

                this.tokenStream = tokenStream;
                this.formattingRules = formattingRules;
                this.rootNode = rootNode;
            }
Пример #5
0
        internal AbstractFormattingResult(
            TreeData treeInfo,
            TokenStream tokenStream,
            TextSpan formattedSpan,
            TaskExecutor taskExecutor)
        {
            this.TreeInfo = treeInfo;
            this.TokenStream = tokenStream;
            this.FormattedSpan = formattedSpan;
            this.TaskExecutor = taskExecutor;

            _lazyChanges = new CancellableLazy<IList<TextChange>>(CreateTextChanges);
            _lazyNode = new CancellableLazy<SyntaxNode>(CreateFormattedRoot);
        }
            public InitialContextFinder(
                TokenStream tokenStream,
                ChainedFormattingRules formattingRules,
                SyntaxNode rootNode,
                SyntaxToken lastToken)
            {
                Contract.ThrowIfNull(tokenStream);
                Contract.ThrowIfNull(formattingRules);
                Contract.ThrowIfNull(rootNode);

                _tokenStream = tokenStream;
                _formattingRules = formattingRules;
                _rootNode = rootNode;
                _lastToken = lastToken;
            }
Пример #7
0
        public TokenPairWithOperations(
            TokenStream tokenStream,
            int tokenPairIndex,
            AdjustSpacesOperation spaceOperations,
            AdjustNewLinesOperation lineOperations) :
            this()
        {
            Contract.ThrowIfNull(tokenStream);

            Contract.ThrowIfFalse(0 <= tokenPairIndex && tokenPairIndex < tokenStream.TokenCount - 1);

            this.tokenStream = tokenStream;
            this.PairIndex = tokenPairIndex;

            SpaceOperation = spaceOperations;
            LineOperation = lineOperations;
        }
 public OperationApplier(FormattingContext context, TokenStream tokenStream, ChainedFormattingRules formattingRules)
 {
     this.context = context;
     this.tokenStream = tokenStream;
     this.formattingRules = formattingRules;
 }
Пример #9
0
 internal FormattingResult(TreeData treeInfo, TokenStream tokenStream, TextSpan spanToFormat, TaskExecutor taskExecutor) :
     base(treeInfo, tokenStream, spanToFormat, taskExecutor)
 {
 }
 public OperationApplier(FormattingContext context, TokenStream tokenStream, ChainedFormattingRules formattingRules)
 {
     _context = context;
     _tokenStream = tokenStream;
     _formattingRules = formattingRules;
 }
 protected override AbstractFormattingResult CreateFormattingResult(TokenStream tokenStream)
 {
     return new FormattingResult(this.TreeData, tokenStream, this.SpanToFormat, this.TaskExecutor);
 }
 protected override FormattingContext CreateFormattingContext(TokenStream tokenStream, CancellationToken cancellationToken)
 {
     return new FormattingContext(this, tokenStream, LanguageNames.CSharp);
 }