6331: correct hover text for items with doc attribute with raw strings r=matklad a=JoshMcguigan

Fixes #6300 by improving the handling of raw string literals in attribute style doc comments.

This still has a bug where it could consume too many `"` at the start or end of the comment text, just as the original code had. Not sure if we want to fix that as part of this PR or not? If so, I think I'd prefer to add a unit test for either the `as_simple_key_value` function (I'm not exactly sure where this would belong / how to set this up) or create a `fn(&SmolStr) -> &SmolStr` to unit test by factoring out the `trim` operations from `as_simple_key_value`. Thoughts on this? 

6342: Shorter dependency chain r=matklad a=popzxc

Continuing implementing suggestions from the `Completion refactoring` zulip thread.

This PR does the following:

- Removes dependency of `completions` on `assists` by moving required functionality into `ide_db`.
- Moves completely `call_info` crate into `ide_db` as it looks like it fits perfect there.
- Adds a bunch of new tests and docs.
- Adds the re-export of `base_db` to the `ide_db` and removes direct dependency on `base_db` from other crates.

The last point is controversial, I guess, but I noticed that in places where `ide_db` is used, `base_db` is also *always* used. Thus I think the dependency on the `base_db` is implied by the fact of `ide_db` interfaces, and thus it makes sense to just provide `base_db` out of the box.


Co-authored-by: Josh Mcguigan <joshmcg88@gmail.com>
Co-authored-by: Igor Aleksanov <popzxc@yandex.ru>
This commit is contained in:
bors[bot] 2020-10-24 19:08:12 +00:00 committed by GitHub
commit bf84e4958e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
67 changed files with 421 additions and 259 deletions

View file

@ -46,7 +46,6 @@ cfg = { path = "../cfg", version = "0.0.0" }
toolchain = { path = "../toolchain", version = "0.0.0" }
# This should only be used in CLI
base_db = { path = "../base_db", version = "0.0.0" }
ide_db = { path = "../ide_db", version = "0.0.0" }
ssr = { path = "../ssr", version = "0.0.0" }
hir = { path = "../hir", version = "0.0.0" }

View file

