Skip to content

Commit 992e125

Browse files
bors[bot]matklad
andauthored
Merge #4724
4724: Rename WorldState -> GlobalState r=matklad a=matklad bors r+ 🤖 Co-authored-by: Aleksey Kladov <aleksey.kladov@gmail.com>
2 parents 5100f77 + a87cd8e commit 992e125

File tree

7 files changed

+291
-273
lines changed

7 files changed

+291
-273
lines changed

crates/rust-analyzer/src/cargo_target_spec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ use ra_cfg::CfgExpr;
44
use ra_ide::{FileId, RunnableKind, TestId};
55
use ra_project_model::{self, ProjectWorkspace, TargetKind};
66

7-
use crate::{world::WorldSnapshot, Result};
7+
use crate::{global_state::GlobalStateSnapshot, Result};
88

99
/// Abstract representation of Cargo target.
1010
///
@@ -89,7 +89,7 @@ impl CargoTargetSpec {
8989
}
9090

9191
pub(crate) fn for_file(
92-
world: &WorldSnapshot,
92+
world: &GlobalStateSnapshot,
9393
file_id: FileId,
9494
) -> Result<Option<CargoTargetSpec>> {
9595
let &crate_id = match world.analysis().crate_for(file_id)?.first() {

crates/rust-analyzer/src/from_proto.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use ra_db::{FileId, FilePosition, FileRange};
33
use ra_ide::{LineCol, LineIndex};
44
use ra_syntax::{TextRange, TextSize};
55

6-
use crate::{world::WorldSnapshot, Result};
6+
use crate::{global_state::GlobalStateSnapshot, Result};
77

88
pub(crate) fn offset(line_index: &LineIndex, position: lsp_types::Position) -> TextSize {
99
let line_col = LineCol { line: position.line as u32, col_utf16: position.character as u32 };
@@ -16,12 +16,12 @@ pub(crate) fn text_range(line_index: &LineIndex, range: lsp_types::Range) -> Tex
1616
TextRange::new(start, end)
1717
}
1818

19-
pub(crate) fn file_id(world: &WorldSnapshot, url: &lsp_types::Url) -> Result<FileId> {
19+
pub(crate) fn file_id(world: &GlobalStateSnapshot, url: &lsp_types::Url) -> Result<FileId> {
2020
world.uri_to_file_id(url)
2121
}
2222

2323
pub(crate) fn file_position(
24-
world: &WorldSnapshot,
24+
world: &GlobalStateSnapshot,
2525
tdpp: lsp_types::TextDocumentPositionParams,
2626
) -> Result<FilePosition> {
2727
let file_id = file_id(world, &tdpp.text_document.uri)?;
@@ -31,7 +31,7 @@ pub(crate) fn file_position(
3131
}
3232

3333
pub(crate) fn file_range(
34-
world: &WorldSnapshot,
34+
world: &GlobalStateSnapshot,
3535
text_document_identifier: lsp_types::TextDocumentIdentifier,
3636
range: lsp_types::Range,
3737
) -> Result<FileRange> {

crates/rust-analyzer/src/world.rs renamed to crates/rust-analyzer/src/global_state.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,13 @@ fn create_flycheck(workspaces: &[ProjectWorkspace], config: &FlycheckConfig) ->
5050
})
5151
}
5252

53-
/// `WorldState` is the primary mutable state of the language server
53+
/// `GlobalState` is the primary mutable state of the language server
5454
///
5555
/// The most interesting components are `vfs`, which stores a consistent
5656
/// snapshot of the file systems, and `analysis_host`, which stores our
5757
/// incremental salsa database.
5858
#[derive(Debug)]
59-
pub struct WorldState {
59+
pub struct GlobalState {
6060
pub config: Config,
6161
pub local_roots: Vec<PathBuf>,
6262
pub workspaces: Arc<Vec<ProjectWorkspace>>,
@@ -70,7 +70,7 @@ pub struct WorldState {
7070
}
7171

7272
/// An immutable snapshot of the world's state at a point in time.
73-
pub struct WorldSnapshot {
73+
pub struct GlobalStateSnapshot {
7474
pub config: Config,
7575
pub workspaces: Arc<Vec<ProjectWorkspace>>,
7676
pub analysis: Analysis,
@@ -79,14 +79,14 @@ pub struct WorldSnapshot {
7979
vfs: Arc<RwLock<Vfs>>,
8080
}
8181

82-
impl WorldState {
82+
impl GlobalState {
8383
pub fn new(
8484
workspaces: Vec<ProjectWorkspace>,
8585
lru_capacity: Option<usize>,
8686
exclude_globs: &[Glob],
8787
watch: Watch,
8888
config: Config,
89-
) -> WorldState {
89+
) -> GlobalState {
9090
let mut change = AnalysisChange::new();
9191

9292
let extern_dirs: FxHashSet<_> =
@@ -180,7 +180,7 @@ impl WorldState {
180180

181181
let mut analysis_host = AnalysisHost::new(lru_capacity);
182182
analysis_host.apply_change(change);
183-
WorldState {
183+
GlobalState {
184184
config,
185185
local_roots,
186186
workspaces: Arc::new(workspaces),
@@ -255,8 +255,8 @@ impl WorldState {
255255
self.analysis_host.apply_change(change);
256256
}
257257

258-
pub fn snapshot(&self) -> WorldSnapshot {
259-
WorldSnapshot {
258+
pub fn snapshot(&self) -> GlobalStateSnapshot {
259+
GlobalStateSnapshot {
260260
config: self.config.clone(),
261261
workspaces: Arc::clone(&self.workspaces),
262262
analysis: self.analysis_host.analysis(),
@@ -279,7 +279,7 @@ impl WorldState {
279279
}
280280
}
281281

282-
impl WorldSnapshot {
282+
impl GlobalStateSnapshot {
283283
pub fn analysis(&self) -> &Analysis {
284284
&self.analysis
285285
}

crates/rust-analyzer/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ mod main_loop;
2626
mod markdown;
2727
pub mod lsp_ext;
2828
pub mod config;
29-
mod world;
29+
mod global_state;
3030
mod diagnostics;
3131
mod semantic_tokens;
3232

0 commit comments

Comments
 (0)