Name the root file of every crate after the crate to ease navigation

Co-Authored-By: Max Brunsfeld <maxbrunsfeld@gmail.com>
This commit is contained in:
Nathan Sobo 2021-11-30 12:46:39 -07:00
parent 748b1ba602
commit 1445ce10b5
47 changed files with 133 additions and 79 deletions

View File

@ -3,6 +3,9 @@ name = "chat_panel"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/chat_panel.rs"
[dependencies] [dependencies]
client = { path = "../client" } client = { path = "../client" }
editor = { path = "../editor" } editor = { path = "../editor" }

View File

@ -3,6 +3,9 @@ name = "client"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/client.rs"
[features] [features]
test-support = ["rpc/test-support"] test-support = ["rpc/test-support"]

View File

@ -3,6 +3,9 @@ name = "clock"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/clock.rs"
[dependencies] [dependencies]
smallvec = { version = "1.6", features = ["union"] } smallvec = { version = "1.6", features = ["union"] }
rpc = { path = "../rpc" } rpc = { path = "../rpc" }

View File

@ -3,6 +3,9 @@ name = "collections"
version = "0.1.0" version = "0.1.0"
edition = "2021" edition = "2021"
[lib]
path = "src/collections.rs"
[features] [features]
test-support = ["seahash"] test-support = ["seahash"]

View File

@ -3,6 +3,9 @@ name = "contacts_panel"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/contacts_panel.rs"
[dependencies] [dependencies]
client = { path = "../client" } client = { path = "../client" }
gpui = { path = "../gpui" } gpui = { path = "../gpui" }

View File

