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"
edition = "2018"
[lib]
path = "src/chat_panel.rs"
[dependencies]
client = { path = "../client" }
editor = { path = "../editor" }

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,15 +1,7 @@
mod highlight_map;
mod language;
pub mod proto;
#[cfg(test)]
mod tests;
pub use self::{
pub use crate::{
highlight_map::{HighlightId, HighlightMap},
language::{
BracketPair, Grammar, Language, LanguageConfig, LanguageRegistry, LanguageServerConfig,
PLAIN_TEXT,
},
proto, BracketPair, Grammar, Language, LanguageConfig, LanguageRegistry, LanguageServerConfig,
PLAIN_TEXT,
};
use anyhow::{anyhow, Result};
use clock::ReplicaId;
@ -73,7 +65,7 @@ pub struct Buffer {
diagnostics_update_count: usize,
language_server: Option<LanguageServerState>,
#[cfg(test)]
operations: Vec<Operation>,
pub(crate) operations: Vec<Operation>,
}
pub struct Snapshot {
@ -217,7 +209,7 @@ pub struct Chunk<'a> {
pub diagnostic: Option<DiagnosticSeverity>,
}
struct Diff {
pub(crate) struct Diff {
base_version: clock::Global,
new_text: Arc<str>,
changes: Vec<(ChangeTag, usize)>,
@ -573,7 +565,7 @@ impl Buffer {
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() {
self.interpolate_tree(syntax_tree);
Some(syntax_tree.tree.clone())
@ -1094,7 +1086,7 @@ impl Buffer {
.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.
let old_text = self.text();
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 {
self.start_transaction(None).unwrap();
let mut offset = 0;
@ -1153,7 +1145,7 @@ impl Buffer {
self.start_transaction_at(selection_set_ids, Instant::now())
}
fn start_transaction_at(
pub(crate) fn start_transaction_at(
&mut self,
selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
now: Instant,
@ -1169,7 +1161,7 @@ impl Buffer {
self.end_transaction_at(selection_set_ids, Instant::now(), cx)
}
fn end_transaction_at(
pub(crate) fn end_transaction_at(
&mut self,
selection_set_ids: impl IntoIterator<Item = SelectionSetId>,
now: Instant,
@ -1995,7 +1987,7 @@ fn diagnostic_ranges<'a>(
))
}
fn contiguous_ranges(
pub fn contiguous_ranges(
values: impl IntoIterator<Item = u32>,
max_len: usize,
) -> 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};
pub use buffer::Operation;
pub use buffer::*;
use gpui::{executor::Background, AppContext};
use highlight_map::HighlightMap;
use lazy_static::lazy_static;
use lsp::LanguageServer;
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 crate::Diagnostic;
use super::Operation;
use crate::{Diagnostic, Operation};
use anyhow::{anyhow, Result};
use clock::ReplicaId;
use lsp::DiagnosticSeverity;

View file

@ -1,8 +1,56 @@
use super::*;
use gpui::{ModelHandle, MutableAppContext};
use std::{iter::FromIterator, rc::Rc};
use gpui::{ModelHandle, MutableAppContext, Task};
use std::{any::Any, cell::RefCell, ffi::OsString, iter::FromIterator, ops::Range, path::PathBuf, rc::Rc, time::{Duration, Instant, SystemTime}};
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]
fn test_edit_events(cx: &mut gpui::MutableAppContext) {
let mut now = Instant::now();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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