Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rust-analyzer.toml tracking #16254

Closed
wants to merge 55 commits into from
Closed
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
b09dbcb
Assume everything is global for now
alibektas Oct 22, 2023
451a406
Declare imports_* configs as local
alibektas Oct 24, 2023
a7b6175
Declare joinLines_* as local
alibektas Oct 24, 2023
34a255c
Compile time measures. Make a distinction between a RootConfig and a …
alibektas Oct 25, 2023
259e233
Declare inlayHints_* as local
alibektas Oct 25, 2023
3e17039
Declare highlightRelated_* as local
alibektas Oct 25, 2023
f621722
Declare hover_actions_* as local
alibektas Oct 25, 2023
5c063b9
Declare completion_* as local
alibektas Oct 25, 2023
45c7caa
Declare semanticHighlighting_* as local
alibektas Oct 25, 2023
2bad5e7
Last commit before issuing a draft
alibektas Oct 25, 2023
4196ad5
Make ConfigData Ser and TOML De
alibektas Jan 5, 2024
46110f4
Remove need to specify `Option::<T>::None` etc in `config_data!`
cormacrelf Jan 18, 2024
fda1935
Last type annotation in config_data!
cormacrelf Jan 18, 2024
f77b64c
Reduce repetition in config_data! macro by splitting ConfigData into …
cormacrelf Jan 18, 2024
a364384
Sort the fields, so the diffs on the generated docs/schemas are smaller
cormacrelf Jan 18, 2024
8835d42
Add the default snippets back, tweak the serialize output until it's …
cormacrelf Jan 18, 2024
3ae48d1
serialize impl for true_or_always/false_or_never
cormacrelf Jan 18, 2024
86a8438
add serialize for the de_unit_v-s
cormacrelf Jan 18, 2024
48dd942
rename de_unit_v to unit_v
cormacrelf Jan 18, 2024
7b0c05d
Bring the diff down to zero using BTreeMap for snippets, @from_str:
cormacrelf Jan 18, 2024
c474ebb
use indexmap instead of BTreeMap for deterministic snippet output
cormacrelf Jan 18, 2024
172da25
rename `@from_str: ` to `@verbatim: `
cormacrelf Jan 18, 2024
568ee9a
Didn't mean for indexmap to be one of "these 3 deps"
cormacrelf Jan 18, 2024
33a4fe8
Merge pull request #1 from cormacrelf/adoc-diff-zero
alibektas Jan 19, 2024
0039f6b
GlobalConfigInput etc
cormacrelf Jan 20, 2024
9b0666e
Finish splitting *ConfigData and *ConfigInput
cormacrelf Jan 20, 2024
7b4c364
Add clone_with_overrides
cormacrelf Jan 20, 2024
10c1db6
Compact Debug implementation for *ConfigInput
cormacrelf Jan 23, 2024
7c5f33c
ConfigTree
cormacrelf Jan 21, 2024
9c506a9
Start building the tree construction
cormacrelf Jan 23, 2024
c442ea1
Store empty input as None
cormacrelf Jan 23, 2024
18ff646
config tree gets a tree shape
cormacrelf Jan 23, 2024
47c7d45
Make the client config override everything
cormacrelf Jan 23, 2024
69bdf4a
Add failing test for the xdg config being inherited
cormacrelf Jan 23, 2024
ab0149d
fix config invalidation
cormacrelf Jan 23, 2024
851b970
Avoid recomputing the client-config-mixed configs
cormacrelf Jan 23, 2024
77e61f7
Better test for config tree
cormacrelf Jan 23, 2024
9d8cff2
rename read_config to local_config
cormacrelf Jan 23, 2024
ce341dc
delete ConfigParentChange
cormacrelf Jan 23, 2024
09a3888
use salsa for the config tree
cormacrelf Jan 24, 2024
359bf1d
Delte unused vfs method, document set_file_id_contents
cormacrelf Jan 24, 2024
f1cff1e
Add a test that generates a tree from running path.ancestors() on the…
cormacrelf Jan 24, 2024
575ebbc
Add ancestors method to AbsPath
cormacrelf Jan 24, 2024
cc8dce5
Make the public api just "here's a list of source roots and a project…
cormacrelf Jan 24, 2024
cbbfa37
Simplify test code
cormacrelf Jan 24, 2024
ddbdecf
Merge pull request #2 from cormacrelf/apply_input
alibektas Jan 24, 2024
fb1149e
Another test where the source roots are changed
cormacrelf Jan 25, 2024
f253aa4
Test changing project root
cormacrelf Jan 25, 2024
4074803
add failing test
cormacrelf Jan 25, 2024
6906ae9
And fix it
cormacrelf Jan 25, 2024
c246135
Fix comment in test
cormacrelf Jan 25, 2024
bf1419a
Make AbsPath::assert work on plain string slices too
cormacrelf Jan 25, 2024
8177b17
Add a failing test for irrelevant vfs changes
cormacrelf Jan 25, 2024
512295c
Fix the failing test for irrelevant vfs changes
cormacrelf Jan 25, 2024
35a0856
Merge pull request #3 from cormacrelf/config-tree
alibektas Jan 27, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
65 changes: 61 additions & 4 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/base-db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ syntax.workspace = true
test-utils.workspace = true
tt.workspace = true
vfs.workspace = true
serde.workspace = true
3 changes: 2 additions & 1 deletion crates/base-db/src/change.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ impl fmt::Debug for Change {
d.field("roots", roots);
}
if !self.files_changed.is_empty() {
d.field("files_changed", &self.files_changed.len());
d.field("files_changed", &self.files_changed);
// d.field("files_changed", &self.files_changed.len());
}
if self.crate_graph.is_some() {
d.field("crate_graph", &self.crate_graph);
Expand Down
37 changes: 32 additions & 5 deletions crates/base-db/src/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ use std::{fmt, mem, ops, panic::RefUnwindSafe, str::FromStr, sync};
use cfg::CfgOptions;
use la_arena::{Arena, Idx};
use rustc_hash::{FxHashMap, FxHashSet};
use serde::Serialize;
use syntax::SmolStr;
use triomphe::Arc;
use tt::token_id::Subtree;
Expand All @@ -21,33 +22,40 @@ use vfs::{file_set::FileSet, AbsPathBuf, AnchoredPath, FileId, VfsPath};
pub type ProcMacroPaths = FxHashMap<CrateId, Result<(Option<String>, AbsPathBuf), String>>;
pub type ProcMacros = FxHashMap<CrateId, ProcMacroLoadResult>;

#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SourceRootId(pub u32);

/// Files are grouped into source roots. A source root is a directory on the
/// file systems which is watched for changes. Typically it corresponds to a
/// Rust crate. Source roots *might* be nested: in this case, a file belongs to
/// the nearest enclosing source root. Paths to files are always relative to a
/// source root, and the analyzer does not know the root path of the source root at
/// all. So, a file from one source root can't refer to a file in another source
/// root by path.
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct SourceRootId(pub u32);

#[derive(Clone, Debug, PartialEq, Eq)]
pub struct SourceRoot {
/// Sysroot or crates.io library.
///
/// Libraries are considered mostly immutable, this assumption is used to
/// optimize salsa's query structure
pub is_library: bool,
cargo_file_id: Option<FileId>,
/// FIXME : @alibektas We know that this is wrong.
/// base-db must stay as a level of abstraction
/// that has no knowledge of such specific files
/// so this should be moved somewhere else.
ratoml_file_id: Option<FileId>,
file_set: FileSet,
}

impl SourceRoot {
pub fn new_local(file_set: FileSet) -> SourceRoot {
SourceRoot { is_library: false, file_set }
eprintln!("{:#?}", file_set);
SourceRoot { is_library: false, file_set, cargo_file_id: None, ratoml_file_id: None }
}

pub fn new_library(file_set: FileSet) -> SourceRoot {
SourceRoot { is_library: true, file_set }
SourceRoot { is_library: true, file_set, cargo_file_id: None, ratoml_file_id: None }
}

pub fn path_for_file(&self, file: &FileId) -> Option<&VfsPath> {
Expand All @@ -65,6 +73,16 @@ impl SourceRoot {
pub fn iter(&self) -> impl Iterator<Item = FileId> + '_ {
self.file_set.iter()
}

/// Get `FileId` of the `Cargo.toml` if one present in `SourceRoot`
pub fn cargo_toml(&self) -> Option<FileId> {
self.cargo_file_id
}

/// Get `FileId` of the `rust-analyzer.toml` if one present in `SourceRoot`
pub fn ratoml(&self) -> Option<FileId> {
self.ratoml_file_id
}
}

/// `CrateGraph` is a bit of information which turns a set of text files into a
Expand Down Expand Up @@ -103,6 +121,15 @@ pub type CrateId = Idx<CrateData>;
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub struct CrateName(SmolStr);

impl Serialize for CrateName {
fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where
S: serde::Serializer,
{
serializer.serialize_str(self)
}
}

impl CrateName {
/// Creates a crate name, checking for dashes in the string provided.
/// Dashes are not allowed in the crate names,
Expand Down
1 change: 1 addition & 0 deletions crates/load-cargo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ impl ProjectFolders {
let entry = {
let mut dirs = vfs::loader::Directories::default();
dirs.extensions.push("rs".into());
dirs.extensions.push("toml".into());
dirs.include.extend(root.include);
dirs.exclude.extend(root.exclude);
for excl in global_excludes {
Expand Down
3 changes: 2 additions & 1 deletion crates/project-model/src/cfg_flag.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@
use std::{fmt, str::FromStr};

use cfg::CfgOptions;
use serde::Serialize;

#[derive(Clone, Eq, PartialEq, Debug)]
#[derive(Clone, Eq, PartialEq, Debug, Serialize)]
pub enum CfgFlag {
Atom(String),
KeyValue { key: String, value: String },
Expand Down
12 changes: 6 additions & 6 deletions crates/project-model/src/project_json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ use base_db::{CrateDisplayName, CrateId, CrateName, Dependency, Edition};
use la_arena::RawIdx;
use paths::{AbsPath, AbsPathBuf};
use rustc_hash::FxHashMap;
use serde::{de, Deserialize};
use serde::{de, Deserialize, Serialize};
use std::path::PathBuf;

use crate::cfg_flag::CfgFlag;
Expand Down Expand Up @@ -174,14 +174,14 @@ impl ProjectJson {
}
}

#[derive(Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct ProjectJsonData {
sysroot: Option<PathBuf>,
sysroot_src: Option<PathBuf>,
crates: Vec<CrateData>,
}

#[derive(Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
struct CrateData {
display_name: Option<String>,
root_module: PathBuf,
Expand All @@ -203,7 +203,7 @@ struct CrateData {
repository: Option<String>,
}

#[derive(Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
#[serde(rename = "edition")]
enum EditionData {
#[serde(rename = "2015")]
Expand All @@ -224,7 +224,7 @@ impl From<EditionData> for Edition {
}
}

#[derive(Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
struct DepData {
/// Identifies a crate by position in the crates array.
#[serde(rename = "crate")]
Expand All @@ -233,7 +233,7 @@ struct DepData {
name: CrateName,
}

#[derive(Deserialize, Debug, Clone)]
#[derive(Serialize, Deserialize, Debug, Clone)]
struct CrateSource {
include_dirs: Vec<PathBuf>,
exclude_dirs: Vec<PathBuf>,
Expand Down
5 changes: 4 additions & 1 deletion crates/rust-analyzer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,12 @@ tracing-subscriber = { version = "0.3.16", default-features = false, features =
tracing-log = "0.1.3"
tracing-tree = "0.2.1"
triomphe.workspace = true
toml = "0.8.8"
nohash-hasher.workspace = true
always-assert = "0.1.2"
indexmap = { version = "2.0.0", features = ["serde"] }

# These 3 deps are not used by r-a directly, but we list them here to lock in their versions
# These 2 deps are not used by r-a directly, but we list them here to lock in their versions
# in our transitive deps to prevent them from pulling in windows-sys 0.45.0
mio = "=0.8.5"
parking_lot_core = "=0.9.6"
Expand All @@ -72,6 +74,7 @@ parser.workspace = true
toolchain.workspace = true
vfs-notify.workspace = true
vfs.workspace = true
la-arena.workspace = true

[target.'cfg(windows)'.dependencies]
winapi = "0.3.9"
Expand Down
Loading