CssExtensions Class
Reads the CSS kind of the tokens, trivia, and nodes the shared syntax types hand back, and the values of CSS tokens.
public static class CssExtensionsRemarks
The shared types carry a kind as a plain number because they are used by every language. These turn that number back into the CSS kind it stands for.
Methods
| Name | Description |
|---|---|
| GetNumericValue(SyntaxToken) | Gets the number a number, percentage, or dimension token holds, or null for any other token. |
| GetUnicodeRange(SyntaxToken) | Gets the range of code points a unicode-range token covers, or null for any other token. |
| GetUnit(SyntaxToken) | Gets the unit of a dimension token, such as px, with its escapes resolved, or null for any other token. |
| IsComment(SyntaxTrivia) | Determines whether trivia is a comment. |
| IsIdHash(SyntaxToken) | Determines whether a hash token is an ID: whether its name would read as an identifier, as in #main but not #1a. |
| IsInteger(SyntaxToken) | Determines whether a number, percentage, or dimension token is written as an integer, without a fraction or an exponent. |
| IsKind(SyntaxNode?, SyntaxKind) | |
| IsKind(SyntaxNodeOrToken, SyntaxKind) | |
| IsKind(SyntaxToken, SyntaxKind) | |
| IsKind(SyntaxTrivia, SyntaxKind) | |
| IsPresent(SyntaxToken) | Determines whether the source actually had this optional token. |
| Kind(SyntaxNode?) | Gets the CSS kind of a node reached through the shared type rather than the CSS one. |
| Kind(SyntaxNodeOrToken) | |
| Kind(SyntaxToken) | |
| Kind(SyntaxTrivia) |
GetNumericValue(SyntaxToken)
CssExtensions.csGets the number a number, percentage, or dimension token holds, or null for any other token.
public static double? GetNumericValue(this SyntaxToken token)Parameters
tokenSyntaxToken
Returns
Remarks
A number too large for a Double is infinite, as it is for a browser.
GetUnicodeRange(SyntaxToken)
CssExtensions.csGets the range of code points a unicode-range token covers, or null for any other token.
public static (int Start, int End)? GetUnicodeRange(this SyntaxToken token)Parameters
tokenSyntaxToken
Returns
Remarks
The range is returned as written, even when it is not valid, such as when its end is before its start.
GetUnit(SyntaxToken)
CssExtensions.csGets the unit of a dimension token, such as px, with its escapes resolved, or null for any other token.
public static string? GetUnit(this SyntaxToken token)IsComment(SyntaxTrivia)
CssExtensions.csDetermines whether trivia is a comment.
public static bool IsComment(this SyntaxTrivia trivia)IsIdHash(SyntaxToken)
CssExtensions.csDetermines whether a hash token is an ID: whether its name would read as an identifier, as in #main but not #1a.
public static bool IsIdHash(this SyntaxToken token)IsInteger(SyntaxToken)
CssExtensions.csDetermines whether a number, percentage, or dimension token is written as an integer, without a fraction or an exponent.
public static bool IsInteger(this SyntaxToken token)IsKind overloads
IsKind(SyntaxNode?, SyntaxKind)
CssExtensions.cspublic static bool IsKind(this SyntaxNode? node, SyntaxKind kind)No documentation is available.
IsKind(SyntaxNodeOrToken, SyntaxKind)
CssExtensions.cspublic static bool IsKind(this SyntaxNodeOrToken nodeOrToken, SyntaxKind kind)No documentation is available.
IsKind(SyntaxToken, SyntaxKind)
CssExtensions.cspublic static bool IsKind(this SyntaxToken token, SyntaxKind kind)No documentation is available.
IsKind(SyntaxTrivia, SyntaxKind)
CssExtensions.cspublic static bool IsKind(this SyntaxTrivia trivia, SyntaxKind kind)No documentation is available.
IsPresent(SyntaxToken)
CssExtensions.csDetermines whether the source actually had this optional token.
public static bool IsPresent(this SyntaxToken token)Parameters
tokenSyntaxToken
Returns
Remarks
An optional slot the source left empty holds the default token, whose kind is SyntaxKind.None. That is not the same as a missing token, which the parser puts in a required slot to stand in for text that should have been there.
Kind overloads
Kind(SyntaxNode?)
CssExtensions.csGets the CSS kind of a node reached through the shared type rather than the CSS one.
public static SyntaxKind Kind(this SyntaxNode? node)Kind(SyntaxNodeOrToken)
CssExtensions.cspublic static SyntaxKind Kind(this SyntaxNodeOrToken nodeOrToken)No documentation is available.
Kind(SyntaxToken)
CssExtensions.cspublic static SyntaxKind Kind(this SyntaxToken token)No documentation is available.
Kind(SyntaxTrivia)
CssExtensions.cspublic static SyntaxKind Kind(this SyntaxTrivia trivia)No documentation is available.