Derive debug without feature

Note that this also removed those `finish_non_exhaustive()`.
imgbot
Ivan Tham 3 years ago committed by Blaž Hrastnik
parent 1a3a924634
commit 7cc13fefe9

@ -10,7 +10,6 @@ license = "MPL-2.0"
[features] [features]
embed_runtime = ["rust-embed"] embed_runtime = ["rust-embed"]
debug = []
[dependencies] [dependencies]
helix-syntax = { path = "../helix-syntax" } helix-syntax = { path = "../helix-syntax" }

@ -1,5 +1,4 @@
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Eq, PartialEq)]
#[derive(Eq, PartialEq)]
pub enum Severity { pub enum Severity {
Error, Error,
Warning, Warning,
@ -7,13 +6,13 @@ pub enum Severity {
Hint, Hint,
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Range { pub struct Range {
pub start: usize, pub start: usize,
pub end: usize, pub end: usize,
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Diagnostic { pub struct Diagnostic {
pub range: Range, pub range: Range,
pub line: usize, pub line: usize,

@ -147,8 +147,7 @@ pub fn is_grapheme_boundary(slice: RopeSlice, char_idx: usize) -> bool {
} }
/// An iterator over the graphemes of a `RopeSlice`. /// An iterator over the graphemes of a `RopeSlice`.
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Clone)]
#[derive(Clone)]
pub struct RopeGraphemes<'a> { pub struct RopeGraphemes<'a> {
text: RopeSlice<'a>, text: RopeSlice<'a>,
chunks: Chunks<'a>, chunks: Chunks<'a>,

@ -2,7 +2,7 @@ use crate::{ChangeSet, Rope, State, Transaction};
use smallvec::{smallvec, SmallVec}; use smallvec::{smallvec, SmallVec};
/// Undo-tree style history store. /// Undo-tree style history store.
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct History { pub struct History {
revisions: Vec<Revision>, revisions: Vec<Revision>,
cursor: usize, cursor: usize,

@ -1,8 +1,7 @@
use crate::graphemes::{nth_next_grapheme_boundary, nth_prev_grapheme_boundary, RopeGraphemes}; use crate::graphemes::{nth_next_grapheme_boundary, nth_prev_grapheme_boundary, RopeGraphemes};
use crate::{coords_at_pos, pos_at_coords, ChangeSet, Position, Range, Rope, RopeSlice, Selection}; use crate::{coords_at_pos, pos_at_coords, ChangeSet, Position, Range, Rope, RopeSlice, Selection};
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum Direction { pub enum Direction {
Forward, Forward,
Backward, Backward,

@ -1,8 +1,7 @@
use crate::{Rope, Selection}; use crate::{Rope, Selection};
/// A state represents the current editor state of a single buffer. /// A state represents the current editor state of a single buffer.
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Clone)]
#[derive(Clone)]
pub struct State { pub struct State {
pub doc: Rope, pub doc: Rope,
pub selection: Selection, pub selection: Selection,

@ -1,12 +1,11 @@
use crate::{regex::Regex, Change, Rope, RopeSlice, Transaction}; use crate::{regex::Regex, Change, Rope, RopeSlice, Transaction};
pub use helix_syntax::{get_language, get_language_name, Lang}; pub use helix_syntax::{get_language, get_language_name, Lang};
#[cfg(feature = "debug")]
use std::fmt;
use std::{ use std::{
borrow::Cow, borrow::Cow,
cell::RefCell, cell::RefCell,
collections::{HashMap, HashSet}, collections::{HashMap, HashSet},
fmt,
path::{Path, PathBuf}, path::{Path, PathBuf},
sync::Arc, sync::Arc,
}; };
@ -14,15 +13,13 @@ use std::{
use once_cell::sync::{Lazy, OnceCell}; use once_cell::sync::{Lazy, OnceCell};
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Serialize, Deserialize)]
#[derive(Serialize, Deserialize)]
pub struct Configuration { pub struct Configuration {
pub language: Vec<LanguageConfiguration>, pub language: Vec<LanguageConfiguration>,
} }
// largely based on tree-sitter/cli/src/loader.rs // largely based on tree-sitter/cli/src/loader.rs
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Serialize, Deserialize)]
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub struct LanguageConfiguration { pub struct LanguageConfiguration {
#[serde(rename = "name")] #[serde(rename = "name")]
@ -50,8 +47,7 @@ pub struct LanguageConfiguration {
pub(crate) indent_query: OnceCell<Option<IndentQuery>>, pub(crate) indent_query: OnceCell<Option<IndentQuery>>,
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Serialize, Deserialize)]
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub struct LanguageServerConfiguration { pub struct LanguageServerConfiguration {
pub command: String, pub command: String,
@ -60,16 +56,14 @@ pub struct LanguageServerConfiguration {
pub args: Vec<String>, pub args: Vec<String>,
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Serialize, Deserialize)]
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub struct IndentationConfiguration { pub struct IndentationConfiguration {
pub tab_width: usize, pub tab_width: usize,
pub unit: String, pub unit: String,
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Serialize, Deserialize)]
#[derive(Serialize, Deserialize)]
#[serde(rename_all = "kebab-case")] #[serde(rename_all = "kebab-case")]
pub struct IndentQuery { pub struct IndentQuery {
#[serde(default)] #[serde(default)]
@ -196,7 +190,7 @@ impl LanguageConfiguration {
pub static LOADER: OnceCell<Loader> = OnceCell::new(); pub static LOADER: OnceCell<Loader> = OnceCell::new();
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Loader { pub struct Loader {
// highlight_names ? // highlight_names ?
language_configs: Vec<Arc<LanguageConfiguration>>, language_configs: Vec<Arc<LanguageConfiguration>>,
@ -264,10 +258,9 @@ pub struct TsParser {
cursors: Vec<QueryCursor>, cursors: Vec<QueryCursor>,
} }
#[cfg(feature = "debug")]
impl fmt::Debug for TsParser { impl fmt::Debug for TsParser {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("TsParser").finish_non_exhaustive() f.debug_struct("TsParser").finish()
} }
} }
@ -279,7 +272,7 @@ thread_local! {
}) })
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Syntax { pub struct Syntax {
config: Arc<HighlightConfiguration>, config: Arc<HighlightConfiguration>,
@ -460,7 +453,7 @@ impl Syntax {
// buffer_range_for_scope_at_pos // buffer_range_for_scope_at_pos
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct LanguageLayer { pub struct LanguageLayer {
// mode // mode
// grammar // grammar
@ -769,7 +762,7 @@ pub enum HighlightEvent {
/// Contains the data neeeded to higlight code written in a particular language. /// Contains the data neeeded to higlight code written in a particular language.
/// ///
/// This struct is immutable and can be shared between threads. /// This struct is immutable and can be shared between threads.
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct HighlightConfiguration { pub struct HighlightConfiguration {
pub language: Grammar, pub language: Grammar,
pub query: Query, pub query: Query,
@ -800,7 +793,7 @@ struct LocalScope<'a> {
local_defs: Vec<LocalDef<'a>>, local_defs: Vec<LocalDef<'a>>,
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
struct HighlightIter<'a, 'tree: 'a, F> struct HighlightIter<'a, 'tree: 'a, F>
where where
F: FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a, F: FnMut(&str) -> Option<&'a HighlightConfiguration> + 'a,
@ -826,10 +819,9 @@ struct HighlightIterLayer<'a, 'tree: 'a> {
depth: usize, depth: usize,
} }
#[cfg(feature = "debug")]
impl<'a, 'tree: 'a> fmt::Debug for HighlightIterLayer<'a, 'tree> { impl<'a, 'tree: 'a> fmt::Debug for HighlightIterLayer<'a, 'tree> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("HighlightIterLayer").finish_non_exhaustive() f.debug_struct("HighlightIterLayer").finish()
} }
} }

@ -15,8 +15,7 @@ pub enum Operation {
Insert(Tendril), Insert(Tendril),
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Copy, Clone, PartialEq, Eq)]
#[derive(Copy, Clone, PartialEq, Eq)]
pub enum Assoc { pub enum Assoc {
Before, Before,
After, After,

@ -7,9 +7,6 @@ license = "MPL-2.0"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[features]
debug = ["helix-core/debug"]
[dependencies] [dependencies]
helix-core = { path = "../helix-core" } helix-core = { path = "../helix-core" }

@ -16,7 +16,7 @@ use tokio::{
sync::mpsc::{channel, UnboundedReceiver, UnboundedSender}, sync::mpsc::{channel, UnboundedReceiver, UnboundedSender},
}; };
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Client { pub struct Client {
_process: Child, _process: Child,
server_tx: UnboundedSender<Payload>, server_tx: UnboundedSender<Payload>,

@ -172,7 +172,7 @@ impl Notification {
} }
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Registry { pub struct Registry {
inner: HashMap<LanguageId, Arc<Client>>, inner: HashMap<LanguageId, Arc<Client>>,

@ -31,7 +31,7 @@ enum ServerMessage {
Call(jsonrpc::Call), Call(jsonrpc::Call),
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Transport { pub struct Transport {
client_tx: UnboundedSender<jsonrpc::Call>, client_tx: UnboundedSender<jsonrpc::Call>,
client_rx: UnboundedReceiver<Payload>, client_rx: UnboundedReceiver<Payload>,

@ -10,7 +10,6 @@ license = "MPL-2.0"
[features] [features]
embed_runtime = ["helix-core/embed_runtime"] embed_runtime = ["helix-core/embed_runtime"]
debug = ["helix-core/debug", "helix-view/debug"]
[[bin]] [[bin]]
name = "hx" name = "hx"

@ -10,7 +10,6 @@ license = "MPL-2.0"
[features] [features]
default = ["crossterm"] default = ["crossterm"]
debug = []
[dependencies] [dependencies]
bitflags = "1.0" bitflags = "1.0"

@ -10,7 +10,6 @@ license = "MPL-2.0"
[features] [features]
term = ["tui", "crossterm"] term = ["tui", "crossterm"]
default = ["term"] default = ["term"]
debug = ["helix-core/debug", "helix-lsp/debug"]
[dependencies] [dependencies]
anyhow = "1" anyhow = "1"

@ -13,8 +13,7 @@ use crate::{DocumentId, ViewId};
use std::collections::HashMap; use std::collections::HashMap;
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, PartialEq, Eq, Hash)]
pub enum Mode { pub enum Mode {
Normal, Normal,
Select, Select,
@ -53,9 +52,7 @@ pub struct Document {
language_server: Option<Arc<helix_lsp::Client>>, language_server: Option<Arc<helix_lsp::Client>>,
} }
#[cfg(feature = "debug")]
use std::fmt; use std::fmt;
#[cfg(feature = "debug")]
impl fmt::Debug for Document { impl fmt::Debug for Document {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Document") f.debug_struct("Document")
@ -74,7 +71,7 @@ impl fmt::Debug for Document {
.field("version", &self.version) .field("version", &self.version)
.field("diagnostics", &self.diagnostics) .field("diagnostics", &self.diagnostics)
// .field("language_server", &self.language_server) // .field("language_server", &self.language_server)
.finish_non_exhaustive() .finish()
} }
} }

@ -9,7 +9,7 @@ use anyhow::Error;
pub use helix_core::diagnostic::Severity; pub use helix_core::diagnostic::Severity;
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Editor { pub struct Editor {
pub tree: Tree, pub tree: Tree,
pub documents: SlotMap<DocumentId, Document>, pub documents: SlotMap<DocumentId, Document>,
@ -21,8 +21,7 @@ pub struct Editor {
pub status_msg: Option<(String, Severity)>, pub status_msg: Option<(String, Severity)>,
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, Copy, Clone)]
#[derive(Copy, Clone)]
pub enum Action { pub enum Action {
Replace, Replace,
HorizontalSplit, HorizontalSplit,

@ -4,7 +4,7 @@ use tui::layout::Rect;
// the dimensions are recomputed on windo resize/tree change. // the dimensions are recomputed on windo resize/tree change.
// //
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Tree { pub struct Tree {
root: ViewId, root: ViewId,
// (container, index inside the container) // (container, index inside the container)
@ -18,13 +18,13 @@ pub struct Tree {
stack: Vec<(ViewId, Rect)>, stack: Vec<(ViewId, Rect)>,
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Node { pub struct Node {
parent: ViewId, parent: ViewId,
content: Content, content: Content,
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub enum Content { pub enum Content {
View(Box<View>), View(Box<View>),
Container(Box<Container>), Container(Box<Container>),
@ -48,15 +48,14 @@ impl Node {
// TODO: screen coord to container + container coordinate helpers // TODO: screen coord to container + container coordinate helpers
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug, PartialEq, Eq)]
#[derive(PartialEq, Eq)]
pub enum Layout { pub enum Layout {
Horizontal, Horizontal,
Vertical, Vertical,
// could explore stacked/tabbed // could explore stacked/tabbed
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Container { pub struct Container {
layout: Layout, layout: Layout,
children: Vec<ViewId>, children: Vec<ViewId>,
@ -437,7 +436,7 @@ impl Tree {
} }
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct Traverse<'a> { pub struct Traverse<'a> {
tree: &'a Tree, tree: &'a Tree,
stack: Vec<ViewId>, // TODO: reuse the one we use on update stack: Vec<ViewId>, // TODO: reuse the one we use on update

@ -12,7 +12,7 @@ pub const PADDING: usize = 5;
type Jump = (DocumentId, Selection); type Jump = (DocumentId, Selection);
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct JumpList { pub struct JumpList {
jumps: Vec<Jump>, jumps: Vec<Jump>,
current: usize, current: usize,
@ -59,7 +59,7 @@ impl JumpList {
} }
} }
#[cfg_attr(feature = "debug", derive(Debug))] #[derive(Debug)]
pub struct View { pub struct View {
pub id: ViewId, pub id: ViewId,
pub doc: DocumentId, pub doc: DocumentId,

Loading…
Cancel
Save