pub(super) kind: PathKind,
/// Whether the path segment has type args or not.
pub(super) has_type_args: bool,
+ /// Whether the qualifier comes from a use tree parent or not
+ pub(crate) use_tree_parent: bool,
}
impl PathCompletionCtx {
#[derive(Debug)]
pub(super) enum Qualified {
No,
- With(PathQualifierCtx),
+ With {
+ path: ast::Path,
+ resolution: Option<PathResolution>,
+ /// Whether this path consists solely of `super` segments
+ is_super_chain: bool,
+ },
/// <_>::
Infer,
/// Whether the path is an absolute path
Absolute,
}
-/// The path qualifier state of the path we are completing.
-#[derive(Debug)]
-pub(crate) struct PathQualifierCtx {
- pub(crate) path: ast::Path,
- pub(crate) resolution: Option<PathResolution>,
- /// Whether this path consists solely of `super` segments
- pub(crate) is_super_chain: bool,
- /// Whether the qualifier comes from a use tree parent or not
- pub(crate) use_tree_parent: bool,
-}
-
/// The state of the pattern we are completing.
#[derive(Debug)]
pub(super) struct PatternContext {
// FIXME: This shouldn't exist
pub(super) previous_token: Option<SyntaxToken>,
+ // We might wanna split these out of CompletionContext
pub(super) ident_ctx: IdentContext,
-
pub(super) pattern_ctx: Option<PatternContext>,
pub(super) qualifier_ctx: QualifierCtx,
FamousDefs(&self.sema, self.krate)
}
- pub(super) fn nameref_ctx(&self) -> Option<&NameRefContext> {
- match &self.ident_ctx {
- IdentContext::NameRef(it) => Some(it),
- _ => None,
- }
- }
-
- pub(super) fn name_ctx(&self) -> Option<&NameContext> {
- match &self.ident_ctx {
- IdentContext::Name(it) => Some(it),
- _ => None,
- }
- }
-
- pub(super) fn lifetime_ctx(&self) -> Option<&LifetimeContext> {
- match &self.ident_ctx {
- IdentContext::Lifetime(it) => Some(it),
- _ => None,
- }
- }
-
- pub(crate) fn dot_receiver(&self) -> Option<&ast::Expr> {
- match self.nameref_ctx() {
- Some(NameRefContext {
- kind: Some(NameRefKind::DotAccess(DotAccess { receiver, .. })),
- ..
- }) => receiver.as_ref(),
- _ => None,
- }
- }
-
- pub(crate) fn has_dot_receiver(&self) -> bool {
- self.dot_receiver().is_some()
- }
-
- pub(crate) fn path_context(&self) -> Option<&PathCompletionCtx> {
- self.nameref_ctx().and_then(|ctx| match &ctx.kind {
- Some(NameRefKind::Path(path)) => Some(path),
- _ => None,
- })
- }
-
- pub(crate) fn path_qual(&self) -> Option<&ast::Path> {
- self.path_context().and_then(|it| match &it.qualified {
- Qualified::With(it) => Some(&it.path),
- _ => None,
- })
- }
-
/// Checks if an item is visible and not `doc(hidden)` at the completion site.
pub(crate) fn is_visible<I>(&self, item: &I) -> Visible
where