private static void CheckCategory(SyntaxKind kind, SyntaxCategory category) { if (kind.GetCategory() != category) { throw new ArgumentException($"The kind {kind} is not a {category.ToString().ToLower()}"); } }
/// <summary> /// Gets the default <see cref="CompletionItem"/> for a token with the specified <see cref="SyntaxKind"/>. /// </summary> private static CompletionItem GetDefaultCompletionItem(SyntaxKind kind, CompletionKind?ckind, CompletionPriority priority, string ctext = null) { var text = SyntaxFacts.GetText(kind); if (string.IsNullOrWhiteSpace(text)) { return(null); } switch (kind.GetCategory()) { case SyntaxCategory.Keyword: return(GetDefaultCompletionItem(text, ckind ?? CompletionKind.Keyword, priority, ctext)); case SyntaxCategory.Operator: return(GetDefaultCompletionItem(text, ckind ?? CompletionKind.ScalarInfix, priority, ctext)); case SyntaxCategory.Punctuation: return(GetDefaultCompletionItem(text, ckind ?? CompletionKind.Punctuation, priority, ctext)); default: return(null); } }
/// <summary> /// Gets the default tag to assign a token parser, based on the token's kind. /// </summary> private static string GetDefaultTag(SyntaxKind kind) { return(kind.GetCategory() == SyntaxCategory.Punctuation ? $"'{kind.GetText()}'" : kind.GetText() ?? kind.ToString().ToLower()); }