Skip to main content

Crate treesitter_types_c_sharp

Crate treesitter_types_c_sharp 

Source
Expand description

Strongly-typed AST types for C#, auto-generated from tree-sitter-c-sharp’s node-types.json.

This crate is generated by treesitter-types and is automatically kept up to date when a new version of the grammar crate is released.

These types have been tested by parsing the .NET Runtime source code.

See the Tree-sitter project for more information about the underlying parser framework.

§Example

use treesitter_types_c_sharp::*;

// A minimal C# hello-world program (without using directives).
let src = b"\
class Hello {
    static void Main() {
        System.Console.WriteLine(\"Hello, World!\");
    }
}
";

// Parse the source with tree-sitter and convert into typed AST.
let mut parser = tree_sitter::Parser::new();
parser.set_language(&tree_sitter_c_sharp::LANGUAGE.into()).unwrap();
let tree = parser.parse(src, None).unwrap();
let cu = CompilationUnit::from_node(tree.root_node(), src).unwrap();

// The compilation unit has one top-level child: the class declaration.
assert_eq!(cu.children.len(), 1);

let CompilationUnitChildren::TypeDeclaration(type_decl) = &cu.children[0] else {
    panic!("expected a type declaration");
};
let TypeDeclaration::ClassDeclaration(class) = type_decl.as_ref() else {
    panic!("expected a class declaration");
};
assert_eq!(class.name.text(), "Hello");

// The class body contains one method.
assert_eq!(class.body.as_ref().unwrap().children.len(), 1);

Re-exports§

pub use tree_sitter_c_sharp;
pub use treesitter_types::tree_sitter;

Structs§

AccessorDeclaration
AccessorList
AliasQualifiedName
AndPattern
AnonymousMethodExpression
AnonymousObjectCreationExpression
Argument
ArgumentList
ArrayCreationExpression
ArrayRankSpecifier
ArrayType
ArrowExpressionClause
AsExpression
AssignmentExpression
Attribute
AttributeArgument
AttributeArgumentList
AttributeList
AttributeTargetSpecifier
AwaitExpression
BaseList
BinaryExpression
Block
BooleanLiteral
BracketedArgumentList
BracketedParameterList
BreakStatement
CallingConvention
CastExpression
CatchClause
CatchDeclaration
CatchFilterClause
CharacterLiteral
CharacterLiteralContent
CheckedExpression
CheckedStatement
ClassDeclaration
CollectionElement
CollectionExpression
Comment
CompilationUnit
ConditionalAccessExpression
ConditionalExpression
ConstantPattern
ConstructorConstraint
ConstructorDeclaration
ConstructorInitializer
ContinueStatement
ConversionOperatorDeclaration
DeclarationExpression
DeclarationList
DeclarationPattern
DefaultExpression
DelegateDeclaration
DestructorDeclaration
Discard
DoStatement
ElementAccessExpression
ElementBindingExpression
EmptyStatement
EnumDeclaration
EnumMemberDeclaration
EnumMemberDeclarationList
EscapeSequence
EventDeclaration
EventFieldDeclaration
ExplicitInterfaceSpecifier
ExpressionElement
ExpressionStatement
ExternAliasDirective
FieldDeclaration
FileScopedNamespaceDeclaration
FinallyClause
FixedStatement
ForStatement
ForeachStatement
FromClause
FunctionPointerParameter
FunctionPointerType
GenericName
GlobalAttribute
GlobalStatement
GotoStatement
GroupClause
Identifier
IfStatement
ImplicitArrayCreationExpression
ImplicitObjectCreationExpression
ImplicitParameter
ImplicitStackallocExpression
ImplicitType
IndexerDeclaration
InitializerExpression
IntegerLiteral
InterfaceDeclaration
InterpolatedStringExpression
Interpolation
InterpolationAlignmentClause
InterpolationBrace
InterpolationFormatClause
InterpolationQuote
InterpolationStart
InvocationExpression
IsExpression
IsPatternExpression
JoinClause
JoinIntoClause
LabeledStatement
LambdaExpression
LetClause
ListPattern
LocalDeclarationStatement
LocalFunctionStatement
LockStatement
MakerefExpression
MemberAccessExpression
MemberBindingExpression
MethodDeclaration
Modifier
NamespaceDeclaration
NegatedPattern
NullLiteral
NullableType
ObjectCreationExpression
OperatorDeclaration
OrPattern
OrderByClause
Parameter
ParameterList
ParenthesizedExpression
ParenthesizedPattern
ParenthesizedVariableDesignation
PointerType
PositionalPatternClause
PostfixUnaryExpression
PredefinedType
PrefixUnaryExpression
PreprocArg
PreprocDefine
PreprocElif
PreprocElse
PreprocEndregion
PreprocError
PreprocIf
PreprocIfInAttributeList
PreprocLine
PreprocNullable
PreprocPragma
PreprocRegion
PreprocUndef
PreprocWarning
PrimaryConstructorBaseType
PropertyDeclaration
PropertyPatternClause
QualifiedName
QueryExpression
RangeExpression
RawStringContent
RawStringEnd
RawStringLiteral
RawStringStart
RealLiteral
RecordDeclaration
RecursivePattern
RefExpression
RefType
ReftypeExpression
RefvalueExpression
RelationalPattern
ReturnStatement
ScopedType
SelectClause
ShebangDirective
SizeofExpression
Span
SpreadElement
StackallocExpression
StringContent
StringLiteral
StringLiteralContent
StringLiteralEncoding
StructDeclaration
Subpattern
SwitchBody
SwitchExpression
SwitchExpressionArm
SwitchSection
SwitchStatement
ThrowExpression
ThrowStatement
TryStatement
TupleElement
TupleExpression
TuplePattern
TupleType
TypeArgumentList
TypeParameter
TypeParameterConstraint
TypeParameterConstraintsClause
TypeParameterList
TypePattern
TypeofExpression
UnaryExpression
UnsafeStatement
UsingDirective
UsingStatement
VarPattern
VariableDeclaration
VariableDeclarator
VerbatimStringLiteral
WhenClause
WhereClause
WhileStatement
WithExpression
WithInitializer
YieldStatement

