Ejemplo n.º 1
0
        public static IndentationAnalysis Create(SyntaxNode node, CancellationToken cancellationToken = default)
        {
            SyntaxTrivia indentation = SyntaxTriviaAnalysis.DetermineIndentation(node, cancellationToken);

            int size = SyntaxTriviaAnalysis.DetermineIndentationSize(node, cancellationToken);

            return(new IndentationAnalysis(indentation, size));
        }
Ejemplo n.º 2
0
        public static IndentationAnalysis Create(SyntaxNode node, CancellationToken cancellationToken = default)
        {
            SyntaxTrivia indentation = SyntaxTriviaAnalysis.DetermineIndentation(node, cancellationToken);

            (SyntaxTrivia trivia1, SyntaxTrivia trivia2, bool isFromCompilationUnit) = DetermineSingleIndentation(node, cancellationToken);

            if (isFromCompilationUnit)
            {
                return(new IndentationAnalysis(indentation, trivia1.Span.Length - trivia2.Span.Length));
            }
            else if (indentation.Span.Length > 0)
            {
                return((trivia1.Span.Length > 0)
                    ? new IndentationAnalysis(indentation, trivia1.Span.Length)
                    : new IndentationAnalysis(indentation, indentation.Span.Length));
            }
            else if (trivia1.Span.Length > 0)
            {
                return(new IndentationAnalysis(trivia1, -1));
            }
            else
            {
                return(default);