Created
November 18, 2017 14:24
-
-
Save lmcarreiro/3a2af88320025879317dce951bad0258 to your computer and use it in GitHub Desktop.
Convert SintaxKind marker name to the real kind name
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| export function getSyntaxKindName(kind: SyntaxKind): string | |
| { | |
| const markers: { [name: string]: string } = { | |
| FirstAssignment : "EqualsToken", | |
| LastAssignment : "CaretEqualsToken", | |
| FirstCompoundAssignment : "PlusEqualsToken", | |
| LastCompoundAssignment : "CaretEqualsToken", | |
| FirstReservedWord : "BreakKeyword", | |
| LastReservedWord : "WithKeyword", | |
| FirstKeyword : "BreakKeyword", | |
| LastKeyword : "OfKeyword", | |
| FirstFutureReservedWord : "ImplementsKeyword", | |
| LastFutureReservedWord : "YieldKeyword", | |
| FirstTypeNode : "TypePredicate", | |
| LastTypeNode : "LiteralType", | |
| FirstPunctuation : "OpenBraceToken", | |
| LastPunctuation : "CaretEqualsToken", | |
| FirstToken : "Unknown", | |
| LastToken : "LastKeyword", | |
| FirstTriviaToken : "SingleLineCommentTrivia", | |
| LastTriviaToken : "ConflictMarkerTrivia", | |
| FirstLiteralToken : "NumericLiteral", | |
| LastLiteralToken : "NoSubstitutionTemplateLiteral", | |
| FirstTemplateToken : "NoSubstitutionTemplateLiteral", | |
| LastTemplateToken : "TemplateTail", | |
| FirstBinaryOperator : "LessThanToken", | |
| LastBinaryOperator : "CaretEqualsToken", | |
| FirstNode : "QualifiedName", | |
| FirstJSDocNode : "JSDocTypeExpression", | |
| LastJSDocNode : "JSDocPropertyTag", | |
| FirstJSDocTagNode : "JSDocTag", | |
| LastJSDocTagNode : "JSDocPropertyTag", | |
| FirstContextualKeyword : "AbstractKeyword", | |
| LastContextualKeyword : "OfKeyword", | |
| } | |
| const name = SyntaxKind[kind]; | |
| return markers.hasOwnProperty(name) ? markers[name] : name; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This will not break in future versions. ( above is no longer valid )