示例#1
0
 public static BadTokenSyntax BadToken(SyntaxSubKind subkind, string spelling, SyntaxNode precedingTrivia, SyntaxNode followingTrivia)
 {
     return((BadTokenSyntax) new BadTokenSyntax.Green(subkind, spelling, precedingTrivia?.GreenNode, followingTrivia?.GreenNode).CreateRed());
 }
示例#2
0
        private BadTokenSyntax XmlMakeBadToken(SyntaxSubKind subkind, SyntaxList<SyntaxNode> precedingTrivia, int length, ERRID id)
        {
            var spelling = GetText(length);
            var followingTrivia = ScanXmlWhitespace();
            var result1 = SyntaxFactory.BadToken(subkind, spelling, precedingTrivia.Node, followingTrivia);
            DiagnosticInfo diagnostic;
            switch (id)
            {
                case ERRID.ERR_IllegalXmlStartNameChar:
                case ERRID.ERR_IllegalXmlNameChar:
                    Debug.Assert(length == 1);
                    if (id == ERRID.ERR_IllegalXmlNameChar && (precedingTrivia.Any() || PrevToken == null || PrevToken.HasTrailingTrivia || PrevToken.Kind == SyntaxKind.LessThanToken || PrevToken.Kind == SyntaxKind.LessThanSlashToken || PrevToken.Kind == SyntaxKind.LessThanQuestionToken))
                    {
                        id = ERRID.ERR_IllegalXmlStartNameChar;
                    }

                    var xmlCh = spelling[0];
                    var xmlChAsUnicode = UTF16ToUnicode(new XmlCharResult(xmlCh));
                    diagnostic = ErrorFactory.ErrorInfo(id, xmlCh, string.Format("&H{0:X}", xmlChAsUnicode));
                    break;
                default:
                    diagnostic = ErrorFactory.ErrorInfo(id);
                    break;
            }

            var errResult1 = ((BadTokenSyntax)result1.SetDiagnostics(new[]
            {
                diagnostic
            }));

            Debug.Assert(errResult1 != null);
            return errResult1;
        }
示例#3
0
 public static BadTokenSyntax BadToken(SyntaxSubKind subkind, string spelling, SyntaxList <SyntaxNode> precedingTrivia, SyntaxList <SyntaxNode> followingTrivia)
 {
     return(BadToken(subkind, spelling, precedingTrivia.Node, followingTrivia.Node));
 }
示例#4
0
 internal Green(SyntaxSubKind subKind, string name, GreenNode leadingTrivia, GreenNode trailingTrivia)
     : base(SyntaxKind.BadToken, name, leadingTrivia, trailingTrivia)
 {
     SubKind = subKind;
 }
示例#5
0
 internal static BadTokenSyntax.Green BadToken(SyntaxSubKind subkind, string spelling, SyntaxList <GreenNode> precedingTrivia, SyntaxList <GreenNode> followingTrivia)
 {
     return(new BadTokenSyntax.Green(subkind, spelling, precedingTrivia.Node, followingTrivia.Node));
 }
示例#6
0
 internal Green(SyntaxSubKind subKind, string name, GreenNode leadingTrivia, GreenNode trailingTrivia, DiagnosticInfo[] diagnostics, SyntaxAnnotation[] annotations)
     : base(SyntaxKind.BadToken, name, leadingTrivia, trailingTrivia, diagnostics, annotations)
 {
     SubKind = subKind;
 }
 public static BadTokenSyntax BadToken(SyntaxSubKind subkind, string spelling, SyntaxList<SyntaxNode> precedingTrivia, SyntaxList<SyntaxNode> followingTrivia)
 {
     return new BadTokenSyntax(SyntaxKind.BadToken, spelling, precedingTrivia.Node, followingTrivia.Node);
 }