public Indenter(
                AbstractIndentationService <TSyntaxRoot> service,
                SyntacticDocument document,
                IEnumerable <AbstractFormattingRule> rules,
                OptionSet optionSet,
                TextLine lineToBeIndented,
                CancellationToken cancellationToken)
            {
                Document = document;

                this._service          = service;
                this._syntaxFacts      = document.Document.GetLanguageService <ISyntaxFactsService>();
                this.OptionSet         = optionSet;
                this.Root              = (TSyntaxRoot)document.Root;
                this.LineToBeIndented  = lineToBeIndented;
                this._tabSize          = this.OptionSet.GetOption(FormattingOptions.TabSize, Root.Language);
                this.CancellationToken = cancellationToken;

                this.Rules  = rules;
                this.Finder = new BottomUpBaseIndentationFinder(
                    new ChainedFormattingRules(this.Rules, OptionSet),
                    this._tabSize,
                    this.OptionSet.GetOption(FormattingOptions.IndentationSize, Root.Language),
                    tokenStream: null);
            }
            public Indenter(
                AbstractIndentationService <TSyntaxRoot> service,
                SyntacticDocument document,
                IEnumerable <AbstractFormattingRule> rules,
                OptionSet optionSet,
                TextLine lineToBeIndented,
                CancellationToken cancellationToken)
            {
                Document = document;

                _service          = service;
                _syntaxFacts      = document.Document.GetRequiredLanguageService <ISyntaxFactsService>();
                OptionSet         = optionSet;
                OptionService     = document.Document.Project.Solution.Workspace.Services.GetRequiredService <IOptionService>();
                Root              = (TSyntaxRoot)document.Root;
                LineToBeIndented  = lineToBeIndented;
                _tabSize          = this.OptionSet.GetOption(FormattingOptions.TabSize, Root.Language);
                CancellationToken = cancellationToken;

                Rules  = rules;
                Finder = new BottomUpBaseIndentationFinder(
                    new ChainedFormattingRules(this.Rules, OptionSet.AsAnalyzerConfigOptions(OptionService, Root.Language)),
                    _tabSize,
                    this.OptionSet.GetOption(FormattingOptions.IndentationSize, Root.Language),
                    tokenStream: null,
                    _syntaxFacts);
            }
Esempio n. 3
0
            public Indenter(
                AbstractIndentation <TSyntaxRoot> service,
                SyntaxTree tree,
                ImmutableArray <AbstractFormattingRule> rules,
                IndentationOptions options,
                TextLine lineToBeIndented,
                ISmartTokenFormatter smartTokenFormatter,
                CancellationToken cancellationToken)
            {
                _service            = service;
                _syntaxFacts        = service.SyntaxFacts;
                Options             = options;
                Tree                = tree;
                Text                = tree.GetText(cancellationToken);
                Root                = (TSyntaxRoot)tree.GetRoot(cancellationToken);
                LineToBeIndented    = lineToBeIndented;
                _tabSize            = options.FormattingOptions.TabSize;
                SmartTokenFormatter = smartTokenFormatter;
                CancellationToken   = cancellationToken;

                Rules  = rules;
                Finder = new BottomUpBaseIndentationFinder(
                    new ChainedFormattingRules(this.Rules, options.FormattingOptions),
                    _tabSize,
                    options.FormattingOptions.IndentationSize,
                    tokenStream: null,
                    service.HeaderFacts);
            }
Esempio n. 4
0
            public AbstractIndenter(
                ISyntaxFactsService syntaxFacts,
                SyntaxTree syntaxTree,
                IEnumerable <IFormattingRule> rules,
                OptionSet optionSet,
                TextLine lineToBeIndented,
                CancellationToken cancellationToken)
            {
                var syntaxRoot = syntaxTree.GetRoot(cancellationToken);

                this._syntaxFacts      = syntaxFacts;
                this.OptionSet         = optionSet;
                this.Tree              = syntaxTree;
                this.LineToBeIndented  = lineToBeIndented;
                this.TabSize           = this.OptionSet.GetOption(FormattingOptions.TabSize, syntaxRoot.Language);
                this.CancellationToken = cancellationToken;

                this.Rules  = rules;
                this.Finder = new BottomUpBaseIndentationFinder(
                    new ChainedFormattingRules(this.Rules, OptionSet),
                    this.TabSize,
                    this.OptionSet.GetOption(FormattingOptions.IndentationSize, syntaxRoot.Language),
                    tokenStream: null,
                    lastToken: default(SyntaxToken));
            }
Esempio n. 5
0
            public Indenter(
                AbstractIndentationService <TSyntaxRoot> service,
                SyntacticDocument document,
                IEnumerable <AbstractFormattingRule> rules,
                IndentationOptions options,
                TextLine lineToBeIndented,
                CancellationToken cancellationToken)
            {
                Document = document;

                _service          = service;
                _syntaxFacts      = document.Document.GetRequiredLanguageService <ISyntaxFactsService>();
                Options           = options;
                Root              = (TSyntaxRoot)document.Root;
                LineToBeIndented  = lineToBeIndented;
                _tabSize          = options.FormattingOptions.TabSize;
                CancellationToken = cancellationToken;

                Rules  = rules;
                Finder = new BottomUpBaseIndentationFinder(
                    new ChainedFormattingRules(this.Rules, options.FormattingOptions),
                    _tabSize,
                    options.FormattingOptions.IndentationSize,
                    tokenStream: null,
                    document.Document.GetRequiredLanguageService <IHeaderFactsService>());
            }
            public AbstractIndenter(Document document, IEnumerable <IFormattingRule> rules, OptionSet optionSet, ITextSnapshotLine lineToBeIndented, CancellationToken cancellationToken)
            {
                this.OptionSet         = optionSet;
                this.Document          = SyntacticDocument.CreateAsync(document, cancellationToken).WaitAndGetResult(cancellationToken);
                this.LineToBeIndented  = lineToBeIndented;
                this.TabSize           = this.OptionSet.GetOption(FormattingOptions.TabSize, this.Document.Root.Language);
                this.CancellationToken = cancellationToken;

                this.Rules  = rules;
                this.Tree   = this.Document.SyntaxTree;
                this.Finder = new BottomUpBaseIndentationFinder(
                    new ChainedFormattingRules(this.Rules, OptionSet),
                    this.TabSize,
                    this.OptionSet.GetOption(FormattingOptions.IndentationSize, this.Document.Root.Language),
                    tokenStream: null);
            }
Esempio n. 7
0
            public AbstractIndenter(
                SyntacticDocument document,
                IEnumerable <IFormattingRule> rules,
                OptionSet optionSet,
                TextLine lineToBeIndented,
                CancellationToken cancellationToken)
            {
                this.OptionSet         = optionSet;
                this.Document          = document;
                this.LineToBeIndented  = lineToBeIndented;
                this.TabSize           = this.OptionSet.GetOption(FormattingOptions.TabSize, this.Document.Root.Language);
                this.CancellationToken = cancellationToken;

                this.Rules  = rules;
                this.Tree   = this.Document.SyntaxTree;
                this.Finder = new BottomUpBaseIndentationFinder(
                    new ChainedFormattingRules(this.Rules, OptionSet),
                    this.TabSize,
                    this.OptionSet.GetOption(FormattingOptions.IndentationSize, this.Document.Root.Language),
                    tokenStream: null,
                    lastToken: default(SyntaxToken));
            }