mirror of
https://github.com/FabInfra/capnproto-dotnetcore_Runtime.git
synced 2025-03-12 14:51:41 +01:00
23 lines
645 B
C#
23 lines
645 B
C#
using Microsoft.CodeAnalysis.CSharp;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace CapnpC.Model
|
|
{
|
|
public class IdentifierRenamer
|
|
{
|
|
public static bool IsAnyKeyword(string str)
|
|
{
|
|
return SyntaxFacts.GetKeywordKind(str) != SyntaxKind.None
|
|
|| SyntaxFacts.GetContextualKeywordKind(str) != SyntaxKind.None;
|
|
}
|
|
public static string ToNonKeyword(string str)
|
|
{
|
|
// Capnp schema identifiers should be already valid, but could be a keyword
|
|
if (IsAnyKeyword(str)) return $"@{str}";
|
|
return str;
|
|
}
|
|
}
|
|
}
|