Skip to content

Commit

Permalink
Auto merge of #17555 - Veykril:grammar-inline, r=Veykril
Browse files Browse the repository at this point in the history
internal: Inline generated syntax methods
  • Loading branch information
bors committed Jul 7, 2024
2 parents a494aab 35aa238 commit a5b21ea
Show file tree
Hide file tree
Showing 26 changed files with 1,115 additions and 41 deletions.
4 changes: 2 additions & 2 deletions crates/hir-def/src/body/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 15,8 @@ use span::AstIdMap;
use stdx::never;
use syntax::{
ast::{
self, ArrayExprKind, AstChildren, BlockExpr, HasArgList, HasAttrs, HasLoopBody, HasName,
RangeItem, SlicePatComponents,
self, ArrayExprKind, AstChildren, BlockExpr, HasArgList, HasAttrs, HasGenericArgs,
HasLoopBody, HasName, RangeItem, SlicePatComponents,
},
AstNode, AstPtr, AstToken as _, SyntaxNodePtr,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/hir/type_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 10,7 @@ use hir_expand::{
AstId,
};
use intern::Interned;
use syntax::ast::{self, HasName, IsString};
use syntax::ast::{self, HasGenericArgs, HasName, IsString};

use crate::{
builtin_type::{BuiltinInt, BuiltinType, BuiltinUint},
Expand Down
2 changes: 1 addition & 1 deletion crates/hir-def/src/path/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 9,7 @@ use hir_expand::{
name::{name, AsName},
};
use intern::Interned;
use syntax::ast::{self, AstNode, HasTypeBounds};
use syntax::ast::{self, AstNode, HasGenericArgs, HasTypeBounds};

use crate::{
path::{AssociatedTypeBinding, GenericArg, GenericArgs, ModPath, Path, PathKind},
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-assists/src/handlers/add_turbo_fish.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
use either::Either;
use ide_db::defs::{Definition, NameRefClass};
use syntax::{
ast::{self, make, HasArgList},
ast::{self, make, HasArgList, HasGenericArgs},
ted, AstNode,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/ide-assists/src/handlers/convert_from_to_tryfrom.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
use ide_db::{famous_defs::FamousDefs, traits::resolve_target_trait};
use itertools::Itertools;
use syntax::{
ast::{self, make, AstNode, HasName},
ast::{self, make, AstNode, HasGenericArgs, HasName},
ted,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/ide-assists/src/handlers/convert_into_to_from.rs
Original file line number Diff line number Diff line change
@@ -1,6 1,6 @@
use hir::ImportPathConfig;
use ide_db::{famous_defs::FamousDefs, helpers::mod_path_to_ast, traits::resolve_target_trait};
use syntax::ast::{self, AstNode, HasName};
use syntax::ast::{self, AstNode, HasGenericArgs, HasName};

use crate::{AssistContext, AssistId, AssistKind, Assists};

Expand Down
2 changes: 1 addition & 1 deletion crates/ide-assists/src/handlers/extract_type_alias.rs
Original file line number Diff line number Diff line change
@@ -1,7 1,7 @@
use either::Either;
use ide_db::syntax_helpers::node_ext::walk_ty;
use syntax::{
ast::{self, edit::IndentLevel, make, AstNode, HasGenericParams, HasName},
ast::{self, edit::IndentLevel, make, AstNode, HasGenericArgs, HasGenericParams, HasName},
ted,
};

Expand Down
5 changes: 3 additions & 2 deletions crates/ide-assists/src/handlers/generate_delegate_trait.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 17,9 @@ use syntax::{
self,
edit::{self, AstNodeEdit},
edit_in_place::AttrsOwnerEdit,
make, AssocItem, GenericArgList, GenericParamList, HasAttrs, HasGenericParams, HasName,
HasTypeBounds, HasVisibility as astHasVisibility, Path, WherePred,
make, AssocItem, GenericArgList, GenericParamList, HasAttrs, HasGenericArgs,
HasGenericParams, HasName, HasTypeBounds, HasVisibility as astHasVisibility, Path,
WherePred,
},
ted::{self, Position},
AstNode, NodeOrToken, SmolStr, SyntaxKind,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ use itertools::Itertools;
use stdx::{format_to, to_lower_snake_case};
use syntax::{
algo::skip_whitespace_token,
ast::{self, edit::IndentLevel, HasDocComments, HasName},
ast::{self, edit::IndentLevel, HasDocComments, HasGenericArgs, HasName},
match_ast, AstNode, AstToken,
};

Expand Down
4 changes: 3 additions & 1 deletion crates/ide-assists/src/handlers/inline_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 15,9 @@ use ide_db::{
};
use itertools::{izip, Itertools};
use syntax::{
ast::{self, edit::IndentLevel, edit_in_place::Indent, HasArgList, Pat, PathExpr},
ast::{
self, edit::IndentLevel, edit_in_place::Indent, HasArgList, HasGenericArgs, Pat, PathExpr,
},
ted, AstNode, NodeOrToken, SyntaxKind,
};

Expand Down
1 change: 1 addition & 0 deletions crates/ide-assists/src/handlers/qualify_path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 6,7 @@ use ide_db::{
helpers::mod_path_to_ast,
imports::import_assets::{ImportCandidate, LocatedImport},
};
use syntax::ast::HasGenericArgs;
use syntax::{
ast,
ast::{make, HasArgList},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ use ide_db::{
imports::insert_use::{insert_use, ImportScope},
};
use syntax::{
ast::{self, make},
ast::{self, make, HasGenericArgs},
match_ast, ted, AstNode, SyntaxNode,
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 1,6 @@
use hir::HirDisplay;
use syntax::{
ast::{Expr, GenericArg, GenericArgList},
ast::{LetStmt, Type::InferType},
ast::{Expr, GenericArg, GenericArgList, HasGenericArgs, LetStmt, Type::InferType},
AstNode, TextRange,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/ide-assists/src/handlers/toggle_async_sugar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ use ide_db::{
famous_defs::FamousDefs,
};
use syntax::{
ast::{self, HasVisibility},
ast::{self, HasGenericArgs, HasVisibility},
AstNode, NodeOrToken, SyntaxKind, SyntaxNode, SyntaxToken, TextRange,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 4,7 @@ use ide_db::{
};
use itertools::Itertools;
use syntax::{
ast::{self, Expr},
ast::{self, Expr, HasGenericArgs},
match_ast, AstNode, NodeOrToken, SyntaxKind, TextRange,
};

Expand Down
5 changes: 4 additions & 1 deletion crates/ide-completion/src/context/analysis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,10 @@ use ide_db::{active_parameter::ActiveParameter, RootDatabase};
use itertools::Either;
use syntax::{
algo::{ancestors_at_offset, find_node_at_offset, non_trivia_sibling},
ast::{self, AttrKind, HasArgList, HasGenericParams, HasLoopBody, HasName, NameOrNameRef},
ast::{
self, AttrKind, HasArgList, HasGenericArgs, HasGenericParams, HasLoopBody, HasName,
NameOrNameRef,
},
match_ast, AstNode, AstToken, Direction, NodeOrToken, SyntaxElement, SyntaxKind, SyntaxNode,
SyntaxToken, TextRange, TextSize, T,
};
Expand Down
2 changes: 1 addition & 1 deletion crates/ide-db/src/path_transform.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,7 @@ use hir::{AsAssocItem, HirDisplay, ImportPathConfig, ModuleDef, SemanticsScope};
use itertools::Itertools;
use rustc_hash::FxHashMap;
use syntax::{
ast::{self, make, AstNode},
ast::{self, make, AstNode, HasGenericArgs},
ted, SyntaxNode,
};

Expand Down
2 changes: 1 addition & 1 deletion crates/ide-ssr/src/matching.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 10,7 @@ use hir::{ImportPathConfig, Semantics};
use ide_db::{base_db::FileRange, FxHashMap};
use std::{cell::Cell, iter::Peekable};
use syntax::{
ast::{self, AstNode, AstToken},
ast::{self, AstNode, AstToken, HasGenericArgs},
SmolStr, SyntaxElement, SyntaxElementChildren, SyntaxKind, SyntaxNode, SyntaxToken,
};

Expand Down
5 changes: 4 additions & 1 deletion crates/ide-ssr/src/resolving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 3,10 @@
use hir::AsAssocItem;
use ide_db::{base_db::FilePosition, FxHashMap};
use parsing::Placeholder;
use syntax::{ast, SmolStr, SyntaxKind, SyntaxNode, SyntaxToken};
use syntax::{
ast::{self, HasGenericArgs},
SmolStr, SyntaxKind, SyntaxNode, SyntaxToken,
};

use crate::{errors::error, parsing, SsrError};

Expand Down
2 changes: 1 addition & 1 deletion crates/ide/src/inlay_hints/bind_pat.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 8,7 @@ use ide_db::{base_db::FileId, famous_defs::FamousDefs, RootDatabase};

use itertools::Itertools;
use syntax::{
ast::{self, AstNode, HasName},
ast::{self, AstNode, HasGenericArgs, HasName},
match_ast,
};

Expand Down
7 changes: 5 additions & 2 deletions crates/syntax/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 31,8 @@ pub use self::{
operators::{ArithOp, BinaryOp, CmpOp, LogicOp, Ordering, RangeOp, UnaryOp},
token_ext::{CommentKind, CommentPlacement, CommentShape, IsString, QuoteOffsets, Radix},
traits::{
AttrDocCommentIter, DocCommentIter, HasArgList, HasAttrs, HasDocComments, HasGenericParams,
HasLoopBody, HasModuleItem, HasName, HasTypeBounds, HasVisibility,
AttrDocCommentIter, DocCommentIter, HasArgList, HasAttrs, HasDocComments, HasGenericArgs,
HasGenericParams, HasLoopBody, HasModuleItem, HasName, HasTypeBounds, HasVisibility,
},
};

Expand Down Expand Up @@ -149,14 149,17 @@ pub trait RangeItem {
mod support {
use super::{AstChildren, AstNode, SyntaxKind, SyntaxNode, SyntaxToken};

#[inline]
pub(super) fn child<N: AstNode>(parent: &SyntaxNode) -> Option<N> {
parent.children().find_map(N::cast)
}

#[inline]
pub(super) fn children<N: AstNode>(parent: &SyntaxNode) -> AstChildren<N> {
AstChildren::new(parent)
}

#[inline]
pub(super) fn token(parent: &SyntaxNode, kind: SyntaxKind) -> Option<SyntaxToken> {
parent.children_with_tokens().filter_map(|it| it.into_token()).find(|it| it.kind() == kind)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/syntax/src/ast/edit_in_place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 6,7 @@ use parser::{SyntaxKind, T};

use crate::{
algo::{self, neighbor},
ast::{self, edit::IndentLevel, make, HasGenericParams},
ast::{self, edit::IndentLevel, make, HasGenericArgs, HasGenericParams},
ted::{self, Position},
AstNode, AstToken, Direction, SyntaxElement,
SyntaxKind::{ATTR, COMMENT, WHITESPACE},
Expand Down
Loading

0 comments on commit a5b21ea

Please sign in to comment.