Rename things: Tool -> ToolModule

This commit is contained in:
Lukas Wirth 2021-12-03 17:15:19 +01:00
parent 70b8331fd5
commit d174158abc
17 changed files with 33 additions and 33 deletions

View File

@ -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<Self> {
// FIXME: def maps registered tools
hir_def::builtin_attr::TOOL_MODULES.iter().position(|&tool| tool == name).map(Self)

View File

@ -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,

View File

@ -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,
}
}

View File

@ -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))

View File

@ -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)

View File

@ -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,
}
}

View File

@ -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.

View File

@ -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);

View File

@ -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)
}

View File

@ -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",

View File

@ -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",

View File

@ -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<PathResolution> 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),
}
}
}

View File

@ -160,7 +160,7 @@ pub enum SymbolKind {
SelfParam,
Static,
Struct,
Tool,
ToolModule,
Trait,
TypeAlias,
TypeParam,

View File

@ -166,7 +166,7 @@ impl<'a> Ctx<'a> {
| hir::PathResolution::Macro(_)
| hir::PathResolution::AssocItem(_)
| hir::PathResolution::BuiltinAttr(_)
| hir::PathResolution::Tool(_) => (),
| hir::PathResolution::ToolModule(_) => (),
}
Some(())
}

View File

@ -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;

View File

@ -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"),
];

View File

@ -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,