From d174158abce0ab7e9f2d3bc7556ab7070d38aaa4 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 3 Dec 2021 17:15:19 +0100 Subject: [PATCH] Rename things: Tool -> ToolModule --- crates/hir/src/lib.rs | 4 ++-- crates/hir/src/semantics.rs | 6 +++--- crates/hir/src/source_analyzer.rs | 12 ++++++------ crates/ide/src/doc_links.rs | 4 ++-- crates/ide/src/hover/render.rs | 2 +- crates/ide/src/navigation_target.rs | 2 +- crates/ide/src/syntax_highlighting.rs | 2 +- crates/ide/src/syntax_highlighting/highlight.rs | 2 +- crates/ide/src/syntax_highlighting/inject.rs | 2 +- crates/ide/src/syntax_highlighting/tags.rs | 2 +- crates/ide_completion/src/item.rs | 2 +- crates/ide_db/src/defs.rs | 12 ++++++------ crates/ide_db/src/lib.rs | 2 +- crates/ide_db/src/path_transform.rs | 2 +- crates/ide_db/src/rename.rs | 2 +- crates/rust-analyzer/src/semantic_tokens.rs | 2 +- crates/rust-analyzer/src/to_proto.rs | 6 +++--- 17 files changed, 33 insertions(+), 33 deletions(-) diff --git a/crates/hir/src/lib.rs b/crates/hir/src/lib.rs index e64a8182c9cf..c7f94ff9aa63 100644 --- a/crates/hir/src/lib.rs +++ b/crates/hir/src/lib.rs @@ -2039,9 +2039,9 @@ impl BuiltinAttr { } #[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] -pub struct Tool(usize); +pub struct ToolModule(usize); -impl Tool { +impl ToolModule { pub(crate) fn by_name(name: &str) -> Option { // FIXME: def maps registered tools hir_def::builtin_attr::TOOL_MODULES.iter().position(|&tool| tool == name).map(Self) diff --git a/crates/hir/src/semantics.rs b/crates/hir/src/semantics.rs index c48bd1b05381..ed1b2f64fd1d 100644 --- a/crates/hir/src/semantics.rs +++ b/crates/hir/src/semantics.rs @@ -27,7 +27,7 @@ use crate::{ source_analyzer::{resolve_hir_path, resolve_hir_path_as_macro, SourceAnalyzer}, Access, AssocItem, BuiltinAttr, Callable, ConstParam, Crate, Field, Function, HasSource, HirFileId, Impl, InFile, Label, LifetimeParam, Local, MacroDef, Module, ModuleDef, Name, Path, - ScopeDef, Tool, Trait, Type, TypeAlias, TypeParam, VariantDef, + ScopeDef, ToolModule, Trait, Type, TypeAlias, TypeParam, VariantDef, }; #[derive(Debug, Clone, PartialEq, Eq)] @@ -44,7 +44,7 @@ pub enum PathResolution { Macro(MacroDef), AssocItem(AssocItem), BuiltinAttr(BuiltinAttr), - Tool(Tool), + ToolModule(ToolModule), } impl PathResolution { @@ -66,7 +66,7 @@ impl PathResolution { Some(TypeNs::TypeAliasId((*alias).into())) } PathResolution::BuiltinAttr(_) - | PathResolution::Tool(_) + | PathResolution::ToolModule(_) | PathResolution::Local(_) | PathResolution::Macro(_) | PathResolution::ConstParam(_) => None, diff --git a/crates/hir/src/source_analyzer.rs b/crates/hir/src/source_analyzer.rs index e14cd43ede85..762f172c2afd 100644 --- a/crates/hir/src/source_analyzer.rs +++ b/crates/hir/src/source_analyzer.rs @@ -30,8 +30,8 @@ use syntax::{ use crate::{ db::HirDatabase, semantics::PathResolution, Adt, BuiltinAttr, BuiltinType, Const, Field, - Function, Local, MacroDef, ModuleDef, Static, Struct, Tool, Trait, Type, TypeAlias, TypeParam, - Variant, + Function, Local, MacroDef, ModuleDef, Static, Struct, ToolModule, Trait, Type, TypeAlias, + TypeParam, Variant, }; use base_db::CrateId; @@ -341,8 +341,8 @@ impl SourceAnalyzer { None => path.as_single_name_ref().and_then(|name_ref| { if let builtin @ Some(_) = BuiltinAttr::by_name(&name_ref.text()) { builtin.map(PathResolution::BuiltinAttr) - } else if let tool @ Some(_) = Tool::by_name(&name_ref.text()) { - tool.map(PathResolution::Tool) + } else if let tool @ Some(_) = ToolModule::by_name(&name_ref.text()) { + tool.map(PathResolution::ToolModule) } else { None } @@ -362,8 +362,8 @@ impl SourceAnalyzer { None if is_path_of_attr => path .first_segment() .and_then(|seg| seg.name_ref()) - .and_then(|name_ref| Tool::by_name(&name_ref.text())) - .map(PathResolution::Tool), + .and_then(|name_ref| ToolModule::by_name(&name_ref.text())) + .map(PathResolution::ToolModule), None => None, } } diff --git a/crates/ide/src/doc_links.rs b/crates/ide/src/doc_links.rs index edcea7aace78..617f63d35828 100644 --- a/crates/ide/src/doc_links.rs +++ b/crates/ide/src/doc_links.rs @@ -182,7 +182,7 @@ pub(crate) fn resolve_doc_path_for_def( Definition::Macro(it) => it.resolve_doc_path(db, link, ns), Definition::Field(it) => it.resolve_doc_path(db, link, ns), Definition::BuiltinAttr(_) - | Definition::Tool(_) + | Definition::ToolModule(_) | Definition::BuiltinType(_) | Definition::SelfType(_) | Definition::Local(_) @@ -498,7 +498,7 @@ fn filename_and_frag_for_def( | Definition::GenericParam(_) | Definition::Label(_) | Definition::BuiltinAttr(_) - | Definition::Tool(_) => return None, + | Definition::ToolModule(_) => return None, }; Some((def, res, None)) diff --git a/crates/ide/src/hover/render.rs b/crates/ide/src/hover/render.rs index 46f5b2e35be1..393bb253b61a 100644 --- a/crates/ide/src/hover/render.rs +++ b/crates/ide/src/hover/render.rs @@ -371,7 +371,7 @@ pub(super) fn definition( Definition::Label(it) => return Some(Markup::fenced_block(&it.name(db))), // FIXME: We should be able to show more info about these Definition::BuiltinAttr(it) => return Some(Markup::fenced_block(&it.name(db))), - Definition::Tool(it) => return Some(Markup::fenced_block(&it.name(db))), + Definition::ToolModule(it) => return Some(Markup::fenced_block(&it.name(db))), }; markup(docs.filter(|_| config.documentation.is_some()).map(Into::into), label, mod_path) diff --git a/crates/ide/src/navigation_target.rs b/crates/ide/src/navigation_target.rs index aa865ddc21d6..49ff3625caa7 100644 --- a/crates/ide/src/navigation_target.rs +++ b/crates/ide/src/navigation_target.rs @@ -214,7 +214,7 @@ impl TryToNav for Definition { Definition::Trait(it) => it.try_to_nav(db), Definition::TypeAlias(it) => it.try_to_nav(db), Definition::BuiltinType(_) => None, - Definition::Tool(_) => None, + Definition::ToolModule(_) => None, Definition::BuiltinAttr(_) => None, } } diff --git a/crates/ide/src/syntax_highlighting.rs b/crates/ide/src/syntax_highlighting.rs index 118f8dd9be05..56e07da0b900 100644 --- a/crates/ide/src/syntax_highlighting.rs +++ b/crates/ide/src/syntax_highlighting.rs @@ -115,7 +115,7 @@ pub struct HlRange { // parameter:: Emitted for non-self function parameters. // property:: Emitted for struct and union fields. // selfKeyword:: Emitted for the self function parameter and self path-specifier. -// tool:: Emitted for tool modules. +// toolModule:: Emitted for tool modules. // typeParameter:: Emitted for type parameters. // unresolvedReference:: Emitted for unresolved references, names that rust-analyzer can't find the definition of. // variable:: Emitted for locals, constants and statics. diff --git a/crates/ide/src/syntax_highlighting/highlight.rs b/crates/ide/src/syntax_highlighting/highlight.rs index 340168a90d0f..34c4ccd4c76a 100644 --- a/crates/ide/src/syntax_highlighting/highlight.rs +++ b/crates/ide/src/syntax_highlighting/highlight.rs @@ -513,7 +513,7 @@ fn highlight_def( } Definition::Label(_) => Highlight::new(HlTag::Symbol(SymbolKind::Label)), Definition::BuiltinAttr(_) => Highlight::new(HlTag::Symbol(SymbolKind::BuiltinAttr)), - Definition::Tool(_) => Highlight::new(HlTag::Symbol(SymbolKind::Tool)), + Definition::ToolModule(_) => Highlight::new(HlTag::Symbol(SymbolKind::ToolModule)), }; let famous_defs = FamousDefs(sema, krate); diff --git a/crates/ide/src/syntax_highlighting/inject.rs b/crates/ide/src/syntax_highlighting/inject.rs index 50f74cdec1b1..a3b05ee26332 100644 --- a/crates/ide/src/syntax_highlighting/inject.rs +++ b/crates/ide/src/syntax_highlighting/inject.rs @@ -264,7 +264,7 @@ fn module_def_to_hl_tag(def: Definition) -> HlTag { }, Definition::Label(_) => SymbolKind::Label, Definition::BuiltinAttr(_) => SymbolKind::BuiltinAttr, - Definition::Tool(_) => SymbolKind::Tool, + Definition::ToolModule(_) => SymbolKind::ToolModule, }; HlTag::Symbol(symbol) } diff --git a/crates/ide/src/syntax_highlighting/tags.rs b/crates/ide/src/syntax_highlighting/tags.rs index a19eee58172f..3e0a78392a38 100644 --- a/crates/ide/src/syntax_highlighting/tags.rs +++ b/crates/ide/src/syntax_highlighting/tags.rs @@ -139,7 +139,7 @@ impl HlTag { SymbolKind::SelfParam => "self_keyword", SymbolKind::Static => "static", SymbolKind::Struct => "struct", - SymbolKind::Tool => "tool", + SymbolKind::ToolModule => "tool_module", SymbolKind::Trait => "trait", SymbolKind::TypeAlias => "type_alias", SymbolKind::TypeParam => "type_param", diff --git a/crates/ide_completion/src/item.rs b/crates/ide_completion/src/item.rs index e80a8edd9cff..b3f404d9053d 100644 --- a/crates/ide_completion/src/item.rs +++ b/crates/ide_completion/src/item.rs @@ -247,7 +247,7 @@ impl CompletionItemKind { SymbolKind::SelfParam => "sp", SymbolKind::Static => "sc", SymbolKind::Struct => "st", - SymbolKind::Tool => "tl", + SymbolKind::ToolModule => "tm", SymbolKind::Trait => "tt", SymbolKind::TypeAlias => "ta", SymbolKind::TypeParam => "tp", diff --git a/crates/ide_db/src/defs.rs b/crates/ide_db/src/defs.rs index 26cdaa1ac145..ef2f0f940f51 100644 --- a/crates/ide_db/src/defs.rs +++ b/crates/ide_db/src/defs.rs @@ -9,7 +9,7 @@ use arrayvec::ArrayVec; use hir::{ Adt, AsAssocItem, AssocItem, BuiltinAttr, BuiltinType, Const, Field, Function, GenericParam, HasVisibility, Impl, ItemInNs, Label, Local, MacroDef, Module, ModuleDef, Name, PathResolution, - Semantics, Static, Tool, Trait, TypeAlias, Variant, Visibility, + Semantics, Static, ToolModule, Trait, TypeAlias, Variant, Visibility, }; use stdx::impl_from; use syntax::{ @@ -38,7 +38,7 @@ pub enum Definition { GenericParam(GenericParam), Label(Label), BuiltinAttr(BuiltinAttr), - Tool(Tool), + ToolModule(ToolModule), } impl Definition { @@ -129,7 +129,7 @@ impl Definition { Definition::Local(it) => it.module(db), Definition::GenericParam(it) => it.module(db), Definition::Label(it) => it.module(db), - Definition::BuiltinAttr(_) | Definition::BuiltinType(_) | Definition::Tool(_) => { + Definition::BuiltinAttr(_) | Definition::BuiltinType(_) | Definition::ToolModule(_) => { return None } }; @@ -150,7 +150,7 @@ impl Definition { Definition::BuiltinType(_) => Visibility::Public, Definition::Macro(_) => return None, Definition::BuiltinAttr(_) - | Definition::Tool(_) + | Definition::ToolModule(_) | Definition::SelfType(_) | Definition::Local(_) | Definition::GenericParam(_) @@ -177,7 +177,7 @@ impl Definition { Definition::GenericParam(it) => it.name(db), Definition::Label(it) => it.name(db), Definition::BuiltinAttr(_) => return None, // FIXME - Definition::Tool(_) => return None, // FIXME + Definition::ToolModule(_) => return None, // FIXME }; Some(name) } @@ -551,7 +551,7 @@ impl From for Definition { PathResolution::SelfType(impl_def) => Definition::SelfType(impl_def), PathResolution::ConstParam(par) => Definition::GenericParam(par.into()), PathResolution::BuiltinAttr(attr) => Definition::BuiltinAttr(attr), - PathResolution::Tool(tool) => Definition::Tool(tool), + PathResolution::ToolModule(tool) => Definition::ToolModule(tool), } } } diff --git a/crates/ide_db/src/lib.rs b/crates/ide_db/src/lib.rs index 6eaea53f5c1f..67f23536bd8b 100644 --- a/crates/ide_db/src/lib.rs +++ b/crates/ide_db/src/lib.rs @@ -160,7 +160,7 @@ pub enum SymbolKind { SelfParam, Static, Struct, - Tool, + ToolModule, Trait, TypeAlias, TypeParam, diff --git a/crates/ide_db/src/path_transform.rs b/crates/ide_db/src/path_transform.rs index a4db8b3848ba..1b4f793a507f 100644 --- a/crates/ide_db/src/path_transform.rs +++ b/crates/ide_db/src/path_transform.rs @@ -166,7 +166,7 @@ impl<'a> Ctx<'a> { | hir::PathResolution::Macro(_) | hir::PathResolution::AssocItem(_) | hir::PathResolution::BuiltinAttr(_) - | hir::PathResolution::Tool(_) => (), + | hir::PathResolution::ToolModule(_) => (), } Some(()) } diff --git a/crates/ide_db/src/rename.rs b/crates/ide_db/src/rename.rs index 35bd4d02a634..60160f9553e9 100644 --- a/crates/ide_db/src/rename.rs +++ b/crates/ide_db/src/rename.rs @@ -147,7 +147,7 @@ impl Definition { Definition::BuiltinType(_) => return None, Definition::SelfType(_) => return None, Definition::BuiltinAttr(_) => return None, - Definition::Tool(_) => return None, + Definition::ToolModule(_) => return None, }; return res; diff --git a/crates/rust-analyzer/src/semantic_tokens.rs b/crates/rust-analyzer/src/semantic_tokens.rs index 9d19482bee32..8e1ccfb397bd 100644 --- a/crates/rust-analyzer/src/semantic_tokens.rs +++ b/crates/rust-analyzer/src/semantic_tokens.rs @@ -65,7 +65,7 @@ define_semantic_token_types![ (SELF_KEYWORD, "selfKeyword"), (SEMICOLON, "semicolon"), (TYPE_ALIAS, "typeAlias"), - (TOOL, "tool"), + (TOOL_MODULE, "toolModule"), (UNION, "union"), (UNRESOLVED_REFERENCE, "unresolvedReference"), ]; diff --git a/crates/rust-analyzer/src/to_proto.rs b/crates/rust-analyzer/src/to_proto.rs index 1dd4dabec4da..579ad22baca1 100644 --- a/crates/rust-analyzer/src/to_proto.rs +++ b/crates/rust-analyzer/src/to_proto.rs @@ -51,7 +51,7 @@ pub(crate) fn symbol_kind(symbol_kind: SymbolKind) -> lsp_types::SymbolKind { SymbolKind::Variant => lsp_types::SymbolKind::ENUM_MEMBER, SymbolKind::Trait => lsp_types::SymbolKind::INTERFACE, SymbolKind::Macro | SymbolKind::BuiltinAttr => lsp_types::SymbolKind::FUNCTION, - SymbolKind::Module | SymbolKind::Tool => lsp_types::SymbolKind::MODULE, + SymbolKind::Module | SymbolKind::ToolModule => lsp_types::SymbolKind::MODULE, SymbolKind::TypeAlias | SymbolKind::TypeParam => lsp_types::SymbolKind::TYPE_PARAMETER, SymbolKind::Field => lsp_types::SymbolKind::FIELD, SymbolKind::Static => lsp_types::SymbolKind::CONSTANT, @@ -129,7 +129,7 @@ pub(crate) fn completion_item_kind( SymbolKind::ValueParam => lsp_types::CompletionItemKind::VALUE, SymbolKind::Variant => lsp_types::CompletionItemKind::ENUM_MEMBER, SymbolKind::BuiltinAttr => lsp_types::CompletionItemKind::FUNCTION, - SymbolKind::Tool => lsp_types::CompletionItemKind::MODULE, + SymbolKind::ToolModule => lsp_types::CompletionItemKind::MODULE, }, } } @@ -502,7 +502,7 @@ fn semantic_token_type_and_modifiers( SymbolKind::Trait => lsp_types::SemanticTokenType::INTERFACE, SymbolKind::Macro => lsp_types::SemanticTokenType::MACRO, SymbolKind::BuiltinAttr => semantic_tokens::BUILTIN_ATTRIBUTE, - SymbolKind::Tool => semantic_tokens::TOOL, + SymbolKind::ToolModule => semantic_tokens::TOOL_MODULE, }, HlTag::Attribute => semantic_tokens::ATTRIBUTE, HlTag::BoolLiteral => semantic_tokens::BOOLEAN,