@ -3,13 +3,13 @@
use std::{env, path::PathBuf, str::FromStr, sync::Arc, time::Instant};
use anyhow::{bail, format_err, Result};
use base_db::{
salsa::{Database, Durability},
FileId,
};
use ide::{
Analysis, AnalysisHost, Change, CompletionConfig, DiagnosticsConfig, FilePosition, LineCol,
};
use ide_db::base_db::{
salsa::{Database, Durability},
FileId,
};
use vfs::AbsPathBuf;
use crate::{

View file

@ -6,16 +6,16 @@ use std::{
time::{SystemTime, UNIX_EPOCH},
};
use base_db::{
salsa::{self, ParallelDatabase},
SourceDatabaseExt,
};
use hir::{
db::{AstDatabase, DefDatabase, HirDatabase},
original_range, AssocItem, Crate, HasSource, HirDisplay, ModuleDef,
};
use hir_def::FunctionId;
use hir_ty::{Ty, TypeWalk};
use ide_db::base_db::{
salsa::{self, ParallelDatabase},
SourceDatabaseExt,
};
use itertools::Itertools;
use oorandom::Rand32;
use rayon::prelude::*;

View file

@ -6,9 +6,9 @@ use std::path::Path;
use anyhow::anyhow;
use rustc_hash::FxHashSet;
use base_db::SourceDatabaseExt;
use hir::Crate;
use ide::{DiagnosticsConfig, Severity};
use ide_db::base_db::SourceDatabaseExt;
use crate::cli::{load_cargo::load_cargo, Result};

View file

@ -3,9 +3,9 @@
use std::{path::Path, sync::Arc};
use anyhow::Result;
use base_db::CrateGraph;
use crossbeam_channel::{unbounded, Receiver};
use ide::{AnalysisHost, Change};
use ide_db::base_db::CrateGraph;
use project_model::{CargoConfig, ProcMacroClient, ProjectManifest, ProjectWorkspace};
use vfs::{loader::Handle, AbsPath, AbsPathBuf};

View file

@ -4,7 +4,7 @@ use crate::cli::{load_cargo::load_cargo, Result};
use ssr::{MatchFinder, SsrPattern, SsrRule};
pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
use base_db::SourceDatabaseExt;
use ide_db::base_db::SourceDatabaseExt;
let (host, vfs) = load_cargo(&std::env::current_dir()?, true, true)?;
let db = host.raw_database();
let mut match_finder = MatchFinder::at_first_file(db)?;
@ -26,7 +26,7 @@ pub fn apply_ssr_rules(rules: Vec<SsrRule>) -> Result<()> {
/// `debug_snippet`. This is intended for debugging and probably isn't in it's current form useful
/// for much else.
pub fn search_for_patterns(patterns: Vec<SsrPattern>, debug_snippet: Option<String>) -> Result<()> {
use base_db::SourceDatabaseExt;
use ide_db::base_db::SourceDatabaseExt;
use ide_db::symbol_index::SymbolsDatabase;
let (host, _vfs) = load_cargo(&std::env::current_dir()?, true, true)?;
let db = host.raw_database();

View file

@ -1,8 +1,8 @@
//! Conversion lsp_types types to rust-analyzer specific ones.
use std::convert::TryFrom;
use base_db::{FileId, FilePosition, FileRange};
use ide::{AssistKind, LineCol, LineIndex};
use ide_db::base_db::{FileId, FilePosition, FileRange};
use syntax::{TextRange, TextSize};
use vfs::AbsPathBuf;

View file

@ -5,10 +5,10 @@
use std::{sync::Arc, time::Instant};
use base_db::{CrateId, VfsPath};
use crossbeam_channel::{unbounded, Receiver, Sender};
use flycheck::FlycheckHandle;
use ide::{Analysis, AnalysisHost, Change, FileId};
use ide_db::base_db::{CrateId, VfsPath};
use lsp_types::{SemanticTokens, Url};
use parking_lot::{Mutex, RwLock};
use project_model::{CargoWorkspace, ProcMacroClient, ProjectWorkspace, Target};

View file

@ -1,8 +1,8 @@
//! Utilities for LSP-related boilerplate code.
use std::{error::Error, ops::Range};
use base_db::Canceled;
use ide::LineIndex;
use ide_db::base_db::Canceled;
use lsp_server::Notification;
use crate::{from_proto, global_state::GlobalState};

View file

@ -5,10 +5,10 @@ use std::{
time::{Duration, Instant},
};
use base_db::VfsPath;
use crossbeam_channel::{select, Receiver};
use ide::PrimeCachesProgress;
use ide::{Canceled, FileId};
use ide_db::base_db::VfsPath;
use lsp_server::{Connection, Notification, Request, Response};
use lsp_types::notification::Notification as _;
use project_model::ProjectWorkspace;

View file

@ -1,9 +1,9 @@
//! Project loading & configuration updates
use std::{mem, sync::Arc};
use base_db::{CrateGraph, SourceRoot, VfsPath};
use flycheck::{FlycheckConfig, FlycheckHandle};
use ide::Change;
use ide_db::base_db::{CrateGraph, SourceRoot, VfsPath};
use project_model::{ProcMacroClient, ProjectWorkspace};
use vfs::{file_set::FileSetConfig, AbsPath, AbsPathBuf, ChangeKind};

View file

@ -4,13 +4,13 @@ use std::{
sync::atomic::{AtomicU32, Ordering},
};
use base_db::{FileId, FileRange};
use ide::{
Assist, AssistKind, CallInfo, CompletionItem, CompletionItemKind, Documentation,
FileSystemEdit, Fold, FoldKind, Highlight, HighlightModifier, HighlightTag, HighlightedRange,
Indel, InlayHint, InlayKind, InsertTextFormat, LineIndex, Markup, NavigationTarget,
ReferenceAccess, ResolvedAssist, Runnable, Severity, SourceChange, SourceFileEdit, TextEdit,
};
use ide_db::base_db::{FileId, FileRange};
use itertools::Itertools;
use syntax::{SyntaxKind, TextRange, TextSize};
@ -809,7 +809,7 @@ mod tests {
let completions: Vec<(String, Option<String>)> = analysis
.completions(
&ide::CompletionConfig::default(),
base_db::FilePosition { file_id, offset },
ide_db::base_db::FilePosition { file_id, offset },
)
.unwrap()
.unwrap()