pub(crate) mod snippet;
pub(crate) mod trait_impl;
pub(crate) mod unqualified_path;
+pub(crate) mod format_string;
use std::iter;
use ide_db::SymbolKind;
use crate::{
- item::{Builder, CompletionKind},
+ item::Builder,
render::{
const_::render_const,
enum_variant::render_variant,
macro_::render_macro,
pattern::{render_struct_pat, render_variant_pat},
render_field, render_resolution, render_tuple_field,
+ struct_literal::render_struct_literal,
type_alias::{render_type_alias, render_type_alias_with_eq},
RenderContext,
},
items.into_iter().for_each(|item| self.add(item.into()))
}
+ pub(crate) fn add_keyword(&mut self, ctx: &CompletionContext, keyword: &'static str) {
+ let item = CompletionItem::new(CompletionItemKind::Keyword, ctx.source_range(), keyword);
+ item.add_to(self);
+ }
+
pub(crate) fn add_resolution(
&mut self,
ctx: &CompletionContext,
local_name: hir::Name,
- resolution: &hir::ScopeDef,
+ resolution: hir::ScopeDef,
) {
- self.add_opt(render_resolution(RenderContext::new(ctx), local_name, resolution));
+ if ctx.is_scope_def_hidden(resolution) {
+ cov_mark::hit!(qualified_path_doc_hidden);
+ return;
+ }
+ self.add(render_resolution(RenderContext::new(ctx), local_name, resolution));
}
pub(crate) fn add_macro(
Some(it) => it,
None => return,
};
- self.add_opt(render_macro(RenderContext::new(ctx), None, name, macro_));
+ self.add(render_macro(RenderContext::new(ctx), None, name, macro_));
}
pub(crate) fn add_function(
func: hir::Function,
local_name: Option<hir::Name>,
) {
- self.add_opt(render_fn(RenderContext::new(ctx), None, local_name, func));
+ if !ctx.is_visible(&func) {
+ return;
+ }
+ self.add(render_fn(RenderContext::new(ctx), None, local_name, func));
}
pub(crate) fn add_method(
receiver: Option<hir::Name>,
local_name: Option<hir::Name>,
) {
- self.add_opt(render_method(RenderContext::new(ctx), None, receiver, local_name, func));
+ if !ctx.is_visible(&func) {
+ return;
+ }
+ self.add(render_method(RenderContext::new(ctx), None, receiver, local_name, func));
}
- pub(crate) fn add_const(&mut self, ctx: &CompletionContext, constant: hir::Const) {
- self.add_opt(render_const(RenderContext::new(ctx), constant));
+ pub(crate) fn add_const(&mut self, ctx: &CompletionContext, konst: hir::Const) {
+ if !ctx.is_visible(&konst) {
+ return;
+ }
+ self.add_opt(render_const(RenderContext::new(ctx), konst));
}
pub(crate) fn add_type_alias(&mut self, ctx: &CompletionContext, type_alias: hir::TypeAlias) {
+ if !ctx.is_visible(&type_alias) {
+ return;
+ }
self.add_opt(render_type_alias(RenderContext::new(ctx), type_alias));
}
field: hir::Field,
ty: &hir::Type,
) {
+ if !ctx.is_visible(&field) {
+ return;
+ }
let item = render_field(RenderContext::new(ctx), receiver, field, ty);
self.add(item);
}
+ pub(crate) fn add_struct_literal(
+ &mut self,
+ ctx: &CompletionContext,
+ strukt: hir::Struct,
+ path: Option<hir::ModPath>,
+ local_name: Option<hir::Name>,
+ ) {
+ let item = render_struct_literal(RenderContext::new(ctx), strukt, path, local_name);
+ self.add_opt(item);
+ }
+
pub(crate) fn add_tuple_field(
&mut self,
ctx: &CompletionContext,
}
pub(crate) fn add_static_lifetime(&mut self, ctx: &CompletionContext) {
- let mut item =
- CompletionItem::new(CompletionKind::Reference, ctx.source_range(), "'static");
- item.kind(CompletionItemKind::SymbolKind(SymbolKind::LifetimeParam));
+ let item = CompletionItem::new(SymbolKind::LifetimeParam, ctx.source_range(), "'static");
self.add(item.build());
}