1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using Microsoft.CodeAnalysis;
using Microsoft.CodeAnalysis.CSharp;
using SourceBrowser.Generator.Model.CSharp;

namespace SourceBrowser.Generator.DocumentWalkers
{
    class CSWalkerUtils : CSharpSyntaxWalker, IWalkerUtils
    {
        private readonly DocumentWalker<CSWalkerUtils> _walker;

        internal CSWalkerUtils(DocumentWalker<CSWalkerUtils> walker)
            : base(SyntaxWalkerDepth.Trivia)
        {
            _walker = walker;
        }

        public string IdentifierTokenTypeName {  get; } = CSharpTokenTypes.IDENTIFIER;

        public string KeywordTokenTypeName { get; } = CSharpTokenTypes.KEYWORD;

        public string OtherTokenTypeName { get; } = CSharpTokenTypes.OTHER;

        public string StringTokenTypeName { get; } = CSharpTokenTypes.STRING;

        public string TypeTokenTypeName { get; } = CSharpTokenTypes.TYPE;

        public string ParameterDelimiter { get; } = CSharpDelimiters.PARAMETER;

        public string LocalVariableDelimiter { get; } = CSharpDelimiters.LOCAL_VARIABLE;


        public string GetFullName(SyntaxToken token) => token.CSharpKind().ToString();

        public bool IsIdentifier(SyntaxToken token) => token.CSharpKind() == SyntaxKind.IdentifierToken;

        public bool IsKeyword(SyntaxToken token) => token.IsKeyword();

        public bool IsLiteral(SyntaxToken token) => token.CSharpKind() == SyntaxKind.StringLiteralToken;

        public override void VisitToken(SyntaxToken token) => _walker.VisitToken(token);
    }
}