capture_type

func capture_type(source_id: Int, source: String, input: TokenRange, context: &SyntaxContext) -> SyntaxResult<TypeAnnotation>

Validates input as exactly one type annotation with use-site hygiene.

The resulting syntax keeps source token boundaries and can only be spliced into a compatible type grammar position.

View Source
pub func capture_type(source_id: Int, source: String, input: TokenRange, context: &SyntaxContext) -> SyntaxResult<TypeAnnotation> {
	let outcome = parse_type_tokens(source: source, input: input)
	if let .some(failure) = parse_failure(outcome: outcome, fallback: input.span) {
		return SyntaxResult<TypeAnnotation>(value: .none, failure: .some(failure))
	}
	let raw = raw_from_range(source_id: source_id, source: source, input: input, category: .type_annotation, context: context, origin: .use_site)
	SyntaxResult<TypeAnnotation>(value: .some(Syntax<TypeAnnotation>(raw: raw)), failure: .none)
}