|
| 1 | +import ace from 'brace'; |
| 2 | +import 'brace/mode/rust'; |
| 3 | + |
| 4 | +ace.define('ace/mode/rust-playground', function(require, exports, module) { |
| 5 | + const oop = require("ace/lib/oop"); |
| 6 | + const { Mode: RustMode } = require("ace/mode/rust"); |
| 7 | + const { RustPlaygroundHighlightRules } = require("ace/mode/rust_playground_highlight_rules"); |
| 8 | + |
| 9 | + const Mode = function() { |
| 10 | + this.HighlightRules = RustPlaygroundHighlightRules; |
| 11 | + }; |
| 12 | + oop.inherits(Mode, RustMode); |
| 13 | + |
| 14 | + (function() { |
| 15 | + // Extra logic goes here. |
| 16 | + }).call(Mode.prototype); |
| 17 | + |
| 18 | + exports.Mode = Mode; |
| 19 | +}); |
| 20 | + |
| 21 | +ace.define('ace/mode/rust_playground_highlight_rules', function(require, exports, module) { |
| 22 | + const oop = require("ace/lib/oop"); |
| 23 | + const { RustHighlightRules } = require('ace/mode/rust_highlight_rules'); |
| 24 | + |
| 25 | + const RustPlaygroundHighlightRules = function() { |
| 26 | + this.$rules = new RustHighlightRules().getRules(); |
| 27 | + |
| 28 | + // Overriding until the next release that adds the `dyn` token |
| 29 | + const rule = this.$rules.start.find(r => r.token === "keyword.source.rust"); |
| 30 | + rule.regex = '\\b(?:abstract|alignof|as|become|box|break|catch|continue|const|crate|default|do|dyn|else|enum|extern|for|final|if|impl|in|let|loop|macro|match|mod|move|mut|offsetof|override|priv|proc|pub|pure|ref|return|self|sizeof|static|struct|super|trait|type|typeof|union|unsafe|unsized|use|virtual|where|while|yield)\\b'; |
| 31 | + } |
| 32 | + |
| 33 | + oop.inherits(RustPlaygroundHighlightRules, RustHighlightRules); |
| 34 | + |
| 35 | + exports.RustPlaygroundHighlightRules = RustPlaygroundHighlightRules; |
| 36 | +}); |
0 commit comments