C# Класс Loyc.Ecs.EcsValidators

A class filled with methods for checking whether a node has the correct LNode.Name and structure. For example, IsPropertyDefinition(node) checks whether node meets the requirements for being a property definition, such as having a Name equal to #property, and having name and return value that are complex identifiers.
This class also has useful helper functions, such as KeyNameComponentOf(LNode).
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
ExecutableBlockStmtType ( LNode _n, Pedantics p = Pedantics.Lax ) : Symbol
IsAssignmentOperator ( Symbol opName ) : bool
IsBracedBlock ( LNode n ) : bool
IsComplexIdentifier ( LNode n, ICI f = ICI.Default, Pedantics p = Pedantics.Lax ) : bool
IsEventDefinition ( LNode n, Pedantics p ) : bool
IsExecutableBlockStmt ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
IsForwardedProperty ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
IsIdentContChar ( char c ) : bool
IsIdentStartChar ( char c ) : bool
IsLabelStmt ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
IsNamedArgument ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
IsOperator ( Symbol opName ) : bool
IsPlainCsIdentContChar ( char c ) : bool
IsPlainCsIdentStartChar ( char c ) : bool
IsPlainCsIdentifier ( string text ) : bool
IsPrintableTypeParam ( LNode n, Pedantics p = Pedantics.Lax ) : bool

Checks if 'n' is a legal type parameter definition.

A type parameter definition must be a simple symbol with at most one #in or #out attribute, and at most one #where attribute with an argument list consisting of complex identifiers.

IsPropertyDefinition ( LNode n, LNode &retType, LNode &name, LNode &args, LNode &body, LNode &initialValue, Pedantics p = Pedantics.Lax ) : bool

Returns true iff the given node has a valid syntax tree for a property definition, and gets the component parts of the definition.

The body may be anything. If it calls CodeSymbols.Braces, it's a normal body.

IsPropertyDefinition ( LNode n, Pedantics p = Pedantics.Lax ) : bool

Returns true iff the given node has a valid syntax tree for a property definition.

IsResultExpr ( LNode n, Pedantics p = Pedantics.Lax ) : bool
IsSimpleIdentifier ( LNode n, Pedantics p ) : bool
IsVariableDecl ( LNode _n, bool allowMultiple, bool allowNoAssignment, Pedantics p ) : bool
IsVariableDeclExpr ( LNode expr, LNode &type, LNode &name, LNode &initialValue ) : bool

Verifies that a declaration of a single variable is valid and gets its parts.

KeyNameComponentOf ( LNode name ) : Symbol

Given a complex name such as global::Foo<int>.Bar<T>, this method identifies the base name component, which in this example is Bar. This is used, for example, to identify the expected name for a constructor based on the class name, e.g. Foo<T> => Foo.

It is not verified that name is a complex identifier. There is no error detection but in some cases an empty name may be returned, e.g. for input like Foo."Hello".

MayBeImplicitChildStatement ( LNode node, int childIndex ) : bool

Returns true if the specified child of the specified node can be an implicit child statement, i.e. a child statement that is not necessarily a braced block, e.g. the second child of a while loop.

This method helps the printer decide when a newline should be added before an unbraced child statement when there are no attributes dictating whether to add a newline or not. This method only cares about executable parent nodes. It returns false for class/space and function/property bodies, which are always braced blocks and therefore get a newline before every child statement automatically.

MethodDefinitionKind ( LNode n, LNode &retType, LNode &name, LNode &args, LNode &body, bool allowDelegate, Pedantics p = Pedantics.Lax ) : Symbol

