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 09f903c commit 838d3b9
Show file tree
Hide file tree
Showing 20 changed files with 40 additions and 2,016 deletions.
4 changes: 2 additions & 2 deletions .azure/azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ steps:
echo "##vso[task.prependpath]$HOME/.cargo/bin"
rustup component add rustfmt --toolchain "stable"
displayName: Install Rust
- bash: RUSTFLAGS="-D warnings" cargo test --all --features=user-visible
- bash: RUSTFLAGS="-D warnings" cargo test --all --features=stable
condition: eq(variables['style'], 'unflagged')
displayName: Run tests
- bash: NUSHELL_ENABLE_ALL_FLAGS=1 RUSTFLAGS="-D warnings" cargo test --all --features=user-visible
- bash: NUSHELL_ENABLE_ALL_FLAGS=1 RUSTFLAGS="-D warnings" cargo test --all --features=stable
condition: eq(variables['style'], 'canary')
displayName: Run tests
- bash: cargo fmt --all -- --check
Expand Down
2 changes: 1 addition & 1 deletion .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
image:
file: .gitpod.Dockerfile
tasks:
- init: cargo install nu --features=user-visible
- init: cargo install nu --features=stable
command: nu
github:
prebuilds:
Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ semver = {version = "0.9.0", optional = true}

[features]
default = ["sys", "ps", "textview", "inc", "str"]
user-visible = ["sys", "ps", "starship-prompt", "textview", "binaryview", "match", "tree", "average", "sum"]
stable = ["sys", "ps", "starship-prompt", "textview", "binaryview", "match", "tree", "average", "sum"]

sys = ["heim", "battery"]
ps = ["heim", "futures-timer"]
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ cargo install nu
You can also install Nu with all the bells and whistles (be sure to have installed the [dependencies](https://book.nushell.sh/en/installation#dependencies) for your platform):

```
cargo install nu --features=user-visible
cargo install nu --features=stable
```

## Docker
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 @@ -41,4 +41,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 @@ -69,33 +67,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 @@ -295,7 +266,6 @@ impl ExpandExpression for ExternalContinuationShape {
}
}

#[cfg(coloring_in_tokens)]
impl ColorSyntax for ExternalExpressionShape {
type Info = ExternalExpressionResult;
type Input = ();
Expand Down Expand Up @@ -334,34 +304,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 838d3b9

Please sign in to comment.