Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
4654: Add semantic highlight to ? operator r=matklad a=ruabmbua

Made it an operator with controlFlow modifier.

To highlight in vscode as red:

```json
"editor.semanticTokenColorCustomizations": {
        "enabled": true,
        "rules": {
            "operator.controlFlow": "#ff0000",
        }
}
```

![Bildschirmfoto von 2020-05-29 21-32-06](https://user-images.githubusercontent.com/2522373/83297998-f3585a00-a1f3-11ea-9d14-4ef04b9b6b9a.png)

rust-lang#4597


Co-authored-by: Roland Ruckerbauer <roland.rucky@gmail.com>
  • Loading branch information
bors[bot] and ruabmbua authored May 30, 2020
2 parents 5d84028 + 18aa4bc commit 07060b3
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 0 deletions.
1 change: 1 addition & 0 deletions crates/ra_ide/src/syntax_highlighting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ fn highlight_element(
INT_NUMBER | FLOAT_NUMBER => HighlightTag::NumericLiteral.into(),
BYTE => HighlightTag::ByteLiteral.into(),
CHAR => HighlightTag::CharLiteral.into(),
QUESTION => Highlight::new(HighlightTag::Operator) | HighlightModifier::ControlFlow,
LIFETIME => {
let h = Highlight::new(HighlightTag::Lifetime);
match element.parent().map(|it| it.kind()) {
Expand Down
2 changes: 2 additions & 0 deletions crates/ra_ide/src/syntax_highlighting/tags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ pub enum HighlightTag {
Local,
UnresolvedReference,
FormatSpecifier,
Operator,
}

#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
Expand Down Expand Up @@ -89,6 +90,7 @@ impl HighlightTag {
HighlightTag::Local => "variable",
HighlightTag::UnresolvedReference => "unresolved_reference",
HighlightTag::FormatSpecifier => "format_specifier",
HighlightTag::Operator => "operator",
}
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/rust-analyzer/src/to_proto.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ fn semantic_token_type_and_modifiers(
HighlightTag::Keyword => lsp_types::SemanticTokenType::KEYWORD,
HighlightTag::UnresolvedReference => semantic_tokens::UNRESOLVED_REFERENCE,
HighlightTag::FormatSpecifier => semantic_tokens::FORMAT_SPECIFIER,
HighlightTag::Operator => lsp_types::SemanticTokenType::OPERATOR,
};

for modifier in highlight.modifiers.iter() {
Expand Down

0 comments on commit 07060b3

Please sign in to comment.