@ -3,6 +3,9 @@ name = "editor"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/editor.rs"
[features] [features]
test-support = [ test-support = [
"text/test-support", "text/test-support",

View File

@ -3,6 +3,9 @@ name = "file_finder"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/file_finder.rs"
[dependencies] [dependencies]
editor = { path = "../editor" } editor = { path = "../editor" }
fuzzy = { path = "../fuzzy" } fuzzy = { path = "../fuzzy" }

View File

@ -4,6 +4,9 @@ version = "2.0.2"
license = "MIT" license = "MIT"
edition = "2018" edition = "2018"
[lib]
path = "src/fsevent.rs"
[dependencies] [dependencies]
bitflags = "1" bitflags = "1"
fsevent-sys = "3.0.2" fsevent-sys = "3.0.2"

View File

@ -3,6 +3,9 @@ name = "fuzzy"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/fuzzy.rs"
[dependencies] [dependencies]
gpui = { path = "../gpui" } gpui = { path = "../gpui" }
util = { path = "../util" } util = { path = "../util" }

View File

@ -3,6 +3,9 @@ name = "go_to_line"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/go_to_line.rs"
[dependencies] [dependencies]
text = { path = "../text" } text = { path = "../text" }
editor = { path = "../editor" } editor = { path = "../editor" }

View File

@ -4,6 +4,9 @@ edition = "2018"
name = "gpui" name = "gpui"
version = "0.1.0" version = "0.1.0"
[lib]
path = "src/gpui.rs"
[features] [features]
test-support = ["env_logger"] test-support = ["env_logger"]

View File

@ -4,6 +4,7 @@ version = "0.1.0"
edition = "2018" edition = "2018"
[lib] [lib]
path = "src/gpui_macros.rs"
proc-macro = true proc-macro = true
[dependencies] [dependencies]

View File

@ -3,6 +3,9 @@ name = "language"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/language.rs"
[features] [features]
test-support = [ test-support = [
"rand", "rand",

View File

@ -1,15 +1,7 @@
mod highlight_map; pub use crate::{
mod language;
pub mod proto;
#[cfg(test)]
mod tests;
pub use self::{
highlight_map::{HighlightId, HighlightMap}, highlight_map::{HighlightId, HighlightMap},
language::{ proto, BracketPair, Grammar, Language, LanguageConfig, LanguageRegistry, LanguageServerConfig,
BracketPair, Grammar, Language, LanguageConfig, LanguageRegistry, LanguageServerConfig, PLAIN_TEXT,
PLAIN_TEXT,
},
}; };
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use clock::ReplicaId; use clock::ReplicaId;
@ -73,7 +65,7 @@ pub struct Buffer {
diagnostics_update_count: usize, diagnostics_update_count: usize,
language_server: Option<LanguageServerState>, language_server: Option<LanguageServerState>,
#[cfg(test)] #[cfg(test)]
operations: Vec<Operation>, pub(crate) operations: Vec<Operation>,
} }
pub struct Snapshot { pub struct Snapshot {
@ -217,7 +209,7 @@ pub struct Chunk<'a> {
pub diagnostic: Option<DiagnosticSeverity>, pub diagnostic: Option<DiagnosticSeverity>,
} }
struct Diff { pub(crate) struct Diff {
base_version: clock::Global, base_version: clock::Global,
new_text: Arc<str>, new_text: Arc<str>,
changes: Vec<(ChangeTag, usize)>, changes: Vec<(ChangeTag, usize)>,
@ -573,7 +565,7 @@ impl Buffer {
self.parse_count self.parse_count
} }
fn syntax_tree(&self) -> Option<Tree> { pub(crate) fn syntax_tree(&self) -> Option<Tree> {
if let Some(syntax_tree) = self.syntax_tree.lock().as_mut() { if let Some(syntax_tree) = self.syntax_tree.lock().as_mut() {
self.interpolate_tree(syntax_tree); self.interpolate_tree(syntax_tree);
Some(syntax_tree.tree.clone()) Some(syntax_tree.tree.clone())
@ -1094,7 +1086,7 @@ impl Buffer {
.min_by_key(|(open_range, close_range)| close_range.end - open_range.start) .min_by_key(|(open_range, close_range)| close_range.end - open_range.start)
} }
fn diff(&self, new_text: Arc<str>, cx: &AppContext) -> Task<Diff> { pub(crate) fn diff(&self, new_text: Arc<str>, cx: &AppContext) -> Task<Diff> {
// TODO: it would be nice to not allocate here. // TODO: it would be nice to not allocate here.
let old_text = self.text(); let old_text = self.text();
let base_version = self.version(); let base_version = self.version();
@ -1111,7 +1103,7 @@ impl Buffer {
}) })
} }
fn apply_diff(&mut self, diff: Diff, cx: &mut ModelContext<Self>) -> bool { pub(crate) fn apply_diff(&mut self, diff: Diff, cx: &mut ModelContext<Self>) -> bool {
if self.version == diff.base_version { if self.version == diff.base_version {
self.start_transaction(None).unwrap(); self.start_transaction(None).unwrap();
let mut offset = 0; let mut offset = 0;
@ -1153,7 +1145,7 @@ impl Buffer {
self.start_transaction_at(selection_set_ids, Instant::now()) self.start_transaction_at(selection_set_ids, Instant::now())
} }
fn start_transaction_at( pub(crate) fn start_transaction_at(
&mut self, &mut self,
selection_set_ids: impl IntoIterator<Item = SelectionSetId>, selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
now: Instant, now: Instant,
@ -1169,7 +1161,7 @@ impl Buffer {
self.end_transaction_at(selection_set_ids, Instant::now(), cx) self.end_transaction_at(selection_set_ids, Instant::now(), cx)
} }
fn end_transaction_at( pub(crate) fn end_transaction_at(
&mut self, &mut self,
selection_set_ids: impl IntoIterator<Item = SelectionSetId>, selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
now: Instant, now: Instant,
@ -1995,7 +1987,7 @@ fn diagnostic_ranges<'a>(
)) ))
} }
fn contiguous_ranges( pub fn contiguous_ranges(
values: impl IntoIterator<Item = u32>, values: impl IntoIterator<Item = u32>,
max_len: usize, max_len: usize,
) -> impl Iterator<Item = Range<u32>> { ) -> impl Iterator<Item = Range<u32>> {

View File

@ -1,6 +1,14 @@
use crate::HighlightMap; mod buffer;
mod highlight_map;
pub mod proto;
#[cfg(test)]
mod tests;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
pub use buffer::Operation;
pub use buffer::*;
use gpui::{executor::Background, AppContext}; use gpui::{executor::Background, AppContext};
use highlight_map::HighlightMap;
use lazy_static::lazy_static; use lazy_static::lazy_static;
use lsp::LanguageServer; use lsp::LanguageServer;
use parking_lot::Mutex; use parking_lot::Mutex;
@ -223,56 +231,3 @@ impl LanguageServerConfig {
) )
} }
} }
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_select_language() {
let registry = LanguageRegistry {
languages: vec![
Arc::new(Language::new(
LanguageConfig {
name: "Rust".to_string(),
path_suffixes: vec!["rs".to_string()],
..Default::default()
},
Some(tree_sitter_rust::language()),
)),
Arc::new(Language::new(
LanguageConfig {
name: "Make".to_string(),
path_suffixes: vec!["Makefile".to_string(), "mk".to_string()],
..Default::default()
},
Some(tree_sitter_rust::language()),
)),
],
};
// matching file extension
assert_eq!(
registry.select_language("zed/lib.rs").map(|l| l.name()),
Some("Rust")
);
assert_eq!(
registry.select_language("zed/lib.mk").map(|l| l.name()),
Some("Make")
);
// matching filename
assert_eq!(
registry.select_language("zed/Makefile").map(|l| l.name()),
Some("Make")
);
// matching suffix that is not the full file extension or filename
assert_eq!(registry.select_language("zed/cars").map(|l| l.name()), None);
assert_eq!(
registry.select_language("zed/a.cars").map(|l| l.name()),
None
);
assert_eq!(registry.select_language("zed/sumk").map(|l| l.name()), None);
}
}

View File

@ -1,8 +1,6 @@
use std::sync::Arc; use std::sync::Arc;
use crate::Diagnostic; use crate::{Diagnostic, Operation};
use super::Operation;
use anyhow::{anyhow, Result}; use anyhow::{anyhow, Result};
use clock::ReplicaId; use clock::ReplicaId;
use lsp::DiagnosticSeverity; use lsp::DiagnosticSeverity;

View File

@ -1,8 +1,56 @@
use super::*; use super::*;
use gpui::{ModelHandle, MutableAppContext}; use gpui::{ModelHandle, MutableAppContext, Task};
use std::{iter::FromIterator, rc::Rc}; use std::{any::Any, cell::RefCell, ffi::OsString, iter::FromIterator, ops::Range, path::PathBuf, rc::Rc, time::{Duration, Instant, SystemTime}};
use unindent::Unindent as _; use unindent::Unindent as _;
#[test]
fn test_select_language() {
let registry = LanguageRegistry {
languages: vec![
Arc::new(Language::new(
LanguageConfig {
name: "Rust".to_string(),
path_suffixes: vec!["rs".to_string()],
..Default::default()
},
Some(tree_sitter_rust::language()),
)),
Arc::new(Language::new(
LanguageConfig {
name: "Make".to_string(),
path_suffixes: vec!["Makefile".to_string(), "mk".to_string()],
..Default::default()
},
Some(tree_sitter_rust::language()),
)),
],
};
// matching file extension
assert_eq!(
registry.select_language("zed/lib.rs").map(|l| l.name()),
Some("Rust")
);
assert_eq!(
registry.select_language("zed/lib.mk").map(|l| l.name()),
Some("Make")
);
// matching filename
assert_eq!(
registry.select_language("zed/Makefile").map(|l| l.name()),
Some("Make")
);
// matching suffix that is not the full file extension or filename
assert_eq!(registry.select_language("zed/cars").map(|l| l.name()), None);
assert_eq!(
registry.select_language("zed/a.cars").map(|l| l.name()),
None
);
assert_eq!(registry.select_language("zed/sumk").map(|l| l.name()), None);
}
#[gpui::test] #[gpui::test]
fn test_edit_events(cx: &mut gpui::MutableAppContext) { fn test_edit_events(cx: &mut gpui::MutableAppContext) {
let mut now = Instant::now(); let mut now = Instant::now();

View File

@ -3,6 +3,9 @@ name = "lsp"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/lsp.rs"
[features] [features]
test-support = ["async-pipe"] test-support = ["async-pipe"]

View File

@ -3,6 +3,9 @@ name = "project"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/project.rs"
[features] [features]
test-support = ["language/test-support", "text/test-support"] test-support = ["language/test-support", "text/test-support"]

View File

@ -3,6 +3,9 @@ name = "project_panel"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/project_panel.rs"
[dependencies] [dependencies]
gpui = { path = "../gpui" } gpui = { path = "../gpui" }
project = { path = "../project" } project = { path = "../project" }

View File

@ -4,6 +4,9 @@ edition = "2018"
name = "rpc" name = "rpc"
version = "0.1.0" version = "0.1.0"
[lib]
path = "src/rpc.rs"
[features] [features]
test-support = [] test-support = []

View File

@ -3,6 +3,9 @@ name = "sum_tree"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/sum_tree.rs"
[dependencies] [dependencies]
arrayvec = "0.7.1" arrayvec = "0.7.1"

View File

@ -3,6 +3,9 @@ name = "theme"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/theme.rs"
[dependencies] [dependencies]
gpui = { path = "../gpui" } gpui = { path = "../gpui" }
anyhow = "1.0.38" anyhow = "1.0.38"

View File

@ -3,6 +3,9 @@ name = "theme_selector"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/theme_selector.rs"
[dependencies] [dependencies]
editor = { path = "../editor" } editor = { path = "../editor" }
fuzzy = { path = "../fuzzy" } fuzzy = { path = "../fuzzy" }

View File

@ -3,6 +3,9 @@ name = "workspace"
version = "0.1.0" version = "0.1.0"
edition = "2018" edition = "2018"
[lib]
path = "src/workspace.rs"
[features] [features]
test-support = [ test-support = [
"client/test-support", "client/test-support",

View File

@ -7,7 +7,7 @@ version = "0.9.0"
[lib] [lib]
name = "zed" name = "zed"
path = "src/lib.rs" path = "src/zed.rs"
[[bin]] [[bin]]
name = "Zed" name = "Zed"