mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
internal: Compute syntax validation errors on demand
This commit is contained in:
parent
4303e741de
commit
c3c9f5ffe1
11 changed files with 45 additions and 44 deletions
|
@ -15,34 +15,32 @@ use crate::{
|
|||
SyntaxNode, SyntaxToken, TextSize, T,
|
||||
};
|
||||
|
||||
pub(crate) fn validate(root: &SyntaxNode) -> Vec<SyntaxError> {
|
||||
pub(crate) fn validate(root: &SyntaxNode, errors: &mut Vec<SyntaxError>) {
|
||||
let _p = tracing::span!(tracing::Level::INFO, "parser::validate").entered();
|
||||
// FIXME:
|
||||
// * Add unescape validation of raw string literals and raw byte string literals
|
||||
// * Add validation of doc comments are being attached to nodes
|
||||
|
||||
let mut errors = Vec::new();
|
||||
for node in root.descendants() {
|
||||
match_ast! {
|
||||
match node {
|
||||
ast::Literal(it) => validate_literal(it, &mut errors),
|
||||
ast::Const(it) => validate_const(it, &mut errors),
|
||||
ast::BlockExpr(it) => block::validate_block_expr(it, &mut errors),
|
||||
ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), &mut errors),
|
||||
ast::RecordExprField(it) => validate_numeric_name(it.name_ref(), &mut errors),
|
||||
ast::Visibility(it) => validate_visibility(it, &mut errors),
|
||||
ast::RangeExpr(it) => validate_range_expr(it, &mut errors),
|
||||
ast::PathSegment(it) => validate_path_keywords(it, &mut errors),
|
||||
ast::RefType(it) => validate_trait_object_ref_ty(it, &mut errors),
|
||||
ast::PtrType(it) => validate_trait_object_ptr_ty(it, &mut errors),
|
||||
ast::FnPtrType(it) => validate_trait_object_fn_ptr_ret_ty(it, &mut errors),
|
||||
ast::MacroRules(it) => validate_macro_rules(it, &mut errors),
|
||||
ast::LetExpr(it) => validate_let_expr(it, &mut errors),
|
||||
ast::Literal(it) => validate_literal(it, errors),
|
||||
ast::Const(it) => validate_const(it, errors),
|
||||
ast::BlockExpr(it) => block::validate_block_expr(it, errors),
|
||||
ast::FieldExpr(it) => validate_numeric_name(it.name_ref(), errors),
|
||||
ast::RecordExprField(it) => validate_numeric_name(it.name_ref(), errors),
|
||||
ast::Visibility(it) => validate_visibility(it, errors),
|
||||
ast::RangeExpr(it) => validate_range_expr(it, errors),
|
||||
ast::PathSegment(it) => validate_path_keywords(it, errors),
|
||||
ast::RefType(it) => validate_trait_object_ref_ty(it, errors),
|
||||
ast::PtrType(it) => validate_trait_object_ptr_ty(it, errors),
|
||||
ast::FnPtrType(it) => validate_trait_object_fn_ptr_ret_ty(it, errors),
|
||||
ast::MacroRules(it) => validate_macro_rules(it, errors),
|
||||
ast::LetExpr(it) => validate_let_expr(it, errors),
|
||||
_ => (),
|
||||
}
|
||||
}
|
||||
}
|
||||
errors
|
||||
}
|
||||
|
||||
fn rustc_unescape_error_to_string(err: unescape::EscapeError) -> (&'static str, bool) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue