Provides set of services for brace handling in formatting
Exemple #1
0
        /// <summary>
        /// Tokenizes provided string that contains R code
        /// </summary>
        private void Tokenize(string text)
        {
            _textProvider = new TextStream(text);

            var tokenizer = new RTokenizer(separateComments: false);
            var tokens    = tokenizer.Tokenize(_textProvider, 0, _textProvider.Length);

            _tokens = new TokenStream <RToken>(tokens, RToken.EndOfStreamToken);

            _braceHandler     = new BraceHandler(_tokens, _tb);
            _expressionHelper = new ExpressionHelper(_tokens, _textProvider);
        }
Exemple #2
0
        public FormattingScope(TextBuilder tb, TokenStream<RToken> tokens, int openBraceTokenIndex, RFormatOptions options, BraceHandler braceHandler) {
            Debug.Assert(tokens[openBraceTokenIndex].TokenType == RTokenType.OpenCurlyBrace);

            _options = options;
            _tb = tb;
            _previousIndentLevel = tb.IndentBuilder.IndentLevel;

            CloseCurlyBraceTokenIndex = FindMatchingCloseBrace(tokens, openBraceTokenIndex);

            StartingLineIndentSize = braceHandler.GetOpenCurlyBraceIndentSize(tokens[openBraceTokenIndex], tb, options);
            if (StartingLineIndentSize > 0) {
                tb.IndentBuilder.SetIndentLevelForSize(StartingLineIndentSize + _options.IndentSize);
            } else {
                tb.IndentBuilder.NewIndentLevel();
            }
        }
Exemple #3
0
        public FormattingScope(TextBuilder tb, TokenStream <RToken> tokens, int openBraceTokenIndex, RFormatOptions options, BraceHandler braceHandler)
        {
            Debug.Assert(tokens[openBraceTokenIndex].TokenType == RTokenType.OpenCurlyBrace);

            _options             = options;
            _tb                  = tb;
            _previousIndentLevel = tb.IndentBuilder.IndentLevel;

            CloseCurlyBraceTokenIndex = FindMatchingCloseBrace(tokens, openBraceTokenIndex);

            StartingLineIndentSize = braceHandler.GetOpenCurlyBraceIndentSize(tokens[openBraceTokenIndex], tb, options);
            if (StartingLineIndentSize > 0)
            {
                tb.IndentBuilder.SetIndentLevelForSize(StartingLineIndentSize + _options.IndentSize);
            }
            else
            {
                tb.IndentBuilder.NewIndentLevel();
            }
        }
Exemple #4
0
        /// <summary>
        /// Tokenizes provided string that contains R code
        /// </summary>
        private void Tokenize(string text) {
            _textProvider = new TextStream(text);

            var tokenizer = new RTokenizer(separateComments: false);
            var tokens = tokenizer.Tokenize(_textProvider, 0, _textProvider.Length);
            _tokens = new TokenStream<RToken>(tokens, RToken.EndOfStreamToken);

            _braceHandler = new BraceHandler(_tokens, _tb);
            _expressionHelper = new ExpressionHelper(_tokens, _textProvider);
        }