func capture_decl(source_id: Int, source: String, input: TokenRange, context: &SyntaxContext) -> SyntaxResult<Decl>Validates input as one top-level declaration with use-site hygiene.
Declaration grammar depends on context; wrapper targets inside nominal bodies should use capture_decl_in instead so methods and members parse correctly.
View Source
pub func capture_decl(source_id: Int, source: String, input: TokenRange, context: &SyntaxContext) -> SyntaxResult<Decl> {
let outcome = parse_decl_tokens(source: source, input: input)
if let .some(failure) = parse_failure(outcome: outcome, fallback: input.span) {
return SyntaxResult<Decl>(value: .none, failure: .some(failure))
}
let raw = raw_from_range(source_id: source_id, source: source, input: input, category: .decl, context: context, origin: .use_site)
SyntaxResult<Decl>(value: .some(Syntax<Decl>(raw: raw)), failure: .none)
}