示例#1
0
        private static Classification GetClassification(SyntaxKind kind)
        {
            var isKeyword    = kind.IsKeyword();
            var isIdentifier = kind == SyntaxKind.IdentifierToken;
            var isNumber     = kind == SyntaxKind.NumberToken;
            var isString     = kind == SyntaxKind.StringToken;
            var isComment    = kind.IsComment();

            if (isKeyword)
            {
                return(Classification.Keyword);
            }
            else if (isIdentifier)
            {
                return(Classification.Identifier);
            }
            else if (isNumber)
            {
                return(Classification.Number);
            }
            else if (isString)
            {
                return(Classification.String);
            }
            else if (isComment)
            {
                return(Classification.Comment);
            }
            else
            {
                return(Classification.Text);
            }
        }
示例#2
0
    private static Classification GetClassification(SyntaxKind tokenKind)
    {
        if (tokenKind.IsKeyword())
        {
            return(Classification.Keyword);
        }

        if (tokenKind.IsComment())
        {
            return(Classification.Comment);
        }

        return(tokenKind switch
        {
            SyntaxKind.IdentifierToken => Classification.Identifier,
            SyntaxKind.NumberToken => Classification.Number,
            SyntaxKind.StringToken => Classification.String,
            _ => Classification.Text
        });
示例#3
0
 public static void IsComment(SyntaxKind kind, bool expectedResult) =>
 Assert.That(kind.IsComment(), Is.EqualTo(expectedResult));