Revert "Merge #2629"

This reverts commit cdc9d682b0, reversing
changes made to 90ef070db3.
This commit is contained in:
Aleksey Kladov 2019-12-21 15:04:33 +01:00
parent a1f4c988e4
commit 973b5cf7e2
13 changed files with 166 additions and 71 deletions

View file

@ -270,6 +270,7 @@ impl RootDatabase {
self.query(hir::db::AstIdMapQuery).sweep(sweep);
self.query(hir::db::RawItemsWithSourceMapQuery).sweep(sweep);
self.query(hir::db::BodyWithSourceMapQuery).sweep(sweep);
self.query(hir::db::ExprScopesQuery).sweep(sweep);
@ -308,6 +309,7 @@ impl RootDatabase {
hir::db::StructDataQuery
hir::db::EnumDataQuery
hir::db::TraitDataQuery
hir::db::RawItemsWithSourceMapQuery
hir::db::RawItemsQuery
hir::db::CrateDefMapQuery
hir::db::GenericParamsQuery

View file

@ -1,6 +1,7 @@
//! FIXME: write short doc here
use hir::{Adt, PathResolution, ScopeDef};
use either::Either;
use hir::{Adt, HasSource, PathResolution};
use ra_syntax::AstNode;
use test_utils::tested_by;
@ -18,15 +19,17 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
match def {
hir::ModuleDef::Module(module) => {
let module_scope = module.scope(ctx.db);
for (name, def) in module_scope {
if ctx.use_item_syntax.is_some() {
if let hir::ScopeDef::ModuleDef(hir::ModuleDef::BuiltinType(..)) = def {
for (name, def, import) in module_scope {
if let hir::ScopeDef::ModuleDef(hir::ModuleDef::BuiltinType(..)) = def {
if ctx.use_item_syntax.is_some() {
tested_by!(dont_complete_primitive_in_use);
continue;
}
if let ScopeDef::Unknown = def {
if let Some(name_ref) = ctx.name_ref.as_ref() {
if &name_ref.syntax().text() == name.to_string().as_str() {
}
if Some(module) == ctx.module {
if let Some(import) = import {
if let Either::Left(use_tree) = import.source(ctx.db).value {
if use_tree.syntax().text_range().contains_inclusive(ctx.offset) {
// for `use self::foo<|>`, don't suggest `foo` as a completion
tested_by!(dont_complete_current_use);
continue;

View file

@ -18,7 +18,6 @@ pub(crate) struct CompletionContext<'a> {
pub(super) analyzer: hir::SourceAnalyzer,
pub(super) offset: TextUnit,
pub(super) token: SyntaxToken,
pub(super) name_ref: Option<ast::NameRef>,
pub(super) module: Option<hir::Module>,
pub(super) function_syntax: Option<ast::FnDef>,
pub(super) use_item_syntax: Option<ast::UseItem>,
@ -69,7 +68,6 @@ impl<'a> CompletionContext<'a> {
analyzer,
token,
offset: position.offset,
name_ref: None,
module,
function_syntax: None,
use_item_syntax: None,
@ -144,8 +142,6 @@ impl<'a> CompletionContext<'a> {
}
fn classify_name_ref(&mut self, original_file: SourceFile, name_ref: ast::NameRef) {
self.name_ref =
find_node_at_offset(original_file.syntax(), name_ref.syntax().text_range().start());
let name_range = name_ref.syntax().text_range();
if name_ref.syntax().parent().and_then(ast::RecordField::cast).is_some() {
self.record_lit_syntax = find_node_at_offset(original_file.syntax(), self.offset);