示例#1
0
        // Process a token. and add to the list of triva/tokens we're accumulating.
        public void AddToken(SyntaxToken.Green token, bool isFirst, bool isLast)
        {
            bool isMissing = token.IsMissing;

            if (token.HasLeadingTrivia && (isFirst || isMissing || token.GetLeadingTrivia().TriviaListContainsStructuredTrivia()))
            {
                FinishInProgressTokens();
                AddTrivia(token.GetLeadingTrivia());
                token = ((SyntaxToken.Green)token.WithLeadingTrivia(null));
            }

            ////if (!preserveExistingDiagnostics)
            ////{
            ////    token = token.WithoutDiagnostics();
            ////}

            GreenNode trailingTrivia = null;

            if (token.HasTrailingTrivia && (isLast || isMissing || token.GetTrailingTrivia().TriviaListContainsStructuredTrivia()))
            {
                trailingTrivia = token.GetTrailingTrivia();
                token          = ((SyntaxToken.Green)token.WithTrailingTrivia(null));
            }

            if (isMissing)
            {
                // Don't add missing tokens to skipped tokens, but preserve their diagnostics.
                ////if (token.ContainsDiagnostics())
                ////{
                ////    // Move diagnostics on missing token to next token.
                ////    if (diagnosticsToAdd != null)
                ////    {
                ////        diagnosticsToAdd = diagnosticsToAdd.Concat(token.GetDiagnostics());
                ////    }
                ////    else
                ////    {
                ////        diagnosticsToAdd = token.GetDiagnostics();
                ////    }

                ////    addDiagnosticsToFirstTokenOnly = true;
                ////}
            }
            else
            {
                skippedTokensBuilder.Add(token);
            }

            if (trailingTrivia != null)
            {
                FinishInProgressTokens();
                AddTrivia(trailingTrivia);
            }

            if (isFirst && addDiagnosticsToFirstTokenOnly)
            {
                FinishInProgressTokens(); // implicitly adds the diagnostics.
            }
        }
示例#2
0
 internal Green(XmlNameSyntax.Green nameNode, SyntaxToken.Green equalsSyntax, XmlNodeSyntax.Green valueNode, DiagnosticInfo[] diagnostics, SyntaxAnnotation[] annotations)
     : base(SyntaxKind.XmlAttribute, diagnostics, annotations)
 {
     this.SlotCount = 3;
     this.nameNode  = nameNode;
     AdjustWidth(nameNode);
     this.equalsSyntax = equalsSyntax;
     AdjustWidth(equalsSyntax);
     this.valueNode = valueNode;
     AdjustWidth(valueNode);
 }
示例#3
0
 internal Green(XmlNameSyntax.Green nameNode, SyntaxToken.Green equalsSyntax, XmlNodeSyntax.Green valueNode)
     : base(SyntaxKind.XmlAttribute)
 {
     this.SlotCount = 3;
     this.nameNode  = nameNode;
     AdjustWidth(nameNode);
     this.equalsSyntax = equalsSyntax;
     AdjustWidth(equalsSyntax);
     this.valueNode = valueNode;
     AdjustWidth(valueNode);
 }
示例#4
0
 internal Green(SyntaxToken.Green lessThanToken, XmlNameSyntax.Green name, SyntaxToken.Green slashGreaterThanToken)
     : base(SyntaxKind.XmlElementEndTag)
 {
     this.SlotCount     = 3;
     this.lessThanToken = lessThanToken;
     AdjustWidth(lessThanToken);
     this.name = name;
     AdjustWidth(name);
     this.slashGreaterThanToken = slashGreaterThanToken;
     AdjustWidth(slashGreaterThanToken);
 }
 internal Green(SyntaxToken.Green lessThanToken, XmlNameSyntax.Green name, SyntaxToken.Green slashGreaterThanToken, DiagnosticInfo[] diagnostics, SyntaxAnnotation[] annotations)
     : base(SyntaxKind.XmlElementEndTag, diagnostics, annotations)
 {
     this.SlotCount     = 3;
     this.lessThanToken = lessThanToken;
     AdjustWidth(lessThanToken);
     this.name = name;
     AdjustWidth(name);
     this.slashGreaterThanToken = slashGreaterThanToken;
     AdjustWidth(slashGreaterThanToken);
 }
示例#6
0
 internal Green(SyntaxToken.Green lessThanToken, XmlNameSyntax.Green name, GreenNode attributes, SyntaxToken.Green slashGreaterThanToken)
     : base(SyntaxKind.XmlElementStartTag)
 {
     this.SlotCount     = 4;
     this.lessThanToken = lessThanToken;
     AdjustWidth(lessThanToken);
     this.name = name;
     AdjustWidth(name);
     this.attributes = attributes;
     AdjustWidth(attributes);
     this.slashGreaterThanToken = slashGreaterThanToken;
     AdjustWidth(slashGreaterThanToken);
 }
示例#7
0
        private static void PushReverseTerminal(Stack <GreenNode> stack, SyntaxToken.Green tk)
        {
            var trivia = tk.GetTrailingTrivia();

            if (trivia != null)
            {
                PushChildReverse(stack, trivia);
            }
            PushChildReverse(stack, tk.WithLeadingTrivia(null).WithTrailingTrivia(null));
            trivia = tk.GetLeadingTrivia();
            if (trivia != null)
            {
                PushChildReverse(stack, trivia);
            }
        }
示例#8
0
 internal Green(XmlDeclarationSyntax.Green prologue, GreenNode precedingMisc, XmlNodeSyntax.Green body, GreenNode followingMisc, SkippedTokensTriviaSyntax.Green skippedTokens, SyntaxToken.Green eof, DiagnosticInfo[] diagnostics, SyntaxAnnotation[] annotations)
     : base(SyntaxKind.XmlDocument, diagnostics, annotations)
 {
     this.SlotCount = 6;
     this.prologue  = prologue;
     AdjustWidth(prologue);
     this.precedingMisc = precedingMisc;
     AdjustWidth(precedingMisc);
     this.body = body;
     AdjustWidth(body);
     this.followingMisc = followingMisc;
     AdjustWidth(followingMisc);
     this.skippedTokens = skippedTokens;
     AdjustWidth(skippedTokens);
     this.eof = eof;
     AdjustWidth(eof);
 }
示例#9
0
 public override SyntaxToken.Green VisitSyntaxToken(SyntaxToken.Green token)
 {
     return(_newItem(token));
 }