If the given node has a valid syntax tree for a method definition, a constructor, or (when orDelegate is true) a delegate definition, gets the definition kind (#fn, #cons, or #delegate).

Method declarations (no body) also count. A destructor counts as a #fn with a method name that calls the ~ operator.

MethodDefinitionKind ( LNode n, bool allowDelegate, Pedantics p = Pedantics.Lax ) : Symbol

If the given node has a valid syntax tree for a method definition, a constructor, or (when orDelegate is true) a delegate definition, gets the definition kind (#fn, #cons, or #delegate).

SanitizeIdentifier ( string id ) : string

Eliminates punctuation and special characters from a string so that the string can be used as a plain C# identifier, e.g. "I'd" => "I_aposd", "123" => "_123", "+5" => "_plus5".

The empty string "" becomes "__empty__", ASCII punctuation becomes "_xyz" where xyz is an HTML entity name, e.g. '!' becomes "_excl", and all other characters become "Xxx" where xx is the hexadecimal representation of the code point. Designed for the Unicode BMP only.

SpaceDefinitionKind ( LNode n, LNode &name, LNode &bases, LNode &body, Pedantics p = Pedantics.Lax ) : Symbol

Returns the space kind, which is one of the names #struct, #class, #enum, #interface, #namespace, #alias, #trait, or null if the node Name or structure is not valid for a space statement.

SpaceDefinitionKind ( LNode n, Pedantics p = Pedantics.Lax ) : Symbol

Returns the space kind, which is one of the names #struct, #class, #enum, #interface, #namespace, #alias, #trait, or null if the node Name or structure is not valid for a space statement.

Приватные методы

Метод Описание
CallsMinWPAIH ( LNode self, Symbol name, int argCount, Pedantics p ) : bool
CallsWPAIH ( LNode self, Symbol name, Pedantics p ) : bool
CallsWPAIH ( LNode self, Symbol name, int argCount, Pedantics p ) : bool
HasPAttrs ( LNode node, Pedantics p ) : bool
HasPAttrsOrParens ( LNode node, Pedantics p ) : bool
HasSimpleHeadWPA ( LNode self, Pedantics p ) : bool
IsEventDefinition ( LNode node, LNode &type, LNode &name, LNode &body, Pedantics p ) : bool
IsSimpleExecutableKeywordStmt ( LNode _n, Pedantics p ) : bool
IsSimpleSymbolWPA ( LNode self, Pedantics p ) : bool
IsSimpleSymbolWPA ( LNode self, Symbol name, Pedantics p ) : bool
OtherBlockStmtType ( LNode _n, Pedantics p ) : Symbol
TwoArgBlockStmtType ( LNode _n, Pedantics p ) : Symbol

Описание методов

ExecutableBlockStmtType() публичный статический Метод

public static ExecutableBlockStmtType ( LNode _n, Pedantics p = Pedantics.Lax ) : Symbol
_n LNode
p Pedantics
Результат Symbol

IsAssignmentOperator() публичный статический Метод

public static IsAssignmentOperator ( Symbol opName ) : bool
opName Symbol
Результат bool

IsBracedBlock() публичный статический Метод

public static IsBracedBlock ( LNode n ) : bool
n LNode
Результат bool

IsComplexIdentifier() публичный статический Метод

public static IsComplexIdentifier ( LNode n, ICI f = ICI.Default, Pedantics p = Pedantics.Lax ) : bool
n LNode
f ICI
p Pedantics
Результат bool

IsEventDefinition() публичный статический Метод

public static IsEventDefinition ( LNode n, Pedantics p ) : bool
n LNode
p Pedantics
Результат bool

IsExecutableBlockStmt() публичный статический Метод

public static IsExecutableBlockStmt ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
_n LNode
p Pedantics
Результат bool

IsForwardedProperty() публичный статический Метод

public static IsForwardedProperty ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
_n LNode
p Pedantics
Результат bool

IsIdentContChar() публичный статический Метод

public static IsIdentContChar ( char c ) : bool
c char
Результат bool

IsIdentStartChar() публичный статический Метод

public static IsIdentStartChar ( char c ) : bool
c char
Результат bool

IsLabelStmt() публичный статический Метод

public static IsLabelStmt ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
_n LNode
p Pedantics
Результат bool

IsNamedArgument() публичный статический Метод

public static IsNamedArgument ( LNode _n, Pedantics p = Pedantics.Lax ) : bool
_n LNode
p Pedantics
Результат bool

IsOperator() публичный статический Метод

public static IsOperator ( Symbol opName ) : bool
opName Symbol
Результат bool

IsPlainCsIdentContChar() публичный статический Метод

public static IsPlainCsIdentContChar ( char c ) : bool
c char
Результат bool

IsPlainCsIdentStartChar() публичный статический Метод

public static IsPlainCsIdentStartChar ( char c ) : bool
c char
Результат bool

IsPlainCsIdentifier() публичный статический Метод

public static IsPlainCsIdentifier ( string text ) : bool
text string
Результат bool

IsPrintableTypeParam() публичный статический Метод

Checks if 'n' is a legal type parameter definition.
A type parameter definition must be a simple symbol with at most one #in or #out attribute, and at most one #where attribute with an argument list consisting of complex identifiers.
public static IsPrintableTypeParam ( LNode n, Pedantics p = Pedantics.Lax ) : bool
n LNode
p Pedantics
Результат bool

IsPropertyDefinition() публичный статический Метод

Returns true iff the given node has a valid syntax tree for a property definition, and gets the component parts of the definition.
The body may be anything. If it calls CodeSymbols.Braces, it's a normal body.
public static IsPropertyDefinition ( LNode n, LNode &retType, LNode &name, LNode &args, LNode &body, LNode &initialValue, Pedantics p = Pedantics.Lax ) : bool
n LNode
retType LNode
name LNode
args LNode
body LNode
initialValue LNode
p Pedantics
Результат bool

IsPropertyDefinition() публичный статический Метод

Returns true iff the given node has a valid syntax tree for a property definition.
public static IsPropertyDefinition ( LNode n, Pedantics p = Pedantics.Lax ) : bool
n LNode
p Pedantics
Результат bool

IsResultExpr() публичный статический Метод

public static IsResultExpr ( LNode n, Pedantics p = Pedantics.Lax ) : bool
n LNode
p Pedantics
Результат bool

IsSimpleIdentifier() публичный статический Метод

public static IsSimpleIdentifier ( LNode n, Pedantics p ) : bool
n LNode
p Pedantics
Результат bool

IsVariableDecl() публичный статический Метод

public static IsVariableDecl ( LNode _n, bool allowMultiple, bool allowNoAssignment, Pedantics p ) : bool
_n LNode
allowMultiple bool
allowNoAssignment bool
p Pedantics
Результат bool

IsVariableDeclExpr() публичный статический Метод

Verifies that a declaration of a single variable is valid and gets its parts.
public static IsVariableDeclExpr ( LNode expr, LNode &type, LNode &name, LNode &initialValue ) : bool
expr LNode Potential variable or field declaration
type LNode Variable type (empty identifier if `var`)
name LNode Variable name (identifier or $substutution expr)
initialValue LNode Initial value that is assigned in expr, or null if unassigned.
Результат bool

KeyNameComponentOf() публичный статический Метод

Given a complex name such as global::Foo<int>.Bar<T>, this method identifies the base name component, which in this example is Bar. This is used, for example, to identify the expected name for a constructor based on the class name, e.g. Foo<T> => Foo.
It is not verified that name is a complex identifier. There is no error detection but in some cases an empty name may be returned, e.g. for input like Foo."Hello".
public static KeyNameComponentOf ( LNode name ) : Symbol
name LNode
Результат Symbol

MayBeImplicitChildStatement() публичный статический Метод

Returns true if the specified child of the specified node can be an implicit child statement, i.e. a child statement that is not necessarily a braced block, e.g. the second child of a while loop.
This method helps the printer decide when a newline should be added before an unbraced child statement when there are no attributes dictating whether to add a newline or not. This method only cares about executable parent nodes. It returns false for class/space and function/property bodies, which are always braced blocks and therefore get a newline before every child statement automatically.
public static MayBeImplicitChildStatement ( LNode node, int childIndex ) : bool
node LNode
childIndex int
Результат bool

MethodDefinitionKind() публичный статический Метод

If the given node has a valid syntax tree for a method definition, a constructor, or (when orDelegate is true) a delegate definition, gets the definition kind (#fn, #cons, or #delegate).
Method declarations (no body) also count. A destructor counts as a #fn with a method name that calls the ~ operator.
public static MethodDefinitionKind ( LNode n, LNode &retType, LNode &name, LNode &args, LNode &body, bool allowDelegate, Pedantics p = Pedantics.Lax ) : Symbol
n LNode
retType LNode Return type of the method (if it's a constructor, this will be the empty identifier).
name LNode Name of the method.
args LNode args.Args is the argument list of the method.
body LNode The method body, or null if there is no method body. /// The method body calls if the method is a /// non-lambda-style method.
allowDelegate bool
p Pedantics
Результат Symbol

MethodDefinitionKind() публичный статический Метод

If the given node has a valid syntax tree for a method definition, a constructor, or (when orDelegate is true) a delegate definition, gets the definition kind (#fn, #cons, or #delegate).
public static MethodDefinitionKind ( LNode n, bool allowDelegate, Pedantics p = Pedantics.Lax ) : Symbol
n LNode
allowDelegate bool
p Pedantics
Результат Symbol

SanitizeIdentifier() публичный статический Метод

Eliminates punctuation and special characters from a string so that the string can be used as a plain C# identifier, e.g. "I'd" => "I_aposd", "123" => "_123", "+5" => "_plus5".
The empty string "" becomes "__empty__", ASCII punctuation becomes "_xyz" where xyz is an HTML entity name, e.g. '!' becomes "_excl", and all other characters become "Xxx" where xx is the hexadecimal representation of the code point. Designed for the Unicode BMP only.
public static SanitizeIdentifier ( string id ) : string
id string
Результат string

SpaceDefinitionKind() публичный статический Метод

Returns the space kind, which is one of the names #struct, #class, #enum, #interface, #namespace, #alias, #trait, or null if the node Name or structure is not valid for a space statement.
public static SpaceDefinitionKind ( LNode n, LNode &name, LNode &bases, LNode &body, Pedantics p = Pedantics.Lax ) : Symbol
n LNode The node to examine.
name LNode Name of the space.
bases LNode bases.Args will be the list of base types.
body LNode A braced block of statements holding the contents of the space.
p Pedantics
Результат Symbol

SpaceDefinitionKind() публичный статический Метод

Returns the space kind, which is one of the names #struct, #class, #enum, #interface, #namespace, #alias, #trait, or null if the node Name or structure is not valid for a space statement.
public static SpaceDefinitionKind ( LNode n, Pedantics p = Pedantics.Lax ) : Symbol
n LNode
p Pedantics
Результат Symbol