Skip to content

Commit

Permalink
Remove the coloring_in_tokens feature flag
Browse files Browse the repository at this point in the history
Stabilize and enable
  • Loading branch information
wycats committed Dec 12, 2019
1 parent 24bad78 commit 801c856
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 1,949 deletions.
8 changes: 5 additions & 3 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -108,13 +108,15 @@ image = { version = "0.22.2", default_features = false, features = ["png_codec",
starship = { version = "0.26.4", optional = true}

[features]
stable = ["sys", "ps", "raw-key", "binaryview", "starship-prompt"]
default = ["sys", "ps"]
raw-key = ["rawkey", "neso"]
binaryview = ["image", "crossterm"]

sys = ["heim", "battery"]
ps = ["heim"]
raw-key = ["rawkey", "neso"]
binaryview = ["image", "crossterm"]
starship-prompt = ["starship"]
#trace = ["nu-parser/trace"]
trace = ["nu-parser/trace"]

[dependencies.rusqlite]
version = "0.20.0"
Expand Down
1 change: 1 addition & 0 deletions crates/nu-parser/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ pretty_assertions = "0.6.1"
nu-build = { version = "0.1.0", path = "../nu-build" }

[features]
stable = []
trace = ["nom-tracable/trace"]
61 changes: 0 additions & 61 deletions crates/nu-parser/src/hir/expand_external_tokens.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#[cfg(not(coloring_in_tokens))]
use crate::hir::syntax_shape::FlatShape;
use crate::{
hir::syntax_shape::{
color_syntax, expand_atom, expand_expr, expand_syntax, AtomicToken, ColorSyntax,
Expand Down Expand Up @@ -68,33 +66,6 @@ impl ExpandSyntax for ExternalTokensShape {
}
}

#[cfg(not(coloring_in_tokens))]
impl ColorSyntax for ExternalTokensShape {
type Info = ();
type Input = ();

fn color_syntax<'a, 'b>(
&self,
_input: &(),
token_nodes: &'b mut TokensIterator<'a>,
context: &ExpandContext,
shapes: &mut Vec<Spanned<FlatShape>>,
) -> Self::Info {
loop {
// Allow a space
color_syntax(&MaybeSpaceShape, token_nodes, context, shapes);

// Process an external expression. External expressions are mostly words, with a
// few exceptions (like $variables and path expansion rules)
match color_syntax(&ExternalExpressionShape, token_nodes, context, shapes).1 {
ExternalExpressionResult::Eof => break,
ExternalExpressionResult::Processed => continue,
}
}
}
}

#[cfg(coloring_in_tokens)]
impl ColorSyntax for ExternalTokensShape {
type Info = ();
type Input = ();
Expand Down Expand Up @@ -276,7 +247,6 @@ impl ExpandExpression for ExternalContinuationShape {
}
}

#[cfg(coloring_in_tokens)]
impl ColorSyntax for ExternalExpressionShape {
type Info = ExternalExpressionResult;
type Input = ();
Expand Down Expand Up @@ -315,34 +285,3 @@ pub enum ExternalExpressionResult {
Eof,
Processed,
}

#[cfg(not(coloring_in_tokens))]
impl ColorSyntax for ExternalExpressionShape {
type Info = ExternalExpressionResult;
type Input = ();

fn color_syntax<'a, 'b>(
&self,
_input: &(),
token_nodes: &'b mut TokensIterator<'a>,
context: &ExpandContext,
shapes: &mut Vec<Spanned<FlatShape>>,
) -> ExternalExpressionResult {
let atom = match expand_atom(
token_nodes,
"external word",
context,
ExpansionRule::permissive(),
) {
Err(_) => unreachable!("TODO: separate infallible expand_atom"),
Ok(AtomicToken {
unspanned: UnspannedAtomicToken::Eof { .. },
..
}) => return ExternalExpressionResult::Eof,
Ok(atom) => atom,
};

atom.color_tokens(shapes);
return ExternalExpressionResult::Processed;
}
}

0 comments on commit 801c856

Please sign in to comment.