Make call_info a part of ide_db
This commit is contained in:
parent
8d3d509af7
commit
b6ea56ea09
17
Cargo.lock
generated
17
Cargo.lock
generated
@ -127,20 +127,6 @@ version = "1.3.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
checksum = "08c48aae112d48ed9f069b33538ea9e3e90aa263cfa3d1c24309612b1f7472de"
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "call_info"
|
|
||||||
version = "0.0.0"
|
|
||||||
dependencies = [
|
|
||||||
"base_db",
|
|
||||||
"either",
|
|
||||||
"expect-test",
|
|
||||||
"hir",
|
|
||||||
"ide_db",
|
|
||||||
"stdx",
|
|
||||||
"syntax",
|
|
||||||
"test_utils",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "cargo_metadata"
|
name = "cargo_metadata"
|
||||||
version = "0.12.0"
|
version = "0.12.0"
|
||||||
@ -269,7 +255,6 @@ name = "completion"
|
|||||||
version = "0.0.0"
|
version = "0.0.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base_db",
|
"base_db",
|
||||||
"call_info",
|
|
||||||
"expect-test",
|
"expect-test",
|
||||||
"hir",
|
"hir",
|
||||||
"ide_db",
|
"ide_db",
|
||||||
@ -643,7 +628,6 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"assists",
|
"assists",
|
||||||
"base_db",
|
"base_db",
|
||||||
"call_info",
|
|
||||||
"cfg",
|
"cfg",
|
||||||
"completion",
|
"completion",
|
||||||
"either",
|
"either",
|
||||||
@ -672,6 +656,7 @@ version = "0.0.0"
|
|||||||
dependencies = [
|
dependencies = [
|
||||||
"base_db",
|
"base_db",
|
||||||
"either",
|
"either",
|
||||||
|
"expect-test",
|
||||||
"fst",
|
"fst",
|
||||||
"hir",
|
"hir",
|
||||||
"log",
|
"log",
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
[package]
|
|
||||||
name = "call_info"
|
|
||||||
version = "0.0.0"
|
|
||||||
description = "TBD"
|
|
||||||
license = "MIT OR Apache-2.0"
|
|
||||||
authors = ["rust-analyzer developers"]
|
|
||||||
edition = "2018"
|
|
||||||
|
|
||||||
[lib]
|
|
||||||
doctest = false
|
|
||||||
|
|
||||||
[dependencies]
|
|
||||||
either = "1.5.3"
|
|
||||||
|
|
||||||
stdx = { path = "../stdx", version = "0.0.0" }
|
|
||||||
syntax = { path = "../syntax", version = "0.0.0" }
|
|
||||||
base_db = { path = "../base_db", version = "0.0.0" }
|
|
||||||
ide_db = { path = "../ide_db", version = "0.0.0" }
|
|
||||||
test_utils = { path = "../test_utils", version = "0.0.0" }
|
|
||||||
|
|
||||||
# call_info crate should depend only on the top-level `hir` package. if you need
|
|
||||||
# something from some `hir_xxx` subpackage, reexport the API via `hir`.
|
|
||||||
hir = { path = "../hir", version = "0.0.0" }
|
|
||||||
|
|
||||||
[dev-dependencies]
|
|
||||||
expect-test = "1.0"
|
|
@ -21,7 +21,6 @@ base_db = { path = "../base_db", version = "0.0.0" }
|
|||||||
ide_db = { path = "../ide_db", version = "0.0.0" }
|
ide_db = { path = "../ide_db", version = "0.0.0" }
|
||||||
profile = { path = "../profile", version = "0.0.0" }
|
profile = { path = "../profile", version = "0.0.0" }
|
||||||
test_utils = { path = "../test_utils", version = "0.0.0" }
|
test_utils = { path = "../test_utils", version = "0.0.0" }
|
||||||
call_info = { path = "../call_info", version = "0.0.0" }
|
|
||||||
|
|
||||||
# completions crate should depend only on the top-level `hir` package. if you need
|
# completions crate should depend only on the top-level `hir` package. if you need
|
||||||
# something from some `hir_xxx` subpackage, reexport the API via `hir`.
|
# something from some `hir_xxx` subpackage, reexport the API via `hir`.
|
||||||
|
@ -1,9 +1,8 @@
|
|||||||
//! See `CompletionContext` structure.
|
//! See `CompletionContext` structure.
|
||||||
|
|
||||||
use base_db::{FilePosition, SourceDatabase};
|
use base_db::{FilePosition, SourceDatabase};
|
||||||
use call_info::ActiveParameter;
|
|
||||||
use hir::{Local, ScopeDef, Semantics, SemanticsScope, Type};
|
use hir::{Local, ScopeDef, Semantics, SemanticsScope, Type};
|
||||||
use ide_db::RootDatabase;
|
use ide_db::{call_info::ActiveParameter, RootDatabase};
|
||||||
use syntax::{
|
use syntax::{
|
||||||
algo::{find_covering_element, find_node_at_offset},
|
algo::{find_covering_element, find_node_at_offset},
|
||||||
ast, match_ast, AstNode, NodeOrToken,
|
ast, match_ast, AstNode, NodeOrToken,
|
||||||
|
@ -30,7 +30,6 @@ profile = { path = "../profile", version = "0.0.0" }
|
|||||||
test_utils = { path = "../test_utils", version = "0.0.0" }
|
test_utils = { path = "../test_utils", version = "0.0.0" }
|
||||||
assists = { path = "../assists", version = "0.0.0" }
|
assists = { path = "../assists", version = "0.0.0" }
|
||||||
ssr = { path = "../ssr", version = "0.0.0" }
|
ssr = { path = "../ssr", version = "0.0.0" }
|
||||||
call_info = { path = "../call_info", version = "0.0.0" }
|
|
||||||
completion = { path = "../completion", version = "0.0.0" }
|
completion = { path = "../completion", version = "0.0.0" }
|
||||||
|
|
||||||
# ide should depend only on the top-level `hir` package. if you need
|
# ide should depend only on the top-level `hir` package. if you need
|
||||||
|
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
use indexmap::IndexMap;
|
use indexmap::IndexMap;
|
||||||
|
|
||||||
use call_info::FnCallNode;
|
|
||||||
use hir::Semantics;
|
use hir::Semantics;
|
||||||
|
use ide_db::call_info::FnCallNode;
|
||||||
use ide_db::RootDatabase;
|
use ide_db::RootDatabase;
|
||||||
use syntax::{ast, match_ast, AstNode, TextRange};
|
use syntax::{ast, match_ast, AstNode, TextRange};
|
||||||
|
|
||||||
|
@ -80,10 +80,10 @@ macro_rules! eprintln {
|
|||||||
Highlight, HighlightModifier, HighlightModifiers, HighlightTag, HighlightedRange,
|
Highlight, HighlightModifier, HighlightModifiers, HighlightTag, HighlightedRange,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
pub use call_info::CallInfo;
|
|
||||||
pub use completion::{
|
pub use completion::{
|
||||||
CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat,
|
CompletionConfig, CompletionItem, CompletionItemKind, CompletionScore, InsertTextFormat,
|
||||||
};
|
};
|
||||||
|
pub use ide_db::call_info::CallInfo;
|
||||||
|
|
||||||
pub use assists::{
|
pub use assists::{
|
||||||
utils::MergeBehaviour, Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist,
|
utils::MergeBehaviour, Assist, AssistConfig, AssistId, AssistKind, ResolvedAssist,
|
||||||
@ -396,7 +396,7 @@ pub fn external_docs(
|
|||||||
|
|
||||||
/// Computes parameter information for the given call expression.
|
/// Computes parameter information for the given call expression.
|
||||||
pub fn call_info(&self, position: FilePosition) -> Cancelable<Option<CallInfo>> {
|
pub fn call_info(&self, position: FilePosition) -> Cancelable<Option<CallInfo>> {
|
||||||
self.with_db(|db| call_info::call_info(db, position))
|
self.with_db(|db| ide_db::call_info::call_info(db, position))
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Computes call hierarchy candidates for the given file position.
|
/// Computes call hierarchy candidates for the given file position.
|
||||||
|
@ -3,8 +3,8 @@
|
|||||||
use std::{collections::BTreeMap, convert::TryFrom};
|
use std::{collections::BTreeMap, convert::TryFrom};
|
||||||
|
|
||||||
use ast::{HasQuotes, HasStringValue};
|
use ast::{HasQuotes, HasStringValue};
|
||||||
use call_info::ActiveParameter;
|
|
||||||
use hir::Semantics;
|
use hir::Semantics;
|
||||||
|
use ide_db::call_info::ActiveParameter;
|
||||||
use itertools::Itertools;
|
use itertools::Itertools;
|
||||||
use syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize};
|
use syntax::{ast, AstToken, SyntaxNode, SyntaxToken, TextRange, TextSize};
|
||||||
|
|
||||||
|
@ -29,3 +29,6 @@ test_utils = { path = "../test_utils", version = "0.0.0" }
|
|||||||
# ide should depend only on the top-level `hir` package. if you need
|
# ide should depend only on the top-level `hir` package. if you need
|
||||||
# something from some `hir_xxx` subpackage, reexport the API via `hir`.
|
# something from some `hir_xxx` subpackage, reexport the API via `hir`.
|
||||||
hir = { path = "../hir", version = "0.0.0" }
|
hir = { path = "../hir", version = "0.0.0" }
|
||||||
|
|
||||||
|
[dev-dependencies]
|
||||||
|
expect-test = "1.0"
|
||||||
|
@ -2,7 +2,6 @@
|
|||||||
use base_db::FilePosition;
|
use base_db::FilePosition;
|
||||||
use either::Either;
|
use either::Either;
|
||||||
use hir::{HasAttrs, HirDisplay, Semantics, Type};
|
use hir::{HasAttrs, HirDisplay, Semantics, Type};
|
||||||
use ide_db::RootDatabase;
|
|
||||||
use stdx::format_to;
|
use stdx::format_to;
|
||||||
use syntax::{
|
use syntax::{
|
||||||
ast::{self, ArgListOwner},
|
ast::{self, ArgListOwner},
|
||||||
@ -10,6 +9,8 @@
|
|||||||
};
|
};
|
||||||
use test_utils::mark;
|
use test_utils::mark;
|
||||||
|
|
||||||
|
use crate::RootDatabase;
|
||||||
|
|
||||||
/// Contains information about a call site. Specifically the
|
/// Contains information about a call site. Specifically the
|
||||||
/// `FunctionSignature`and current parameter.
|
/// `FunctionSignature`and current parameter.
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
@ -228,9 +229,9 @@ fn arg_list(&self) -> Option<ast::ArgList> {
|
|||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use crate::RootDatabase;
|
||||||
use base_db::{fixture::ChangeFixture, FilePosition};
|
use base_db::{fixture::ChangeFixture, FilePosition};
|
||||||
use expect_test::{expect, Expect};
|
use expect_test::{expect, Expect};
|
||||||
use ide_db::RootDatabase;
|
|
||||||
use test_utils::{mark, RangeOrOffset};
|
use test_utils::{mark, RangeOrOffset};
|
||||||
|
|
||||||
/// Creates analysis from a multi-file fixture, returns positions marked with <|>.
|
/// Creates analysis from a multi-file fixture, returns positions marked with <|>.
|
||||||
@ -249,7 +250,7 @@ pub(crate) fn position(ra_fixture: &str) -> (RootDatabase, FilePosition) {
|
|||||||
|
|
||||||
fn check(ra_fixture: &str, expect: Expect) {
|
fn check(ra_fixture: &str, expect: Expect) {
|
||||||
let (db, position) = position(ra_fixture);
|
let (db, position) = position(ra_fixture);
|
||||||
let call_info = crate::call_info(&db, position);
|
let call_info = crate::call_info::call_info(&db, position);
|
||||||
let actual = match call_info {
|
let actual = match call_info {
|
||||||
Some(call_info) => {
|
Some(call_info) => {
|
||||||
let docs = match &call_info.doc {
|
let docs = match &call_info.doc {
|
@ -12,6 +12,7 @@
|
|||||||
pub mod source_change;
|
pub mod source_change;
|
||||||
pub mod ty_filter;
|
pub mod ty_filter;
|
||||||
pub mod traits;
|
pub mod traits;
|
||||||
|
pub mod call_info;
|
||||||
|
|
||||||
use std::{fmt, sync::Arc};
|
use std::{fmt, sync::Arc};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user