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 CssExtensions

Remarks

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

NameDescription
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.cs

Gets the number a number, percentage, or dimension token holds, or null for any other token.

public static double? GetNumericValue(this SyntaxToken token)

Parameters

token SyntaxToken

Returns

double?

Remarks

A number too large for a Double is infinite, as it is for a browser.

GetUnicodeRange(SyntaxToken)

CssExtensions.cs

Gets 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

token SyntaxToken

Returns

(int Start, int End)?

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.cs

Gets 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)

Parameters

token SyntaxToken

Returns

string?

IsComment(SyntaxTrivia)

CssExtensions.cs

Determines whether trivia is a comment.

public static bool IsComment(this SyntaxTrivia trivia)

Parameters

trivia SyntaxTrivia

Returns

bool

IsIdHash(SyntaxToken)

CssExtensions.cs

Determines 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)

Parameters

token SyntaxToken

Returns

bool

IsInteger(SyntaxToken)

CssExtensions.cs

Determines 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)

Parameters

token SyntaxToken

Returns

bool

IsKind overloads

IsKind(SyntaxNode?, SyntaxKind)

CssExtensions.cs
public static bool IsKind(this SyntaxNode? node, SyntaxKind kind)
Parameters
node SyntaxNode?
kind SyntaxKind
Returns

bool

No documentation is available.

IsKind(SyntaxNodeOrToken, SyntaxKind)

CssExtensions.cs
public static bool IsKind(this SyntaxNodeOrToken nodeOrToken, SyntaxKind kind)
Parameters
nodeOrToken SyntaxNodeOrToken
kind SyntaxKind
Returns

bool

No documentation is available.

IsKind(SyntaxToken, SyntaxKind)

CssExtensions.cs
public static bool IsKind(this SyntaxToken token, SyntaxKind kind)
Parameters
token SyntaxToken
kind SyntaxKind
Returns

bool

No documentation is available.

IsKind(SyntaxTrivia, SyntaxKind)

CssExtensions.cs
public static bool IsKind(this SyntaxTrivia trivia, SyntaxKind kind)
Parameters
trivia SyntaxTrivia
kind SyntaxKind
Returns

bool

No documentation is available.

IsPresent(SyntaxToken)

CssExtensions.cs

Determines whether the source actually had this optional token.

public static bool IsPresent(this SyntaxToken token)

Parameters

token SyntaxToken

Returns

bool

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.cs

Gets the CSS kind of a node reached through the shared type rather than the CSS one.

public static SyntaxKind Kind(this SyntaxNode? node)
Parameters
node SyntaxNode?
Returns

SyntaxKind

Kind(SyntaxNodeOrToken)

CssExtensions.cs
public static SyntaxKind Kind(this SyntaxNodeOrToken nodeOrToken)
Parameters
nodeOrToken SyntaxNodeOrToken
Returns

SyntaxKind

No documentation is available.

Kind(SyntaxToken)

CssExtensions.cs
public static SyntaxKind Kind(this SyntaxToken token)
Parameters
token SyntaxToken
Returns

SyntaxKind

No documentation is available.

Kind(SyntaxTrivia)

CssExtensions.cs
public static SyntaxKind Kind(this SyntaxTrivia trivia)
Parameters
trivia SyntaxTrivia
Returns

SyntaxKind

No documentation is available.