Enums§

AccessorDeclarationBody
AccessorDeclarationChildren
AccessorDeclarationName
AliasQualifiedNameName
AndPatternOperator
AnonymousMethodExpressionChildren
AnonymousObjectCreationExpressionChildren
AnyNode
ArgumentChildren
ArrayTypeType
AsExpressionOperator
AssignmentExpressionOperator
AttributeListChildren
AttributeName
BaseListChildren
BinaryExpressionLeft
BinaryExpressionOperator
BinaryExpressionRight
BracketedParameterListChildren
CatchClauseChildren
CharacterLiteralChildren
ClassDeclarationChildren
CollectionElementChildren
CompilationUnitChildren
ConditionalAccessExpressionChildren
ConstantPatternChildren
ConstructorDeclarationBody
ConstructorDeclarationChildren
ConversionOperatorDeclarationBody
ConversionOperatorDeclarationChildren
Declaration
DeclarationPatternChildren
DelegateDeclarationChildren
DestructorDeclarationBody
DestructorDeclarationChildren
EnumDeclarationChildren
EnumMemberDeclarationChildren
EnumMemberDeclarationListChildren
EventDeclarationChildren
EventFieldDeclarationChildren
ExplicitInterfaceSpecifierChildren
Expression
ExpressionStatementChildren
FieldDeclarationChildren
FileScopedNamespaceDeclarationName
FixedStatementChildren
ForStatementInitializer
ForStatementUpdate
ForeachStatementLeft
FunctionPointerParameterType
FunctionPointerTypeChildren
GenericNameChildren
ImplicitObjectCreationExpressionChildren
IndexerDeclarationChildren
InterfaceDeclarationChildren
InterpolatedStringExpressionChildren
InterpolationChildren
InvocationExpressionFunction
IsExpressionOperator
JoinClauseChildren
LabeledStatementChildren
LambdaExpressionBody
LambdaExpressionChildren
LambdaExpressionParameters
LetClauseChildren
ListPatternChildren
Literal
LocalDeclarationStatementChildren
LocalFunctionStatementBody
LocalFunctionStatementChildren
LockStatementChildren
LvalueExpression
MemberAccessExpressionExpression
MemberAccessExpressionName
MemberBindingExpressionName
MethodDeclarationBody
MethodDeclarationChildren
NamespaceDeclarationName
NonLvalueExpression
NullableTypeType
OperatorDeclarationBody
OperatorDeclarationChildren
OperatorDeclarationOperator
OrPatternOperator
ParameterChildren
ParameterListChildren
ParenthesizedExpressionChildren
ParenthesizedVariableDesignationChildren
ParseError
Pattern
PointerTypeType
PreprocElifAlternative
PreprocElifChildren
PreprocElifCondition
PreprocElseChildren
PreprocIfAlternative
PreprocIfChildren
PreprocIfCondition
PreprocIfInAttributeListAlternative
PreprocIfInAttributeListCondition
PreprocLineChildren
PreprocPragmaChildren
PrimaryConstructorBaseTypeType
PropertyDeclarationChildren
PropertyDeclarationValue
QualifiedNameName
QualifiedNameQualifier
QueryExpressionChildren
RawStringLiteralChildren
RecordDeclarationChildren
RecursivePatternChildren
ScopedTypeType
Statement
StringLiteralChildren
StructDeclarationChildren
SubpatternChildren
SwitchExpressionArmChildren
SwitchExpressionChildren
SwitchSectionChildren
SwitchStatementValue
TryStatementChildren
TuplePatternChildren
Type
TypeDeclaration
TypeParameterChildren
TypeParameterConstraintsClauseChildren
UnaryExpressionArgument
UnaryExpressionOperator
UsingStatementChildren
VarPatternChildren
VariableDeclaratorChildren
WithExpressionChildren
WithInitializerChildren

Traits§

FromNode
Every generated struct and enum implements this.
LeafNode
Implemented by every generated leaf type (identifiers, literals, etc.)
Spanned
Implemented by every generated type that has a source location.