Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

1c #4132

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open

1c #4132

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
778 changes: 778 additions & 0 deletions demo/kitchen-sink/docs/_1c.1c

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions lib/ace/ext/modelist.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Mode.prototype.supportsFile = function(filename) {

// todo firstlinematch
var supportedModes = {
_1C: ["1c"],
ABAP: ["abap"],
ABC: ["abc"],
ActionScript:["as"],
Expand Down Expand Up @@ -206,6 +207,7 @@ var supportedModes = {
};

var nameOverrides = {
_1C: "1C 7.7,8.x",
ObjectiveC: "Objective-C",
CSharp: "C#",
golang: "Go",
Expand Down
58 changes: 58 additions & 0 deletions lib/ace/mode/_1c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2012, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */

/*
THIS FILE WAS AUTOGENERATED BY mode.tmpl.js
*/

define(function (require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextMode = require("./text").Mode;
var _1CHighlightRules = require("./_1c_highlight_rules")._1CHighlightRules;
var _1CFoldMode = require("./folding/1c").FoldMode;

var Mode = function () {
this.HighlightRules = _1CHighlightRules;
this.foldingRules = new _1CFoldMode();
this.$behaviour = this.$defaultBehaviour;
};
oop.inherits(Mode, TextMode);

(function () {
this.lineCommentStart = "//";
// this.blockComment = {start: ""/*"", end: ""*/""};
// Extra logic goes here.
this.$id = "ace/mode/1c";
}).call(Mode.prototype);

exports.Mode = Mode;
});
123 changes: 123 additions & 0 deletions lib/ace/mode/_1c_highlight_rules.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */

define(function(require, exports, module) {
"use strict";

var oop = require("../lib/oop");
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;

var _1CHighlightRules = function() {

var keywords = (
"процедура|функция|конецпроцедуры|конецфункции|для|пока|по|цикл|конеццикла|если|тогда|иначе|иначеесли|конецесли|попытка|исключение|конецпопытки|каждого|" +
"перем|знач|и|или|не|новый|прервать|продолжить|возврат|экспорт|массив|структура|соответствие|массив|вызватьисключение" +
"procedure|function|endprocedure|endfunction|for|while|to|do|enddo|if|then|else|elseif|endif|try|catch|endtry|each|" +
"var|val|and|or|not|new|break|continue|return|export|array|structure|map|rise"
);
var builtinConstants = (
"истина|ложь|неопределено|true|false"
);
var builtinFunctions = (
"лев|сред|прав|цел|окр|минимум|максимум|число|строка|дата|формат|сокрлп|сокрл|символ|кодсимвола|" +
"врег|нрег|трег|найти|стрнайти|стрчисловхождений|пустаястрока|стрзаменить|стрчислострок|стрполучитьстроку|" +
"стрразделить|стрсоединить|год|месяц|день|час|минута|секунда|началогода|началоквартала|началомесяца|началонедели|" +
"началодня|началочаса|началоминуты|конецгода|конецквартала|конецмесяца|конецнедели|конецдня|конецчаса|конецминуты|" +
"тип|типзнч|показатьвопрос|вопрос|предупреждение|сообщить"
);
var dataTypes = (
"константы|справочники|документы|журналыдокументов|перечисления|регистрысведений|регистрынакопления|отчеты|обработки" +
"планывидовхарактеристик|планыобмена|параметрысеанса|роли|общиереквизиты|общиеформы|общиемакеты|критерииотбора"
);
var keywordMapper = this.createKeywordMapper({
"support.function": builtinFunctions,
"keyword": keywords,
"constant.language": builtinConstants,
"types": dataTypes
}, "identifier", true);

this.$rules = {
"start" : [ {
token : "comment",
regex : "\/\/.*"
},
{
token: keywordMapper,
regex: "[_A-Za-zА-ЯЁа-яё][_A-Za-z0-9А-ЯЁа-яё]*"
},
{
token : "label",
regex : "~(\u0020|\t)*[_A-Za-zА-ЯЁа-яё][_A-Za-z0-9А-ЯЁа-яё]*(\u0020|\t)*:"
},
{
token : "string", // ' string
regex : "\"{1,1}[^\"]*\"{1,1}"
},
{
token : "identifier", // ' identifier
regex : "[_A-Za-zА-ЯЁа-яё][_A-Za-z0-9А-ЯЁа-яё]*"
},
{
token : "doubleoperator", // ' doubleoperator
regex : "<=|<>|>="
},
{
token : "singleoperator", // ' singleoperator
regex : "[\\+\\-\\*/%&<>=]"
},
{
token : "number", // ' number
regex : "[0-9]*(\.[0-9])+"
},
{
token : "paren.lparen",
regex : "[\\(]"
},
{
token : "paren.rparen",
regex : "[\\)]"
},
{
token : "paren.lsqare",
regex : "[\\[]"
},
{
token : "paren.rsqare",
regex : "[\\]]"
}
]
};
this.normalizeRules();
};

oop.inherits(_1CHighlightRules, TextHighlightRules);

exports._1CHighlightRules = _1CHighlightRules;
});
183 changes: 183 additions & 0 deletions lib/ace/mode/folding/1c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
/* ***** BEGIN LICENSE BLOCK *****
* Distributed under the BSD license:
*
* Copyright (c) 2010, Ajax.org B.V.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of Ajax.org B.V. nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL AJAX.ORG B.V. BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* ***** END LICENSE BLOCK ***** */

define(function(require, exports, module) {
"use strict";

var oop = require("../../lib/oop");
var Range = require("../../range").Range;
var CFoldMode = require("./cstyle").FoldMode;

var FoldMode = exports.FoldMode = function(commentRegex) {
if (commentRegex) {
this.foldingStartMarker = new RegExp(

Check warning on line 40 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L40

Added line #L40 was not covered by tests
this.foldingStartMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.start)
);
this.foldingStopMarker = new RegExp(

Check warning on line 43 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L43

Added line #L43 was not covered by tests
this.foldingStopMarker.source.replace(/\|[^|]*?$/, "|" + commentRegex.end)
);
}
};
oop.inherits(FoldMode, CFoldMode);

(function() {
this.procRe = /^\s*процедура|procedure\s*/i;
this.funcRe = /^\s*функция|function\s*/i;

this.getFoldWidgetRangeBase = this.getFoldWidgetRange;
this.getFoldWidgetBase = this.getFoldWidget;

this.getFoldWidget = function(session, foldStyle, row) {
var fw = this.getFoldWidgetBase(session, foldStyle, row);
if (!fw) {
var line = session.getLine(row);
if (this.procRe.test(line) || this.funcRe.test(line)) {
return "start";

Check warning on line 62 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L58-L62

Added lines #L58 - L62 were not covered by tests
}
}
return fw;

Check warning on line 65 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L65

Added line #L65 was not covered by tests
};

this.getFoldWidgetRange = function(session, foldStyle, row) {
var range = this.getFoldWidgetRangeBase(session, foldStyle, row);
if (range)
return range;

Check warning on line 71 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L69-L71

Added lines #L69 - L71 were not covered by tests

var line = session.getLine(row);
if (this.procRe.test(line))
return this.getProcStatementBlock(session, line, row);
if (this.funcRe.test(line))
return this.getFuncStatementBlock(session, line, row);

Check warning on line 77 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L73-L77

Added lines #L73 - L77 were not covered by tests
};

this.getProcStatementBlock = function(session, line, row) {
var startColumn = line.match(this.procRe)[0].length + 1;
var openBrackets = 0;
var closeBrackets = 0;
var foundStart = false;
var maxRow = session.getLength();
var startRow = row;
var endRow = row;

Check warning on line 87 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L81-L87

Added lines #L81 - L87 were not covered by tests

var cLine = session.getLine(row);
for (var currentPos = startColumn; currentPos < cLine.length; currentPos++ ) {
if (currentPos > 0 && cLine[currentPos-1] === '/' && cLine[currentPos] === '/') {
break; // comment

Check warning on line 92 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L89-L92

Added lines #L89 - L92 were not covered by tests
}
if (cLine[currentPos] === '(') openBrackets++;
else if (cLine[currentPos] === ')') closeBrackets++;
if (openBrackets > 0 && openBrackets == closeBrackets) {
startColumn = cLine.length;
foundStart = true;
break;

Check warning on line 99 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L94-L99

Added lines #L94 - L99 were not covered by tests
}
}
var re = /^\s*конецпроцедуры|endprocedure\s*/i;

Check warning on line 102 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L102

Added line #L102 was not covered by tests

while (++row < maxRow) {
line = session.getLine(row);
if (!foundStart) {
for (var currentPos = 0; currentPos < line.length; currentPos++ ) {
if (currentPos > 0 && line[currentPos-1] === '/' && line[currentPos] === '/') {
break; // comment

Check warning on line 109 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L104-L109

Added lines #L104 - L109 were not covered by tests
}
if (line[currentPos] === '(') openBrackets++;
else if (line[currentPos] === ')') closeBrackets++;
if (openBrackets > 0 && openBrackets == closeBrackets) {
startRow = row;
startColumn = line.length;
foundStart = true;
break;

Check warning on line 117 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L111-L117

Added lines #L111 - L117 were not covered by tests
}
}
}
if (re.test(line))
break;
endRow = row+1;

Check warning on line 123 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L121-L123

Added lines #L121 - L123 were not covered by tests
}
if (endRow > startRow) {
var endColumn = session.getLine(endRow).length;
return new Range(startRow, startColumn, endRow, endColumn);

Check warning on line 127 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L125-L127

Added lines #L125 - L127 were not covered by tests
}
};
this.getFuncStatementBlock = function(session, line, row) {
var startColumn = line.match(this.funcRe)[0].length;
var openBrackets = 0;
var closeBrackets = 0;
var foundStart = false;
var maxRow = session.getLength();
var startRow = row;
var endRow = row;

Check warning on line 137 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L131-L137

Added lines #L131 - L137 were not covered by tests

var cLine = session.getLine(row);
for (var currentPos = startColumn; currentPos < cLine.length; currentPos++ ) {
if (currentPos > 0 && cLine[currentPos-1] === '/' && cLine[currentPos] === '/') {
break; // comment

Check warning on line 142 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L139-L142

Added lines #L139 - L142 were not covered by tests
}
if (cLine[currentPos] === '(') openBrackets++;
else if (cLine[currentPos] === ')') closeBrackets++;
if (openBrackets > 0 && openBrackets == closeBrackets) {
startColumn = cLine.length;
foundStart = true;
break;

Check warning on line 149 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L144-L149

Added lines #L144 - L149 were not covered by tests
}
}
var re = /^\s*конецфункции|endfunction\s*/i;
while (++row < maxRow) {
line = session.getLine(row);

Check warning on line 154 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L152-L154

Added lines #L152 - L154 were not covered by tests

if (!foundStart) {
for (var currentPos = 0; currentPos < line.length; currentPos++ ) {
if (currentPos > 0 && line[currentPos-1] === '/' && line[currentPos] === '/') {
break; // comment

Check warning on line 159 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L156-L159

Added lines #L156 - L159 were not covered by tests
}
if (line[currentPos] === '(') openBrackets++;
else if (line[currentPos] === ')') closeBrackets++;
if (openBrackets > 0 && openBrackets == closeBrackets) {
startRow = row;
startColumn = line.length;
foundStart = true;
break;

Check warning on line 167 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L161-L167

Added lines #L161 - L167 were not covered by tests
}
}
}
if (re.test(line))
break;
endRow = row+1;

Check warning on line 173 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L171-L173

Added lines #L171 - L173 were not covered by tests
}
if (endRow > startRow) {
var endColumn = session.getLine(endRow).length;
return new Range(startRow, startColumn, endRow, endColumn);

Check warning on line 177 in lib/ace/mode/folding/1c.js

View check run for this annotation

Codecov / codecov/patch

lib/ace/mode/folding/1c.js#L175-L177

Added lines #L175 - L177 were not covered by tests
}
};

}).call(FoldMode.prototype);

});
7 changes: 7 additions & 0 deletions lib/ace/snippets/_1c.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
define(function(require, exports, module) {
"use strict";

exports.snippetText = require("../requirejs/text!./_1c.snippets");
exports.scope = "_1c";

});
Empty file added lib/ace/snippets/_1c.snippets
Empty file.