Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions crates/ra_assists/src/handlers/add_explicit_type.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use hir::HirDisplay;
use ra_syntax::{
ast::{self, AstNode, LetStmt, NameOwner, TypeAscriptionOwner},
ast::{self, AstNode, AstToken, LetStmt, NameOwner, TypeAscriptionOwner},
TextRange,
};

Expand Down Expand Up @@ -35,7 +35,7 @@ pub(crate) fn add_explicit_type(ctx: AssistCtx) -> Option<Assist> {
let name = pat.name()?;
let name_range = name.syntax().text_range();
let stmt_range = stmt.syntax().text_range();
let eq_range = stmt.eq_token()?.text_range();
let eq_range = stmt.eq_token()?.syntax().text_range();
// Assist should only be applicable if cursor is between 'let' and '='
let let_range = TextRange::from_to(stmt_range.start(), eq_range.start());
let cursor_in_range = ctx.frange.range.is_subrange(&let_range);
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_assists/src/handlers/add_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pub(crate) fn add_impl(ctx: AssistCtx) -> Option<Assist> {
if let Some(type_params) = type_params {
let lifetime_params = type_params
.lifetime_params()
.filter_map(|it| it.lifetime())
.filter_map(|it| it.lifetime_token())
.map(|it| it.text().clone());
let type_params =
type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone());
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_assists/src/handlers/add_new.rs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ fn generate_impl_text(strukt: &ast::StructDef, code: &str) -> String {
if let Some(type_params) = type_params {
let lifetime_params = type_params
.lifetime_params()
.filter_map(|it| it.lifetime())
.filter_map(|it| it.lifetime_token())
.map(|it| it.text().clone());
let type_params =
type_params.type_params().filter_map(|it| it.name()).map(|it| it.text().clone());
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_assists/src/handlers/inline_local_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub(crate) fn inline_local_variable(ctx: AssistCtx) -> Option<Assist> {
ast::Pat::BindPat(pat) => pat,
_ => return None,
};
if bind_pat.is_mutable() {
if bind_pat.mut_kw_token().is_some() {
tested_by!(test_not_inline_mut_variable);
return None;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_assists/src/handlers/introduce_variable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ pub(crate) fn introduce_variable(ctx: AssistCtx) -> Option<Assist> {
};
if is_full_stmt {
tested_by!(test_introduce_var_expr_stmt);
if !full_stmt.unwrap().has_semi() {
if full_stmt.unwrap().semi_token().is_none() {
buf.push_str(";");
}
edit.replace(expr.syntax().text_range(), buf);
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_assists/src/handlers/merge_imports.rs
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ fn try_merge_trees(old: &ast::UseTree, new: &ast::UseTree) -> Option<ast::UseTre
.filter(|it| it.kind() != T!['{'] && it.kind() != T!['}']),
);
let use_tree_list = lhs.use_tree_list()?;
let pos = InsertPosition::Before(use_tree_list.r_curly()?.syntax().clone().into());
let pos = InsertPosition::Before(use_tree_list.r_curly_token()?.syntax().clone().into());
let use_tree_list = use_tree_list.insert_children(pos, to_insert);
Some(lhs.with_use_tree_list(use_tree_list))
}
Expand Down
7 changes: 5 additions & 2 deletions crates/ra_hir_def/src/body/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,10 @@ impl ExprCollector<'_> {
let pattern = match &pat {
ast::Pat::BindPat(bp) => {
let name = bp.name().map(|nr| nr.as_name()).unwrap_or_else(Name::missing);
let annotation = BindingAnnotation::new(bp.is_mutable(), bp.is_ref());
let annotation = BindingAnnotation::new(
bp.mut_kw_token().is_some(),
bp.ref_kw_token().is_some(),
);
let subpat = bp.pat().map(|subpat| self.collect_pat(subpat));
if annotation == BindingAnnotation::Unannotated && subpat.is_none() {
// This could also be a single-segment path pattern. To
Expand Down Expand Up @@ -613,7 +616,7 @@ impl ExprCollector<'_> {
}
ast::Pat::RefPat(p) => {
let pat = self.collect_pat_opt(p.pat());
let mutability = Mutability::from_mutable(p.is_mut());
let mutability = Mutability::from_mutable(p.mut_kw_token().is_some());
Pat::Ref { pat, mutability }
}
ast::Pat::PathPat(p) => {
Expand Down
6 changes: 3 additions & 3 deletions crates/ra_hir_def/src/data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ impl FunctionData {
TypeRef::unit()
};

let ret_type = if src.value.is_async() {
let ret_type = if src.value.async_kw_token().is_some() {
let future_impl = desugar_future_path(ret_type);
let ty_bound = TypeBound::Path(future_impl);
TypeRef::ImplTrait(vec![ty_bound])
Expand Down Expand Up @@ -136,7 +136,7 @@ impl TraitData {
pub(crate) fn trait_data_query(db: &dyn DefDatabase, tr: TraitId) -> Arc<TraitData> {
let src = tr.lookup(db).source(db);
let name = src.value.name().map_or_else(Name::missing, |n| n.as_name());
let auto = src.value.is_auto();
let auto = src.value.auto_kw_token().is_some();
let ast_id_map = db.ast_id_map(src.file_id);

let container = AssocContainerId::TraitId(tr);
Expand Down Expand Up @@ -213,7 +213,7 @@ impl ImplData {

let target_trait = src.value.target_trait().map(TypeRef::from_ast);
let target_type = TypeRef::from_ast_opt(src.value.target_type());
let is_negative = src.value.is_negative();
let is_negative = src.value.excl_token().is_some();
let module_id = impl_loc.container.module(db);

let mut items = Vec::new();
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_hir_def/src/generics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ impl GenericParams {
}

fn add_where_predicate_from_bound(&mut self, bound: ast::TypeBound, type_ref: TypeRef) {
if bound.has_question_mark() {
if bound.question_token().is_some() {
// FIXME: remove this bound
return;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_hir_def/src/nameres/raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ impl RawItemsCollector {
let visibility = RawVisibility::from_ast_with_hygiene(module.visibility(), &self.hygiene);

let ast_id = self.source_ast_id_map.ast_id(&module);
if module.has_semi() {
if module.semi_token().is_some() {
let item =
self.raw_items.modules.alloc(ModuleData::Declaration { name, visibility, ast_id });
self.push_item(current_module, attrs, RawItemKind::Module(item));
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_hir_def/src/path/lower.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub(super) fn lower_path(mut path: ast::Path, hygiene: &Hygiene) -> Option<Path>
loop {
let segment = path.segment()?;

if segment.coloncolon().is_some() {
if segment.coloncolon_token().is_some() {
kind = PathKind::Abs;
}

Expand Down
2 changes: 1 addition & 1 deletion crates/ra_hir_def/src/path/lower/lower_use.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ pub(crate) fn lower_use_tree(
let alias = tree.alias().map(|a| {
a.name().map(|it| it.as_name()).map_or(ImportAlias::Underscore, ImportAlias::Alias)
});
let is_glob = tree.star().is_some();
let is_glob = tree.star_token().is_some();
if let Some(ast_path) = tree.path() {
// Handle self in a path.
// E.g. `use something::{self, <...>}`
Expand Down
4 changes: 2 additions & 2 deletions crates/ra_hir_def/src/type_ref.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl TypeRef {
}
ast::TypeRef::PointerType(inner) => {
let inner_ty = TypeRef::from_ast_opt(inner.type_ref());
let mutability = Mutability::from_mutable(inner.is_mut());
let mutability = Mutability::from_mutable(inner.mut_kw_token().is_some());
TypeRef::RawPtr(Box::new(inner_ty), mutability)
}
ast::TypeRef::ArrayType(inner) => {
Expand All @@ -88,7 +88,7 @@ impl TypeRef {
}
ast::TypeRef::ReferenceType(inner) => {
let inner_ty = TypeRef::from_ast_opt(inner.type_ref());
let mutability = Mutability::from_mutable(inner.is_mut());
let mutability = Mutability::from_mutable(inner.mut_kw_token().is_some());
TypeRef::Reference(Box::new(inner_ty), mutability)
}
ast::TypeRef::PlaceholderType(_inner) => TypeRef::Placeholder,
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_hir_ty/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ fn infer_with_mismatches(content: &str, include_mismatches: bool) -> String {
let node = src_ptr.value.to_node(&src_ptr.file_syntax(&db));

let (range, text) = if let Some(self_param) = ast::SelfParam::cast(node.clone()) {
(self_param.self_kw().unwrap().syntax().text_range(), "self".to_string())
(self_param.self_kw_token().unwrap().syntax().text_range(), "self".to_string())
} else {
(src_ptr.value.range(), node.text().to_string().replace("\n", " "))
};
Expand Down
5 changes: 4 additions & 1 deletion crates/ra_ide/src/completion/completion_context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,10 @@ impl<'a> CompletionContext<'a> {
if let Some(name) = find_node_at_offset::<ast::Name>(&file_with_fake_ident, offset) {
if let Some(bind_pat) = name.syntax().ancestors().find_map(ast::BindPat::cast) {
self.is_pat_binding_or_const = true;
if bind_pat.has_at() || bind_pat.is_ref() || bind_pat.is_mutable() {
if bind_pat.at_token().is_some()
|| bind_pat.ref_kw_token().is_some()
|| bind_pat.mut_kw_token().is_some()
{
self.is_pat_binding_or_const = false;
}
if bind_pat.syntax().parent().and_then(ast::RecordFieldPatList::cast).is_some() {
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_ide/src/references.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ fn decl_access(def: &Definition, syntax: &SyntaxNode, range: TextRange) -> Optio
if stmt.initializer().is_some() {
let pat = stmt.pat()?;
if let ast::Pat::BindPat(it) = pat {
if it.is_mutable() {
if it.mut_kw_token().is_some() {
return Some(ReferenceAccess::Write);
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_ide/src/typing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ fn on_char_typed_inner(
fn on_eq_typed(file: &SourceFile, offset: TextUnit) -> Option<SingleFileChange> {
assert_eq!(file.syntax().text().char_at(offset), Some('='));
let let_stmt: ast::LetStmt = find_node_at_offset(file.syntax(), offset)?;
if let_stmt.has_semi() {
if let_stmt.semi_token().is_some() {
return None;
}
if let Some(expr) = let_stmt.initializer() {
Expand Down
2 changes: 1 addition & 1 deletion crates/ra_syntax/src/ast.rs
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ where
let pred = predicates.next().unwrap();
let mut bounds = pred.type_bound_list().unwrap().bounds();

assert_eq!("'a", pred.lifetime().unwrap().text());
assert_eq!("'a", pred.lifetime_token().unwrap().text());

assert_bound("'b", bounds.next());
assert_bound("'c", bounds.next());
Expand Down
10 changes: 5 additions & 5 deletions crates/ra_syntax/src/ast/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ impl ast::FnDef {
let mut to_insert: ArrayVec<[SyntaxElement; 2]> = ArrayVec::new();
let old_body_or_semi: SyntaxElement = if let Some(old_body) = self.body() {
old_body.syntax().clone().into()
} else if let Some(semi) = self.semicolon_token() {
} else if let Some(semi) = self.semi_token() {
to_insert.push(make::tokens::single_space().into());
semi.into()
semi.syntax.clone().into()
} else {
to_insert.push(make::tokens::single_space().into());
to_insert.push(body.syntax().clone().into());
Expand Down Expand Up @@ -96,7 +96,7 @@ impl ast::ItemList {
leading_indent(it.syntax()).unwrap_or_default().to_string(),
InsertPosition::After(it.syntax().clone().into()),
),
None => match self.l_curly() {
None => match self.l_curly_token() {
Some(it) => (
" ".to_string() + &leading_indent(self.syntax()).unwrap_or_default(),
InsertPosition::After(it.syntax().clone().into()),
Expand Down Expand Up @@ -142,7 +142,7 @@ impl ast::RecordFieldList {

macro_rules! after_l_curly {
() => {{
let anchor = match self.l_curly() {
let anchor = match self.l_curly_token() {
Some(it) => it.syntax().clone().into(),
None => return self.clone(),
};
Expand Down Expand Up @@ -301,7 +301,7 @@ impl ast::UseTree {
suffix.clone(),
self.use_tree_list(),
self.alias(),
self.star().is_some(),
self.star_token().is_some(),
);
let nested = make::use_tree_list(iter::once(use_tree));
return make::use_tree(prefix.clone(), Some(nested), None, false);
Expand Down
Loading