vendor/assets/javascripts/ace/mode-dart.js in ace-rails-ap-3.0.2 vs vendor/assets/javascripts/ace/mode-dart.js in ace-rails-ap-3.0.3
- old
+ new
@@ -64,26 +64,26 @@
);
var storageType = (
"asm|__asm__|auto|bool|_Bool|char|_Complex|double|enum|float|" +
"_Imaginary|int|long|short|signed|struct|typedef|union|unsigned|void|" +
- "class|wchar_t|template"
+ "class|wchar_t|template|char16_t|char32_t"
);
var storageModifiers = (
"const|extern|register|restrict|static|volatile|inline|private|" +
"protected|public|friend|explicit|virtual|export|mutable|typename|" +
- "constexpr|new|delete"
+ "constexpr|new|delete|alignas|alignof|decltype|noexcept|thread_local"
);
var keywordOperators = (
"and|and_eq|bitand|bitor|compl|not|not_eq|or|or_eq|typeid|xor|xor_eq" +
"const_cast|dynamic_cast|reinterpret_cast|static_cast|sizeof|namespace"
);
var builtinConstants = (
- "NULL|true|false|TRUE|FALSE"
+ "NULL|true|false|TRUE|FALSE|nullptr"
);
var keywordMapper = this.$keywords = this.createKeywordMapper({
"keyword.control" : keywordControls,
"storage.type" : storageType,
@@ -127,15 +127,15 @@
}, {
token : "constant.numeric", // float
regex : "[+-]?\\d+(?:(?:\\.\\d*)?(?:[eE][+-]?\\d+)?)?(L|l|UL|ul|u|U|F|f|ll|LL|ull|ULL)?\\b"
}, {
token : "keyword", // pre-compiler directives
- regex : "#\\s*(?:include|import|pragma|line|define|undef|if|ifdef|else|elif|ifndef)\\b",
+ regex : "#\\s*(?:include|import|pragma|line|define|undef)\\b",
next : "directive"
}, {
token : "keyword", // special case pre-compiler directive
- regex : "(?:#\\s*endif)\\b"
+ regex : "#\\s*(?:endif|if|ifdef|else|elif|ifndef)\\b"
}, {
token : "support.function.C99.c",
regex : cFunctions
}, {
token : keywordMapper,
@@ -312,23 +312,33 @@
maybeInsertedLineStart: "",
maybeInsertedLineEnd: ""
};
};
+var getWrapped = function(selection, selected, opening, closing) {
+ var rowDiff = selection.end.row - selection.start.row;
+ return {
+ text: opening + selected + closing,
+ selection: [
+ 0,
+ selection.start.column + 1,
+ rowDiff,
+ selection.end.column + (rowDiff ? 0 : 1)
+ ]
+ };
+};
+
var CstyleBehaviour = function() {
this.add("braces", "insertion", function(state, action, editor, session, text) {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
if (text == '{') {
initContext(editor);
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) {
- return {
- text: '{' + selected + '}',
- selection: false
- };
+ return getWrapped(selection, selected, '{', '}');
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
CstyleBehaviour.recordAutoInsert(editor, session, "}");
return {
text: '{}',
@@ -404,14 +414,11 @@
if (text == '(') {
initContext(editor);
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
- return {
- text: '(' + selected + ')',
- selection: false
- };
+ return getWrapped(selection, selected, '(', ')');
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
CstyleBehaviour.recordAutoInsert(editor, session, ")");
return {
text: '()',
selection: [1, 1]
@@ -452,14 +459,11 @@
if (text == '[') {
initContext(editor);
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "" && editor.getWrapBehavioursEnabled()) {
- return {
- text: '[' + selected + ']',
- selection: false
- };
+ return getWrapped(selection, selected, '[', ']');
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
CstyleBehaviour.recordAutoInsert(editor, session, "]");
return {
text: '[]',
selection: [1, 1]
@@ -501,53 +505,48 @@
initContext(editor);
var quote = text;
var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection);
if (selected !== "" && selected !== "'" && selected != '"' && editor.getWrapBehavioursEnabled()) {
- return {
- text: quote + selected + quote,
- selection: false
- };
- } else {
+ return getWrapped(selection, selected, quote, quote);
+ } else if (!selected) {
var cursor = editor.getCursorPosition();
var line = session.doc.getLine(cursor.row);
var leftChar = line.substring(cursor.column-1, cursor.column);
- if (leftChar == '\\') {
+ var rightChar = line.substring(cursor.column, cursor.column + 1);
+
+ var token = session.getTokenAt(cursor.row, cursor.column);
+ var rightToken = session.getTokenAt(cursor.row, cursor.column + 1);
+ if (leftChar == "\\" && token && /escape/.test(token.type))
return null;
+
+ var stringBefore = token && /string/.test(token.type);
+ var stringAfter = !rightToken || /string/.test(rightToken.type);
+
+ var pair;
+ if (rightChar == quote) {
+ pair = stringBefore !== stringAfter;
+ } else {
+ if (stringBefore && !stringAfter)
+ return null; // wrap string with different quote
+ if (stringBefore && stringAfter)
+ return null; // do not pair quotes inside strings
+ var wordRe = session.$mode.tokenRe;
+ wordRe.lastIndex = 0;
+ var isWordBefore = wordRe.test(leftChar);
+ wordRe.lastIndex = 0;
+ var isWordAfter = wordRe.test(leftChar);
+ if (isWordBefore || isWordAfter)
+ return null; // before or after alphanumeric
+ if (rightChar && !/[\s;,.})\]\\]/.test(rightChar))
+ return null; // there is rightChar and it isn't closing
+ pair = true;
}
- var tokens = session.getTokens(selection.start.row);
- var col = 0, token;
- var quotepos = -1; // Track whether we're inside an open quote.
-
- for (var x = 0; x < tokens.length; x++) {
- token = tokens[x];
- if (token.type == "string") {
- quotepos = -1;
- } else if (quotepos < 0) {
- quotepos = token.value.indexOf(quote);
- }
- if ((token.value.length + col) > selection.start.column) {
- break;
- }
- col += tokens[x].value.length;
- }
- if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
- if (!CstyleBehaviour.isSaneInsertion(editor, session))
- return;
- return {
- text: quote + quote,
- selection: [1,1]
- };
- } else if (token && token.type === "string") {
- var rightChar = line.substring(cursor.column, cursor.column + 1);
- if (rightChar == quote) {
- return {
- text: '',
- selection: [1, 1]
- };
- }
- }
+ return {
+ text: pair ? quote + quote : "",
+ selection: [1,1]
+ };
}
}
});
this.add("string_dquotes", "deletion", function(state, action, editor, session, range) {
@@ -655,16 +654,39 @@
}
};
oop.inherits(FoldMode, BaseFoldMode);
(function() {
-
+
this.foldingStartMarker = /(\{|\[)[^\}\]]*$|^\s*(\/\*)/;
this.foldingStopMarker = /^[^\[\{]*(\}|\])|^[\s\*]*(\*\/)/;
+ this.singleLineBlockCommentRe= /^\s*(\/\*).*\*\/\s*$/;
+ this.tripleStarBlockCommentRe = /^\s*(\/\*\*\*).*\*\/\s*$/;
+ this.startRegionRe = /^\s*(\/\*|\/\/)#region\b/;
+ this._getFoldWidgetBase = this.getFoldWidget;
+ this.getFoldWidget = function(session, foldStyle, row) {
+ var line = session.getLine(row);
+
+ if (this.singleLineBlockCommentRe.test(line)) {
+ if (!this.startRegionRe.test(line) && !this.tripleStarBlockCommentRe.test(line))
+ return "";
+ }
+
+ var fw = this._getFoldWidgetBase(session, foldStyle, row);
+
+ if (!fw && this.startRegionRe.test(line))
+ return "start"; // lineCommentRegionStart
+
+ return fw;
+ };
this.getFoldWidgetRange = function(session, foldStyle, row, forceMultiline) {
var line = session.getLine(row);
+
+ if (this.startRegionRe.test(line))
+ return this.getCommentRegionBlock(session, line, row);
+
var match = line.match(this.foldingStartMarker);
if (match) {
var i = match.index;
if (match[1])
@@ -725,11 +747,34 @@
endRow = row;
}
return new Range(startRow, startColumn, endRow, session.getLine(endRow).length);
};
+
+ this.getCommentRegionBlock = function(session, line, row) {
+ var startColumn = line.search(/\s*$/);
+ var maxRow = session.getLength();
+ var startRow = row;
+
+ var re = /^\s*(?:\/\*|\/\/)#(end)?region\b/;
+ var depth = 1;
+ while (++row < maxRow) {
+ line = session.getLine(row);
+ var m = re.exec(line);
+ if (!m) continue;
+ if (m[1]) depth--;
+ else depth++;
+ if (!depth) break;
+ }
+
+ var endRow = row;
+ if (endRow > startRow) {
+ return new Range(startRow, startColumn, endRow, line.length);
+ }
+ };
+
}).call(FoldMode.prototype);
});
define("ace/mode/c_cpp",["require","exports","module","ace/lib/oop","ace/mode/text","ace/mode/c_cpp_highlight_rules","ace/mode/matching_brace_outdent","ace/range","ace/mode/behaviour/cstyle","ace/mode/folding/cstyle"], function(require, exports, module) {
@@ -813,11 +858,11 @@
var DartHighlightRules = function() {
var constantLanguage = "true|false|null";
var variableLanguage = "this|super";
- var keywordControl = "try|catch|finally|throw|rethrow|assert|break|case|continue|default|do|else|for|if|in|return|switch|while|new";
- var keywordDeclaration = "abstract|class|extends|external|factory|implements|get|native|operator|set|typedef|with";
+ var keywordControl = "try|catch|finally|throw|rethrow|assert|break|case|continue|default|do|else|for|if|in|return|switch|while|new|deferred|async|await";
+ var keywordDeclaration = "abstract|class|extends|external|factory|implements|get|native|operator|set|typedef|with|enum";
var storageModifier = "static|final|const";
var storageType = "void|bool|num|int|double|dynamic|var|String";
var keywordMapper = this.createKeywordMapper({
"constant.language.dart": constantLanguage,