From 6b3389aa511059a44c060f5ee3d18362a4a02f0a Mon Sep 17 00:00:00 2001 From: mkslanc Date: Fri, 31 Mar 2023 17:14:54 +0400 Subject: [PATCH 1/6] improve doc comments highlight rules --- demo/kitchen-sink/docs/javascript.js | 5 ++ src/mode/doc_comment_highlight_rules.js | 89 +++++++++++++++++++++++-- 2 files changed, 90 insertions(+), 4 deletions(-) diff --git a/demo/kitchen-sink/docs/javascript.js b/demo/kitchen-sink/docs/javascript.js index 06ace80982e..ffed1a4c289 100644 --- a/demo/kitchen-sink/docs/javascript.js +++ b/demo/kitchen-sink/docs/javascript.js @@ -1,3 +1,8 @@ +/** + * + * @param {string[]} items + * @param nada + */ function foo(items, nada) { for (var i=0; i Date: Fri, 31 Mar 2023 17:15:46 +0400 Subject: [PATCH 2/6] add doc comment end auto-insertion --- src/mode/_test/tokens_drools.json | 4 ++- src/mode/apex.js | 4 +-- src/mode/asl.js | 29 ++++++++++--------- src/mode/behaviour/behaviour_test.js | 20 +++++++++++++ src/mode/behaviour/doc_comment.js | 43 ++++++++++++++++++++++++++++ src/mode/c_cpp.js | 4 +-- src/mode/csharp.js | 4 +-- src/mode/d.js | 3 +- src/mode/dart.js | 2 ++ src/mode/dot.js | 3 +- src/mode/drools.js | 3 +- src/mode/edifact.js | 2 ++ src/mode/golang.js | 4 +-- src/mode/groovy.js | 2 ++ src/mode/haxe.js | 4 +-- src/mode/javascript.js | 4 +-- src/mode/jsx.js | 4 +-- src/mode/mysql.js | 3 +- src/mode/objectivec.js | 3 +- src/mode/pgsql.js | 3 +- src/mode/php.js | 4 +-- src/mode/redshift.js | 3 +- src/mode/rust.js | 3 +- src/mode/sac.js | 3 +- src/mode/scad.js | 4 +-- src/mode/scrypt.js | 38 ++++++++++++++---------- src/mode/sqlserver.js | 3 +- src/mode/swift.js | 4 +-- 28 files changed, 150 insertions(+), 60 deletions(-) create mode 100644 src/mode/behaviour/doc_comment.js diff --git a/src/mode/_test/tokens_drools.json b/src/mode/_test/tokens_drools.json index 8df67565899..5d08d836af3 100644 --- a/src/mode/_test/tokens_drools.json +++ b/src/mode/_test/tokens_drools.json @@ -208,7 +208,9 @@ "doc-start", ["comment.doc"," * "], ["comment.doc.tag","@param"], - ["comment.doc"," name who we'll salute?"] + ["text"," "], + ["variable.parameter.doc","name"], + ["comment.doc"," who we'll salute?"] ],[ "start", ["comment.doc"," */"] diff --git a/src/mode/apex.js b/src/mode/apex.js index b9217d57276..7846d1e444f 100644 --- a/src/mode/apex.js +++ b/src/mode/apex.js @@ -6,14 +6,14 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var ApexHighlightRules = require("./apex_highlight_rules").ApexHighlightRules; var FoldMode = require("../mode/folding/cstyle").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; function ApexMode() { TextMode.call(this); this.HighlightRules = ApexHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = new DocCommentBehaviour(); } oop.inherits(ApexMode, TextMode); diff --git a/src/mode/asl.js b/src/mode/asl.js index f140643d804..5c8814b0c42 100644 --- a/src/mode/asl.js +++ b/src/mode/asl.js @@ -1,19 +1,20 @@ "use strict"; - var oop = require("../lib/oop"); - var TextMode = require("./text").Mode; - var ASLHighlightRules = require("./asl_highlight_rules").ASLHighlightRules; - var FoldMode = require("./folding/cstyle").FoldMode; +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var ASLHighlightRules = require("./asl_highlight_rules").ASLHighlightRules; +var FoldMode = require("./folding/cstyle").FoldMode; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; - var Mode = function () { - this.HighlightRules = ASLHighlightRules; - this.foldingRules = new FoldMode(); - this.$behaviour = this.$defaultBehaviour; - }; - oop.inherits(Mode, TextMode); +var Mode = function () { + this.HighlightRules = ASLHighlightRules; + this.foldingRules = new FoldMode(); + this.$behaviour = new DocCommentBehaviour(); +}; +oop.inherits(Mode, TextMode); - (function () { - this.$id = "ace/mode/asl"; - }).call(Mode.prototype); +(function () { + this.$id = "ace/mode/asl"; +}).call(Mode.prototype); - exports.Mode = Mode; +exports.Mode = Mode; diff --git a/src/mode/behaviour/behaviour_test.js b/src/mode/behaviour/behaviour_test.js index 64ed9765793..f67a8809e04 100644 --- a/src/mode/behaviour/behaviour_test.js +++ b/src/mode/behaviour/behaviour_test.js @@ -415,6 +415,26 @@ module.exports = { editor.setValue("p", 1); exec("insertstring", 1, '"'); assert.equal(editor.getValue(), 'p"'); + }, + "test: doc comment": function() { + editor.session.setMode(new JavaScriptMode()); + editor.setWrapBehavioursEnabled(true); + + // Test case 1: Starting a new doc comment + editor.setValue("/**", 1); + exec("insertstring", 1, "\n"); + assert.equal(editor.getValue(), "/**\n * \n */"); + + // Test case 2: Continuing an existing doc comment with asterisk on a new line + editor.setValue("/**\n * Test", 1); + editor.gotoLine(1, 5); + exec("insertstring", 1, "\n"); + assert.equal(editor.getValue(), "/**\n * \n * Test"); + + // Test case 3: Starting a new doc comment with 4-space indentation + editor.setValue(" /**", 1); + exec("insertstring", 1, "\n"); + assert.equal(editor.getValue(), " /**\n * \n */"); } }; diff --git a/src/mode/behaviour/doc_comment.js b/src/mode/behaviour/doc_comment.js new file mode 100644 index 00000000000..e6f7b716ece --- /dev/null +++ b/src/mode/behaviour/doc_comment.js @@ -0,0 +1,43 @@ +"use strict"; + +var oop = require("../../lib/oop"); +var CstyleBehaviour = require("./cstyle").CstyleBehaviour; + +var DocCommentBehaviour = function () { + + this.inherit(CstyleBehaviour); + + this.add("doc comment end", "insertion", function (state, action, editor, session, text) { + if (state === "doc-start" && (text === "\n" || text === "\r\n") && editor.selection.isEmpty()) { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var nextLine = session.doc.getLine(cursor.row + 1); + var indent = this.$getIndent(line); + if (/\s*\*/.test(nextLine)) { + if (/^\s*\*/.test(line)) { + return { + text: text + indent + "* ", + selection: [1, 3 + indent.length, 1, 3 + indent.length] + }; + } + else { + return { + text: text + indent + " * ", + selection: [1, 3 + indent.length, 1, 3 + indent.length] + }; + } + + } + if (/\/\*\*/.test(line.substring(0, cursor.column))) { + return { + text: text + indent + " * " + text + " " + indent + "*/", + selection: [1, 4 + indent.length, 1, 4 + indent.length] + }; + } + } + }); + +}; +oop.inherits(DocCommentBehaviour, CstyleBehaviour); + +exports.DocCommentBehaviour = DocCommentBehaviour; diff --git a/src/mode/c_cpp.js b/src/mode/c_cpp.js index 367a8e9feeb..42f449bc28d 100644 --- a/src/mode/c_cpp.js +++ b/src/mode/c_cpp.js @@ -5,14 +5,14 @@ var TextMode = require("./text").Mode; var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Range = require("../range").Range; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = c_cppHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = new DocCommentBehaviour(); this.foldingRules = new CStyleFoldMode(); }; diff --git a/src/mode/csharp.js b/src/mode/csharp.js index 9ff40297380..e0bbc96f48e 100644 --- a/src/mode/csharp.js +++ b/src/mode/csharp.js @@ -4,13 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var CStyleFoldMode = require("./folding/csharp").FoldMode; var Mode = function() { this.HighlightRules = CSharpHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = new DocCommentBehaviour(); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/d.js b/src/mode/d.js index 63bc5b26560..9beda613c1b 100644 --- a/src/mode/d.js +++ b/src/mode/d.js @@ -8,11 +8,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var DHighlightRules = require("./d_highlight_rules").DHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { this.HighlightRules = DHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = this.$defaultBehaviour; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/dart.js b/src/mode/dart.js index c0ed87e3b5c..f0842529585 100644 --- a/src/mode/dart.js +++ b/src/mode/dart.js @@ -8,11 +8,13 @@ var oop = require("../lib/oop"); var CMode = require("./c_cpp").Mode; var DartHighlightRules = require("./dart_highlight_rules").DartHighlightRules; var CStyleFoldMode = require("./folding/cstyle").FoldMode; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { CMode.call(this); this.HighlightRules = DartHighlightRules; this.foldingRules = new CStyleFoldMode(); + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, CMode); diff --git a/src/mode/dot.js b/src/mode/dot.js index 0d554763f96..b4ccd222588 100644 --- a/src/mode/dot.js +++ b/src/mode/dot.js @@ -5,12 +5,13 @@ var TextMode = require("./text").Mode; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var DotHighlightRules = require("./dot_highlight_rules").DotHighlightRules; var DotFoldMode = require("./folding/cstyle").FoldMode; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { this.HighlightRules = DotHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.foldingRules = new DotFoldMode(); - this.$behaviour = this.$defaultBehaviour; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/drools.js b/src/mode/drools.js index 11f7f8887ec..bda93066f17 100644 --- a/src/mode/drools.js +++ b/src/mode/drools.js @@ -4,11 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var DroolsHighlightRules = require("./drools_highlight_rules").DroolsHighlightRules; var DroolsFoldMode = require("./folding/drools").FoldMode; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { this.HighlightRules = DroolsHighlightRules; this.foldingRules = new DroolsFoldMode(); - this.$behaviour = this.$defaultBehaviour; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/edifact.js b/src/mode/edifact.js index c521f970542..1662cacfddd 100644 --- a/src/mode/edifact.js +++ b/src/mode/edifact.js @@ -3,10 +3,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var EdifactHighlightRules = require("./edifact_highlight_rules").EdifactHighlightRules; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { this.HighlightRules = EdifactHighlightRules; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/golang.js b/src/mode/golang.js index ecbe7fb2b4d..3ce5ae8c5ca 100644 --- a/src/mode/golang.js +++ b/src/mode/golang.js @@ -2,14 +2,14 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var GolangHighlightRules = require("./golang_highlight_rules").GolangHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = GolangHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.foldingRules = new CStyleFoldMode(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/groovy.js b/src/mode/groovy.js index acfca8ea74d..708da702ee7 100644 --- a/src/mode/groovy.js +++ b/src/mode/groovy.js @@ -3,10 +3,12 @@ var oop = require("../lib/oop"); var JavaScriptMode = require("./javascript").Mode; var GroovyHighlightRules = require("./groovy_highlight_rules").GroovyHighlightRules; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { JavaScriptMode.call(this); this.HighlightRules = GroovyHighlightRules; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, JavaScriptMode); diff --git a/src/mode/haxe.js b/src/mode/haxe.js index eda1a3fbc0c..f40f40b26af 100644 --- a/src/mode/haxe.js +++ b/src/mode/haxe.js @@ -4,14 +4,14 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var HaxeHighlightRules = require("./haxe_highlight_rules").HaxeHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = HaxeHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = new DocCommentBehaviour(); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/javascript.js b/src/mode/javascript.js index 8f3ba56da7c..0bfe3627c1f 100644 --- a/src/mode/javascript.js +++ b/src/mode/javascript.js @@ -5,14 +5,14 @@ var TextMode = require("./text").Mode; var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var WorkerClient = require("../worker/worker_client").WorkerClient; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var DocCommentBehaviour = require("./behaviour/doc_comment").DocCommentBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = JavaScriptHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = new DocCommentBehaviour(); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/jsx.js b/src/mode/jsx.js index e9360486767..5e5f1cb3d5a 100644 --- a/src/mode/jsx.js +++ b/src/mode/jsx.js @@ -4,13 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var JsxHighlightRules = require("./jsx_highlight_rules").JsxHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; function Mode() { this.HighlightRules = JsxHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = new DocCommentBehaviour(); this.foldingRules = new CStyleFoldMode(); } oop.inherits(Mode, TextMode); diff --git a/src/mode/mysql.js b/src/mode/mysql.js index 6a4d31008cd..2635bd547c2 100644 --- a/src/mode/mysql.js +++ b/src/mode/mysql.js @@ -1,10 +1,11 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var MysqlHighlightRules = require("./mysql_highlight_rules").MysqlHighlightRules; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { this.HighlightRules = MysqlHighlightRules; - this.$behaviour = this.$defaultBehaviour; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/objectivec.js b/src/mode/objectivec.js index d8e55a0796d..1b95e72828e 100644 --- a/src/mode/objectivec.js +++ b/src/mode/objectivec.js @@ -8,11 +8,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var ObjectiveCHighlightRules = require("./objectivec_highlight_rules").ObjectiveCHighlightRules; var CStyleFoldMode = require("./folding/cstyle").FoldMode; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { this.HighlightRules = ObjectiveCHighlightRules; this.foldingRules = new CStyleFoldMode(); - this.$behaviour = this.$defaultBehaviour; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/pgsql.js b/src/mode/pgsql.js index 5a07ca7d609..b19a63e701e 100644 --- a/src/mode/pgsql.js +++ b/src/mode/pgsql.js @@ -1,10 +1,11 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var PgsqlHighlightRules = require("./pgsql_highlight_rules").PgsqlHighlightRules; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { this.HighlightRules = PgsqlHighlightRules; - this.$behaviour = this.$defaultBehaviour; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/php.js b/src/mode/php.js index 8c63316ac56..ab0dd12bcbe 100644 --- a/src/mode/php.js +++ b/src/mode/php.js @@ -8,7 +8,7 @@ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutd var Range = require("../range").Range; var WorkerClient = require("../worker/worker_client").WorkerClient; var PhpCompletions = require("./php_completions").PhpCompletions; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var unicode = require("../unicode"); var HtmlMode = require("./html").Mode; @@ -18,7 +18,7 @@ var CssMode = require("./css").Mode; var PhpMode = function(opts) { this.HighlightRules = PhpLangHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = new DocCommentBehaviour(); this.$completer = new PhpCompletions(); this.foldingRules = new CStyleFoldMode(); }; diff --git a/src/mode/redshift.js b/src/mode/redshift.js index f54ba47715a..77be522f81a 100644 --- a/src/mode/redshift.js +++ b/src/mode/redshift.js @@ -1,10 +1,11 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var RedshiftHighlightRules = require("./redshift_highlight_rules").RedshiftHighlightRules; -var Range = require("../range").Range; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { this.HighlightRules = RedshiftHighlightRules; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/rust.js b/src/mode/rust.js index 4b7b0240fe6..c681a98403e 100644 --- a/src/mode/rust.js +++ b/src/mode/rust.js @@ -8,11 +8,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var RustHighlightRules = require("./rust_highlight_rules").RustHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { this.HighlightRules = RustHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = this.$defaultBehaviour; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/sac.js b/src/mode/sac.js index aa7f3e89f05..6385f448259 100644 --- a/src/mode/sac.js +++ b/src/mode/sac.js @@ -4,11 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var SaCHighlightRules = require("./sac_highlight_rules").sacHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { this.HighlightRules = SaCHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = this.$defaultBehaviour; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/scad.js b/src/mode/scad.js index 35035630e57..ec05481cc78 100644 --- a/src/mode/scad.js +++ b/src/mode/scad.js @@ -4,13 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var scadHighlightRules = require("./scad_highlight_rules").scadHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = scadHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = new DocCommentBehaviour(); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/scrypt.js b/src/mode/scrypt.js index b9527a8c5e3..73d3ff76781 100644 --- a/src/mode/scrypt.js +++ b/src/mode/scrypt.js @@ -2,31 +2,39 @@ THIS FILE WAS AUTOGENERATED BY mode.tmpl.js */ - "use strict"; +"use strict"; - var oop = require("../lib/oop"); - var TextMode = require("./text").Mode; - var scryptHighlightRules = require("./scrypt_highlight_rules").scryptHighlightRules; - var FoldMode = require("./folding/cstyle").FoldMode; +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var scryptHighlightRules = require("./scrypt_highlight_rules").scryptHighlightRules; +var FoldMode = require("./folding/cstyle").FoldMode; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; - var Mode = function () { +var Mode = function () { this.HighlightRules = scryptHighlightRules; this.foldingRules = new FoldMode(); - }; - oop.inherits(Mode, TextMode); + this.$behaviour = new DocCommentBehaviour(); +}; +oop.inherits(Mode, TextMode); - (function () { +(function () { this.lineCommentStart = "//"; - this.blockComment = { start: "/*", end: "*/" }; - this.$quotes = { '"': '"', "'": "'" }; + this.blockComment = { + start: "/*", + end: "*/" + }; + this.$quotes = { + '"': '"', + "'": "'" + }; this.createWorker = function (session) { - - return null; + + return null; }; this.$id = "ace/mode/scrypt"; - }).call(Mode.prototype); +}).call(Mode.prototype); - exports.Mode = Mode; +exports.Mode = Mode; diff --git a/src/mode/sqlserver.js b/src/mode/sqlserver.js index ea9f7bca0db..8ddf20835ee 100644 --- a/src/mode/sqlserver.js +++ b/src/mode/sqlserver.js @@ -4,11 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var SqlServerHighlightRules = require("./sqlserver_highlight_rules").SqlHighlightRules; var SqlServerFoldMode = require("./folding/sqlserver").FoldMode; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; var Mode = function() { this.HighlightRules = SqlServerHighlightRules; this.foldingRules = new SqlServerFoldMode(); - this.$behaviour = this.$defaultBehaviour; + this.$behaviour = new DocCommentBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/swift.js b/src/mode/swift.js index de35d0a4ede..70775f9c3ec 100644 --- a/src/mode/swift.js +++ b/src/mode/swift.js @@ -7,14 +7,14 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var HighlightRules = require("./swift_highlight_rules").HighlightRules; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; +var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; // TODO: pick appropriate fold mode var FoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = HighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = new DocCommentBehaviour(); this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); From 22ef43c3a824dd61825c2b55e488ae14fc74860a Mon Sep 17 00:00:00 2001 From: mkslanc Date: Fri, 31 Mar 2023 17:21:35 +0400 Subject: [PATCH 3/6] fix trailing commas --- src/mode/doc_comment_highlight_rules.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/mode/doc_comment_highlight_rules.js b/src/mode/doc_comment_highlight_rules.js index 7fe0428a709..9eb4bdbfe7f 100644 --- a/src/mode/doc_comment_highlight_rules.js +++ b/src/mode/doc_comment_highlight_rules.js @@ -68,19 +68,19 @@ var DocCommentHighlightRules = function() { regex: "(@(?:alias|memberof|instance|module|name|lends|namespace|external|this|template|" + "requires|param|implements|function|extends|typedef|mixes|constructor|var|" + "memberof\\!|event|listens|exports|class|constructs|interface|emits|fires|" - + "throws|const|callback|borrows|augments))(\\s+)(\\w[\\w#\.:\/~\"\\-]*)?", + + "throws|const|callback|borrows|augments))(\\s+)(\\w[\\w#\.:\/~\"\\-]*)?" }, { token: ["comment.doc.tag", "text", "variable.parameter.doc"], - regex: "(@method)(\\s+)(\\w[\\w\.\\(\\)]*)", + regex: "(@method)(\\s+)(\\w[\\w\.\\(\\)]*)" }, { token: "comment.doc.tag", - regex: "@access\\s+(?:private|public|protected)", + regex: "@access\\s+(?:private|public|protected)" }, { token: "comment.doc.tag", - regex: "@kind\\s+(?:class|constant|event|external|file|function|member|mixin|module|namespace|typedef)", + regex: "@kind\\s+(?:class|constant|event|external|file|function|member|mixin|module|namespace|typedef)" }, { token: "comment.doc.tag", - regex: "@\\w+(?=\\s|$)", + regex: "@\\w+(?=\\s|$)" }, DocCommentHighlightRules.getTagRule(), { From 11fa1a0e8700ee3b836b9b9424e0b6b174535bfb Mon Sep 17 00:00:00 2001 From: mkslanc Date: Tue, 4 Apr 2023 14:16:26 +0400 Subject: [PATCH 4/6] make documentation comments behaviour part of cstyle; add option for auto-closing doc comments --- src/mode/apex.js | 4 +-- src/mode/asl.js | 4 +-- src/mode/behaviour/behaviour_test.js | 2 +- src/mode/behaviour/cstyle.js | 32 +++++++++++++++++++++ src/mode/behaviour/doc_comment.js | 43 ---------------------------- src/mode/c_cpp.js | 4 +-- src/mode/csharp.js | 4 +-- src/mode/d.js | 4 +-- src/mode/dart.js | 4 +-- src/mode/dot.js | 4 +-- src/mode/drools.js | 4 +-- src/mode/edifact.js | 4 +-- src/mode/golang.js | 4 +-- src/mode/groovy.js | 4 +-- src/mode/haxe.js | 4 +-- src/mode/javascript.js | 4 +-- src/mode/jsx.js | 4 +-- src/mode/mysql.js | 4 +-- src/mode/objectivec.js | 4 +-- src/mode/pgsql.js | 4 +-- src/mode/php.js | 4 +-- src/mode/redshift.js | 4 +-- src/mode/rust.js | 4 +-- src/mode/sac.js | 4 +-- src/mode/scad.js | 4 +-- src/mode/scrypt.js | 4 +-- src/mode/sqlserver.js | 4 +-- src/mode/swift.js | 4 +-- 28 files changed, 83 insertions(+), 94 deletions(-) delete mode 100644 src/mode/behaviour/doc_comment.js diff --git a/src/mode/apex.js b/src/mode/apex.js index 7846d1e444f..edbb8b83b83 100644 --- a/src/mode/apex.js +++ b/src/mode/apex.js @@ -6,14 +6,14 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var ApexHighlightRules = require("./apex_highlight_rules").ApexHighlightRules; var FoldMode = require("../mode/folding/cstyle").FoldMode; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; function ApexMode() { TextMode.call(this); this.HighlightRules = ApexHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); } oop.inherits(ApexMode, TextMode); diff --git a/src/mode/asl.js b/src/mode/asl.js index 5c8814b0c42..302407b6928 100644 --- a/src/mode/asl.js +++ b/src/mode/asl.js @@ -4,12 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var ASLHighlightRules = require("./asl_highlight_rules").ASLHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function () { this.HighlightRules = ASLHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/behaviour/behaviour_test.js b/src/mode/behaviour/behaviour_test.js index f67a8809e04..aaff4a60e57 100644 --- a/src/mode/behaviour/behaviour_test.js +++ b/src/mode/behaviour/behaviour_test.js @@ -416,7 +416,7 @@ module.exports = { exec("insertstring", 1, '"'); assert.equal(editor.getValue(), 'p"'); }, - "test: doc comment": function() { + "test: doc comment auto-closing": function() { editor.session.setMode(new JavaScriptMode()); editor.setWrapBehavioursEnabled(true); diff --git a/src/mode/behaviour/cstyle.js b/src/mode/behaviour/cstyle.js index cd107c70b5c..63ccfa9fce3 100644 --- a/src/mode/behaviour/cstyle.js +++ b/src/mode/behaviour/cstyle.js @@ -51,6 +51,7 @@ var getWrapped = function(selection, selected, opening, closing) { * @constructor * @param {Object} [options] - The options for the Cstyle behaviour object. * @param {boolean} [options.braces] - Whether to force braces auto-pairing. + * @param {boolean} [options.closeDocComment] - enables automatic insertion of closing tags for documentation comments. */ var CstyleBehaviour = function(options) { this.add("braces", "insertion", function(state, action, editor, session, text) { @@ -301,7 +302,38 @@ var CstyleBehaviour = function(options) { } } }); + + if (options && options.closeDocComment) { + this.add("doc comment end", "insertion", function (state, action, editor, session, text) { + if (state === "doc-start" && (text === "\n" || text === "\r\n") && editor.selection.isEmpty()) { + var cursor = editor.getCursorPosition(); + var line = session.doc.getLine(cursor.row); + var nextLine = session.doc.getLine(cursor.row + 1); + var indent = this.$getIndent(line); + if (/\s*\*/.test(nextLine)) { + if (/^\s*\*/.test(line)) { + return { + text: text + indent + "* ", + selection: [1, 3 + indent.length, 1, 3 + indent.length] + }; + } + else { + return { + text: text + indent + " * ", + selection: [1, 3 + indent.length, 1, 3 + indent.length] + }; + } + } + if (/\/\*\*/.test(line.substring(0, cursor.column))) { + return { + text: text + indent + " * " + text + " " + indent + "*/", + selection: [1, 4 + indent.length, 1, 4 + indent.length] + }; + } + } + }); + } }; diff --git a/src/mode/behaviour/doc_comment.js b/src/mode/behaviour/doc_comment.js deleted file mode 100644 index e6f7b716ece..00000000000 --- a/src/mode/behaviour/doc_comment.js +++ /dev/null @@ -1,43 +0,0 @@ -"use strict"; - -var oop = require("../../lib/oop"); -var CstyleBehaviour = require("./cstyle").CstyleBehaviour; - -var DocCommentBehaviour = function () { - - this.inherit(CstyleBehaviour); - - this.add("doc comment end", "insertion", function (state, action, editor, session, text) { - if (state === "doc-start" && (text === "\n" || text === "\r\n") && editor.selection.isEmpty()) { - var cursor = editor.getCursorPosition(); - var line = session.doc.getLine(cursor.row); - var nextLine = session.doc.getLine(cursor.row + 1); - var indent = this.$getIndent(line); - if (/\s*\*/.test(nextLine)) { - if (/^\s*\*/.test(line)) { - return { - text: text + indent + "* ", - selection: [1, 3 + indent.length, 1, 3 + indent.length] - }; - } - else { - return { - text: text + indent + " * ", - selection: [1, 3 + indent.length, 1, 3 + indent.length] - }; - } - - } - if (/\/\*\*/.test(line.substring(0, cursor.column))) { - return { - text: text + indent + " * " + text + " " + indent + "*/", - selection: [1, 4 + indent.length, 1, 4 + indent.length] - }; - } - } - }); - -}; -oop.inherits(DocCommentBehaviour, CstyleBehaviour); - -exports.DocCommentBehaviour = DocCommentBehaviour; diff --git a/src/mode/c_cpp.js b/src/mode/c_cpp.js index 42f449bc28d..a2322e1c30a 100644 --- a/src/mode/c_cpp.js +++ b/src/mode/c_cpp.js @@ -5,14 +5,14 @@ var TextMode = require("./text").Mode; var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Range = require("../range").Range; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = c_cppHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); this.foldingRules = new CStyleFoldMode(); }; diff --git a/src/mode/csharp.js b/src/mode/csharp.js index e0bbc96f48e..d519b92dc77 100644 --- a/src/mode/csharp.js +++ b/src/mode/csharp.js @@ -4,13 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/csharp").FoldMode; var Mode = function() { this.HighlightRules = CSharpHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/d.js b/src/mode/d.js index 9beda613c1b..9c209264d42 100644 --- a/src/mode/d.js +++ b/src/mode/d.js @@ -8,12 +8,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var DHighlightRules = require("./d_highlight_rules").DHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = DHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/dart.js b/src/mode/dart.js index f0842529585..d716dac3dad 100644 --- a/src/mode/dart.js +++ b/src/mode/dart.js @@ -8,13 +8,13 @@ var oop = require("../lib/oop"); var CMode = require("./c_cpp").Mode; var DartHighlightRules = require("./dart_highlight_rules").DartHighlightRules; var CStyleFoldMode = require("./folding/cstyle").FoldMode; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { CMode.call(this); this.HighlightRules = DartHighlightRules; this.foldingRules = new CStyleFoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, CMode); diff --git a/src/mode/dot.js b/src/mode/dot.js index b4ccd222588..16e45b7035c 100644 --- a/src/mode/dot.js +++ b/src/mode/dot.js @@ -5,13 +5,13 @@ var TextMode = require("./text").Mode; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var DotHighlightRules = require("./dot_highlight_rules").DotHighlightRules; var DotFoldMode = require("./folding/cstyle").FoldMode; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = DotHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.foldingRules = new DotFoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/drools.js b/src/mode/drools.js index bda93066f17..727eeeeff0e 100644 --- a/src/mode/drools.js +++ b/src/mode/drools.js @@ -4,12 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var DroolsHighlightRules = require("./drools_highlight_rules").DroolsHighlightRules; var DroolsFoldMode = require("./folding/drools").FoldMode; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = DroolsHighlightRules; this.foldingRules = new DroolsFoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/edifact.js b/src/mode/edifact.js index 1662cacfddd..c57a62ca16e 100644 --- a/src/mode/edifact.js +++ b/src/mode/edifact.js @@ -3,12 +3,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var EdifactHighlightRules = require("./edifact_highlight_rules").EdifactHighlightRules; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = EdifactHighlightRules; - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/golang.js b/src/mode/golang.js index 3ce5ae8c5ca..175c935d80f 100644 --- a/src/mode/golang.js +++ b/src/mode/golang.js @@ -2,14 +2,14 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var GolangHighlightRules = require("./golang_highlight_rules").GolangHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = GolangHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.foldingRules = new CStyleFoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/groovy.js b/src/mode/groovy.js index 708da702ee7..674eaf9f3ad 100644 --- a/src/mode/groovy.js +++ b/src/mode/groovy.js @@ -3,12 +3,12 @@ var oop = require("../lib/oop"); var JavaScriptMode = require("./javascript").Mode; var GroovyHighlightRules = require("./groovy_highlight_rules").GroovyHighlightRules; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { JavaScriptMode.call(this); this.HighlightRules = GroovyHighlightRules; - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, JavaScriptMode); diff --git a/src/mode/haxe.js b/src/mode/haxe.js index f40f40b26af..8b554c7c415 100644 --- a/src/mode/haxe.js +++ b/src/mode/haxe.js @@ -4,14 +4,14 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var HaxeHighlightRules = require("./haxe_highlight_rules").HaxeHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = HaxeHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/javascript.js b/src/mode/javascript.js index 0bfe3627c1f..b3e7c02c793 100644 --- a/src/mode/javascript.js +++ b/src/mode/javascript.js @@ -5,14 +5,14 @@ var TextMode = require("./text").Mode; var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var WorkerClient = require("../worker/worker_client").WorkerClient; -var DocCommentBehaviour = require("./behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = JavaScriptHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/jsx.js b/src/mode/jsx.js index 5e5f1cb3d5a..ac4650e5dae 100644 --- a/src/mode/jsx.js +++ b/src/mode/jsx.js @@ -4,13 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var JsxHighlightRules = require("./jsx_highlight_rules").JsxHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; function Mode() { this.HighlightRules = JsxHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); this.foldingRules = new CStyleFoldMode(); } oop.inherits(Mode, TextMode); diff --git a/src/mode/mysql.js b/src/mode/mysql.js index 2635bd547c2..23b2f71b6c8 100644 --- a/src/mode/mysql.js +++ b/src/mode/mysql.js @@ -1,11 +1,11 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var MysqlHighlightRules = require("./mysql_highlight_rules").MysqlHighlightRules; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = MysqlHighlightRules; - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/objectivec.js b/src/mode/objectivec.js index 1b95e72828e..d95c467f544 100644 --- a/src/mode/objectivec.js +++ b/src/mode/objectivec.js @@ -8,12 +8,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var ObjectiveCHighlightRules = require("./objectivec_highlight_rules").ObjectiveCHighlightRules; var CStyleFoldMode = require("./folding/cstyle").FoldMode; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = ObjectiveCHighlightRules; this.foldingRules = new CStyleFoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/pgsql.js b/src/mode/pgsql.js index b19a63e701e..939791679ee 100644 --- a/src/mode/pgsql.js +++ b/src/mode/pgsql.js @@ -1,11 +1,11 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var PgsqlHighlightRules = require("./pgsql_highlight_rules").PgsqlHighlightRules; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = PgsqlHighlightRules; - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/php.js b/src/mode/php.js index ab0dd12bcbe..20dc86d3cd3 100644 --- a/src/mode/php.js +++ b/src/mode/php.js @@ -8,7 +8,7 @@ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutd var Range = require("../range").Range; var WorkerClient = require("../worker/worker_client").WorkerClient; var PhpCompletions = require("./php_completions").PhpCompletions; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var unicode = require("../unicode"); var HtmlMode = require("./html").Mode; @@ -18,7 +18,7 @@ var CssMode = require("./css").Mode; var PhpMode = function(opts) { this.HighlightRules = PhpLangHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); this.$completer = new PhpCompletions(); this.foldingRules = new CStyleFoldMode(); }; diff --git a/src/mode/redshift.js b/src/mode/redshift.js index 77be522f81a..13caa6b6be2 100644 --- a/src/mode/redshift.js +++ b/src/mode/redshift.js @@ -1,11 +1,11 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var RedshiftHighlightRules = require("./redshift_highlight_rules").RedshiftHighlightRules; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = RedshiftHighlightRules; - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/rust.js b/src/mode/rust.js index c681a98403e..fe26ee1817b 100644 --- a/src/mode/rust.js +++ b/src/mode/rust.js @@ -8,12 +8,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var RustHighlightRules = require("./rust_highlight_rules").RustHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = RustHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/sac.js b/src/mode/sac.js index 6385f448259..0f6581d2772 100644 --- a/src/mode/sac.js +++ b/src/mode/sac.js @@ -4,12 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var SaCHighlightRules = require("./sac_highlight_rules").sacHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = SaCHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/scad.js b/src/mode/scad.js index ec05481cc78..8b079733092 100644 --- a/src/mode/scad.js +++ b/src/mode/scad.js @@ -4,13 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var scadHighlightRules = require("./scad_highlight_rules").scadHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = scadHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/scrypt.js b/src/mode/scrypt.js index 73d3ff76781..38012069f00 100644 --- a/src/mode/scrypt.js +++ b/src/mode/scrypt.js @@ -8,12 +8,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var scryptHighlightRules = require("./scrypt_highlight_rules").scryptHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function () { this.HighlightRules = scryptHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/sqlserver.js b/src/mode/sqlserver.js index 8ddf20835ee..a627eb3c866 100644 --- a/src/mode/sqlserver.js +++ b/src/mode/sqlserver.js @@ -4,12 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var SqlServerHighlightRules = require("./sqlserver_highlight_rules").SqlHighlightRules; var SqlServerFoldMode = require("./folding/sqlserver").FoldMode; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = SqlServerHighlightRules; this.foldingRules = new SqlServerFoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/swift.js b/src/mode/swift.js index 70775f9c3ec..186a60ad486 100644 --- a/src/mode/swift.js +++ b/src/mode/swift.js @@ -7,14 +7,14 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var HighlightRules = require("./swift_highlight_rules").HighlightRules; -var DocCommentBehaviour = require("../mode/behaviour/doc_comment").DocCommentBehaviour; +var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; // TODO: pick appropriate fold mode var FoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = HighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new DocCommentBehaviour(); + this.$behaviour = new CstyleBehaviour({closeDocComment: true}); this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); From 280bd19e4b0ed247424a504af9d3a67e58d56013 Mon Sep 17 00:00:00 2001 From: mkslanc Date: Wed, 3 May 2023 16:19:55 +0400 Subject: [PATCH 5/6] make auto `closeDocComment` default; separate jsdoc comments from other document comments --- src/mode/_test/tokens_drools.json | 4 +- src/mode/apex.js | 2 +- src/mode/asl.js | 3 +- src/mode/behaviour/cstyle.js | 5 +- src/mode/c_cpp.js | 4 +- src/mode/csharp.js | 4 +- src/mode/d.js | 3 +- src/mode/dart.js | 3 +- src/mode/doc_comment_highlight_rules.js | 93 +--------------- src/mode/dot.js | 3 +- src/mode/drools.js | 3 +- src/mode/edifact.js | 2 +- src/mode/golang.js | 4 +- src/mode/groovy.js | 2 +- src/mode/haxe.js | 4 +- src/mode/javascript.js | 4 +- src/mode/javascript_highlight_rules.js | 2 +- src/mode/jsdoc_comment_highlight_rules.js | 127 ++++++++++++++++++++++ src/mode/jsx.js | 4 +- src/mode/mysql.js | 3 +- src/mode/objectivec.js | 3 +- src/mode/pgsql.js | 3 +- src/mode/php.js | 4 +- src/mode/redshift.js | 2 +- src/mode/rust.js | 3 +- src/mode/sac.js | 3 +- src/mode/scad.js | 4 +- src/mode/scrypt.js | 2 +- src/mode/sqlserver.js | 3 +- src/mode/swift.js | 4 +- 30 files changed, 172 insertions(+), 138 deletions(-) create mode 100644 src/mode/jsdoc_comment_highlight_rules.js diff --git a/src/mode/_test/tokens_drools.json b/src/mode/_test/tokens_drools.json index 5d08d836af3..8df67565899 100644 --- a/src/mode/_test/tokens_drools.json +++ b/src/mode/_test/tokens_drools.json @@ -208,9 +208,7 @@ "doc-start", ["comment.doc"," * "], ["comment.doc.tag","@param"], - ["text"," "], - ["variable.parameter.doc","name"], - ["comment.doc"," who we'll salute?"] + ["comment.doc"," name who we'll salute?"] ],[ "start", ["comment.doc"," */"] diff --git a/src/mode/apex.js b/src/mode/apex.js index edbb8b83b83..b9217d57276 100644 --- a/src/mode/apex.js +++ b/src/mode/apex.js @@ -13,7 +13,7 @@ function ApexMode() { this.HighlightRules = ApexHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); } oop.inherits(ApexMode, TextMode); diff --git a/src/mode/asl.js b/src/mode/asl.js index 302407b6928..2ba730d987f 100644 --- a/src/mode/asl.js +++ b/src/mode/asl.js @@ -4,12 +4,11 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var ASLHighlightRules = require("./asl_highlight_rules").ASLHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function () { this.HighlightRules = ASLHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/behaviour/cstyle.js b/src/mode/behaviour/cstyle.js index 63ccfa9fce3..ab6c9534968 100644 --- a/src/mode/behaviour/cstyle.js +++ b/src/mode/behaviour/cstyle.js @@ -54,6 +54,7 @@ var getWrapped = function(selection, selected, opening, closing) { * @param {boolean} [options.closeDocComment] - enables automatic insertion of closing tags for documentation comments. */ var CstyleBehaviour = function(options) { + options = options || {}; this.add("braces", "insertion", function(state, action, editor, session, text) { var cursor = editor.getCursorPosition(); var line = session.doc.getLine(cursor.row); @@ -64,7 +65,7 @@ var CstyleBehaviour = function(options) { if (selected !== "" && selected !== "{" && editor.getWrapBehavioursEnabled()) { return getWrapped(selection, selected, '{', '}'); } else if (CstyleBehaviour.isSaneInsertion(editor, session)) { - if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode || options && options.braces) { + if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode || options.braces) { CstyleBehaviour.recordAutoInsert(editor, session, "}"); return { text: '{}', @@ -303,7 +304,7 @@ var CstyleBehaviour = function(options) { } }); - if (options && options.closeDocComment) { + if (options.closeDocComment !== false) { this.add("doc comment end", "insertion", function (state, action, editor, session, text) { if (state === "doc-start" && (text === "\n" || text === "\r\n") && editor.selection.isEmpty()) { var cursor = editor.getCursorPosition(); diff --git a/src/mode/c_cpp.js b/src/mode/c_cpp.js index a2322e1c30a..367a8e9feeb 100644 --- a/src/mode/c_cpp.js +++ b/src/mode/c_cpp.js @@ -5,14 +5,14 @@ var TextMode = require("./text").Mode; var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Range = require("../range").Range; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = c_cppHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); this.foldingRules = new CStyleFoldMode(); }; diff --git a/src/mode/csharp.js b/src/mode/csharp.js index d519b92dc77..9ff40297380 100644 --- a/src/mode/csharp.js +++ b/src/mode/csharp.js @@ -4,13 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/csharp").FoldMode; var Mode = function() { this.HighlightRules = CSharpHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/d.js b/src/mode/d.js index 9c209264d42..63bc5b26560 100644 --- a/src/mode/d.js +++ b/src/mode/d.js @@ -8,12 +8,11 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var DHighlightRules = require("./d_highlight_rules").DHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = DHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/dart.js b/src/mode/dart.js index d716dac3dad..695c20a8433 100644 --- a/src/mode/dart.js +++ b/src/mode/dart.js @@ -8,13 +8,12 @@ var oop = require("../lib/oop"); var CMode = require("./c_cpp").Mode; var DartHighlightRules = require("./dart_highlight_rules").DartHighlightRules; var CStyleFoldMode = require("./folding/cstyle").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { CMode.call(this); this.HighlightRules = DartHighlightRules; this.foldingRules = new CStyleFoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, CMode); diff --git a/src/mode/doc_comment_highlight_rules.js b/src/mode/doc_comment_highlight_rules.js index 9eb4bdbfe7f..b0f3ca353b3 100644 --- a/src/mode/doc_comment_highlight_rules.js +++ b/src/mode/doc_comment_highlight_rules.js @@ -3,99 +3,18 @@ var oop = require("../lib/oop"); var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; -var DocCommentHighlightRules = function() { +var DocCommentHighlightRules = function () { this.$rules = { "start": [ { - token: ["comment.doc.tag", "text", "lparen.doc"], - regex: "(@(?:param|member|typedef|property|namespace|var|const|callback))(\\s*)({)", - push: [ - { - token: "lparen.doc", - regex: "{", - push: [ - { - include: "doc-syntax" - }, { - token: "rparen.doc", - regex: "}|(?=$)", - next: "pop" - } - ] - }, { - token: ["rparen.doc", "text", "variable.parameter.doc", "lparen.doc", "variable.parameter.doc", "rparen.doc"], - regex: /(})(\s*)(?:([\w=:\/\.]+)|(?:(\[)([\w=:\/\.]+)(\])))/, - next: "pop" - }, { - token: "rparen.doc", - regex: "}|(?=$)", - next: "pop" - }, { - include: "doc-syntax" - }, { - defaultToken: "text" - } - ] - }, { - token: ["comment.doc.tag", "text", "lparen.doc"], - regex: "(@(?:returns?|yields|type|this|suppress|public|protected|private|package|modifies|" - + "implements|external|exception|throws|enum|define|extends))(\\s*)({)", - push: [ - { - token: "lparen.doc", - regex: "{", - push: [ - { - include: "doc-syntax" - }, { - token: "rparen.doc", - regex: "}|(?=$)", - next: "pop" - } - ] - }, { - token: "rparen.doc", - regex: "}|(?=$)", - next: "pop" - }, { - include: "doc-syntax" - }, { - defaultToken: "text" - } - ] - }, { - token: ["comment.doc.tag", "text", "variable.parameter.doc"], - regex: "(@(?:alias|memberof|instance|module|name|lends|namespace|external|this|template|" - + "requires|param|implements|function|extends|typedef|mixes|constructor|var|" - + "memberof\\!|event|listens|exports|class|constructs|interface|emits|fires|" - + "throws|const|callback|borrows|augments))(\\s+)(\\w[\\w#\.:\/~\"\\-]*)?" - }, { - token: ["comment.doc.tag", "text", "variable.parameter.doc"], - regex: "(@method)(\\s+)(\\w[\\w\.\\(\\)]*)" - }, { - token: "comment.doc.tag", - regex: "@access\\s+(?:private|public|protected)" - }, { - token: "comment.doc.tag", - regex: "@kind\\s+(?:class|constant|event|external|file|function|member|mixin|module|namespace|typedef)" - }, { token: "comment.doc.tag", regex: "@\\w+(?=\\s|$)" - }, - DocCommentHighlightRules.getTagRule(), - { - defaultToken : "comment.doc", - caseInsensitive: true - }], - "doc-syntax": [{ - token: "operator.doc", - regex: /[|:]/ - }, { - token: "paren.doc", - regex: /[\[\]]/ - }] + }, DocCommentHighlightRules.getTagRule(), { + defaultToken: "comment.doc", + caseInsensitive: true + } + ] }; - this.normalizeRules(); }; oop.inherits(DocCommentHighlightRules, TextHighlightRules); diff --git a/src/mode/dot.js b/src/mode/dot.js index 16e45b7035c..0d554763f96 100644 --- a/src/mode/dot.js +++ b/src/mode/dot.js @@ -5,13 +5,12 @@ var TextMode = require("./text").Mode; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var DotHighlightRules = require("./dot_highlight_rules").DotHighlightRules; var DotFoldMode = require("./folding/cstyle").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = DotHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.foldingRules = new DotFoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/drools.js b/src/mode/drools.js index 727eeeeff0e..11f7f8887ec 100644 --- a/src/mode/drools.js +++ b/src/mode/drools.js @@ -4,12 +4,11 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var DroolsHighlightRules = require("./drools_highlight_rules").DroolsHighlightRules; var DroolsFoldMode = require("./folding/drools").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = DroolsHighlightRules; this.foldingRules = new DroolsFoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/edifact.js b/src/mode/edifact.js index c57a62ca16e..b5bd2fe9692 100644 --- a/src/mode/edifact.js +++ b/src/mode/edifact.js @@ -8,7 +8,7 @@ var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = EdifactHighlightRules; - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/golang.js b/src/mode/golang.js index 175c935d80f..ecbe7fb2b4d 100644 --- a/src/mode/golang.js +++ b/src/mode/golang.js @@ -2,14 +2,14 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var GolangHighlightRules = require("./golang_highlight_rules").GolangHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = GolangHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.foldingRules = new CStyleFoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/groovy.js b/src/mode/groovy.js index 674eaf9f3ad..24755a3a232 100644 --- a/src/mode/groovy.js +++ b/src/mode/groovy.js @@ -8,7 +8,7 @@ var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { JavaScriptMode.call(this); this.HighlightRules = GroovyHighlightRules; - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); }; oop.inherits(Mode, JavaScriptMode); diff --git a/src/mode/haxe.js b/src/mode/haxe.js index 8b554c7c415..eda1a3fbc0c 100644 --- a/src/mode/haxe.js +++ b/src/mode/haxe.js @@ -4,14 +4,14 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var HaxeHighlightRules = require("./haxe_highlight_rules").HaxeHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = HaxeHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/javascript.js b/src/mode/javascript.js index b3e7c02c793..8f3ba56da7c 100644 --- a/src/mode/javascript.js +++ b/src/mode/javascript.js @@ -5,14 +5,14 @@ var TextMode = require("./text").Mode; var JavaScriptHighlightRules = require("./javascript_highlight_rules").JavaScriptHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var WorkerClient = require("../worker/worker_client").WorkerClient; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = JavaScriptHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/javascript_highlight_rules.js b/src/mode/javascript_highlight_rules.js index 729a8b545cd..39613ba839c 100644 --- a/src/mode/javascript_highlight_rules.js +++ b/src/mode/javascript_highlight_rules.js @@ -1,7 +1,7 @@ "use strict"; var oop = require("../lib/oop"); -var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules; +var DocCommentHighlightRules = require("./jsdoc_comment_highlight_rules").JsDocCommentHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; // TODO: Unicode escape sequences diff --git a/src/mode/jsdoc_comment_highlight_rules.js b/src/mode/jsdoc_comment_highlight_rules.js new file mode 100644 index 00000000000..65f6ee00be9 --- /dev/null +++ b/src/mode/jsdoc_comment_highlight_rules.js @@ -0,0 +1,127 @@ +"use strict"; + +var oop = require("../lib/oop"); +var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; + +var JsDocCommentHighlightRules = function() { + this.$rules = { + "start": [ + { + token: ["comment.doc.tag", "text", "lparen.doc"], + regex: "(@(?:param|member|typedef|property|namespace|var|const|callback))(\\s*)({)", + push: [ + { + token: "lparen.doc", + regex: "{", + push: [ + { + include: "doc-syntax" + }, { + token: "rparen.doc", + regex: "}|(?=$)", + next: "pop" + } + ] + }, { + token: ["rparen.doc", "text", "variable.parameter.doc", "lparen.doc", "variable.parameter.doc", "rparen.doc"], + regex: /(})(\s*)(?:([\w=:\/\.]+)|(?:(\[)([\w=:\/\.]+)(\])))/, + next: "pop" + }, { + token: "rparen.doc", + regex: "}|(?=$)", + next: "pop" + }, { + include: "doc-syntax" + }, { + defaultToken: "text" + } + ] + }, { + token: ["comment.doc.tag", "text", "lparen.doc"], + regex: "(@(?:returns?|yields|type|this|suppress|public|protected|private|package|modifies|" + + "implements|external|exception|throws|enum|define|extends))(\\s*)({)", + push: [ + { + token: "lparen.doc", + regex: "{", + push: [ + { + include: "doc-syntax" + }, { + token: "rparen.doc", + regex: "}|(?=$)", + next: "pop" + } + ] + }, { + token: "rparen.doc", + regex: "}|(?=$)", + next: "pop" + }, { + include: "doc-syntax" + }, { + defaultToken: "text" + } + ] + }, { + token: ["comment.doc.tag", "text", "variable.parameter.doc"], + regex: "(@(?:alias|memberof|instance|module|name|lends|namespace|external|this|template|" + + "requires|param|implements|function|extends|typedef|mixes|constructor|var|" + + "memberof\\!|event|listens|exports|class|constructs|interface|emits|fires|" + + "throws|const|callback|borrows|augments))(\\s+)(\\w[\\w#\.:\/~\"\\-]*)?" + }, { + token: ["comment.doc.tag", "text", "variable.parameter.doc"], + regex: "(@method)(\\s+)(\\w[\\w\.\\(\\)]*)" + }, { + token: "comment.doc.tag", + regex: "@access\\s+(?:private|public|protected)" + }, { + token: "comment.doc.tag", + regex: "@kind\\s+(?:class|constant|event|external|file|function|member|mixin|module|namespace|typedef)" + }, { + token: "comment.doc.tag", + regex: "@\\w+(?=\\s|$)" + }, + JsDocCommentHighlightRules.getTagRule(), + { + defaultToken : "comment.doc", + caseInsensitive: true + }], + "doc-syntax": [{ + token: "operator.doc", + regex: /[|:]/ + }, { + token: "paren.doc", + regex: /[\[\]]/ + }] + }; + this.normalizeRules(); +}; + +oop.inherits(JsDocCommentHighlightRules, TextHighlightRules); + +JsDocCommentHighlightRules.getTagRule = function(start) { + return { + token : "comment.doc.tag.storage.type", + regex : "\\b(?:TODO|FIXME|XXX|HACK)\\b" + }; +}; + +JsDocCommentHighlightRules.getStartRule = function(start) { + return { + token : "comment.doc", // doc comment + regex : "\\/\\*(?=\\*)", + next : start + }; +}; + +JsDocCommentHighlightRules.getEndRule = function (start) { + return { + token : "comment.doc", // closing comment + regex : "\\*\\/", + next : start + }; +}; + + +exports.JsDocCommentHighlightRules = JsDocCommentHighlightRules; diff --git a/src/mode/jsx.js b/src/mode/jsx.js index ac4650e5dae..e9360486767 100644 --- a/src/mode/jsx.js +++ b/src/mode/jsx.js @@ -4,13 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var JsxHighlightRules = require("./jsx_highlight_rules").JsxHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; function Mode() { this.HighlightRules = JsxHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); this.foldingRules = new CStyleFoldMode(); } oop.inherits(Mode, TextMode); diff --git a/src/mode/mysql.js b/src/mode/mysql.js index 23b2f71b6c8..6a4d31008cd 100644 --- a/src/mode/mysql.js +++ b/src/mode/mysql.js @@ -1,11 +1,10 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var MysqlHighlightRules = require("./mysql_highlight_rules").MysqlHighlightRules; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = MysqlHighlightRules; - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/objectivec.js b/src/mode/objectivec.js index d95c467f544..d8e55a0796d 100644 --- a/src/mode/objectivec.js +++ b/src/mode/objectivec.js @@ -8,12 +8,11 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var ObjectiveCHighlightRules = require("./objectivec_highlight_rules").ObjectiveCHighlightRules; var CStyleFoldMode = require("./folding/cstyle").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = ObjectiveCHighlightRules; this.foldingRules = new CStyleFoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/pgsql.js b/src/mode/pgsql.js index 939791679ee..5a07ca7d609 100644 --- a/src/mode/pgsql.js +++ b/src/mode/pgsql.js @@ -1,11 +1,10 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var PgsqlHighlightRules = require("./pgsql_highlight_rules").PgsqlHighlightRules; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = PgsqlHighlightRules; - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/php.js b/src/mode/php.js index 20dc86d3cd3..8c63316ac56 100644 --- a/src/mode/php.js +++ b/src/mode/php.js @@ -8,7 +8,7 @@ var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutd var Range = require("../range").Range; var WorkerClient = require("../worker/worker_client").WorkerClient; var PhpCompletions = require("./php_completions").PhpCompletions; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var unicode = require("../unicode"); var HtmlMode = require("./html").Mode; @@ -18,7 +18,7 @@ var CssMode = require("./css").Mode; var PhpMode = function(opts) { this.HighlightRules = PhpLangHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); this.$completer = new PhpCompletions(); this.foldingRules = new CStyleFoldMode(); }; diff --git a/src/mode/redshift.js b/src/mode/redshift.js index 13caa6b6be2..b7c48770318 100644 --- a/src/mode/redshift.js +++ b/src/mode/redshift.js @@ -5,7 +5,7 @@ var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = RedshiftHighlightRules; - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/rust.js b/src/mode/rust.js index fe26ee1817b..4b7b0240fe6 100644 --- a/src/mode/rust.js +++ b/src/mode/rust.js @@ -8,12 +8,11 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var RustHighlightRules = require("./rust_highlight_rules").RustHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = RustHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/sac.js b/src/mode/sac.js index 0f6581d2772..aa7f3e89f05 100644 --- a/src/mode/sac.js +++ b/src/mode/sac.js @@ -4,12 +4,11 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var SaCHighlightRules = require("./sac_highlight_rules").sacHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = SaCHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/scad.js b/src/mode/scad.js index 8b079733092..35035630e57 100644 --- a/src/mode/scad.js +++ b/src/mode/scad.js @@ -4,13 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var scadHighlightRules = require("./scad_highlight_rules").scadHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = scadHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/scrypt.js b/src/mode/scrypt.js index 38012069f00..378968bb2e4 100644 --- a/src/mode/scrypt.js +++ b/src/mode/scrypt.js @@ -13,7 +13,7 @@ var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function () { this.HighlightRules = scryptHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/sqlserver.js b/src/mode/sqlserver.js index a627eb3c866..ea9f7bca0db 100644 --- a/src/mode/sqlserver.js +++ b/src/mode/sqlserver.js @@ -4,12 +4,11 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var SqlServerHighlightRules = require("./sqlserver_highlight_rules").SqlHighlightRules; var SqlServerFoldMode = require("./folding/sqlserver").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = SqlServerHighlightRules; this.foldingRules = new SqlServerFoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/swift.js b/src/mode/swift.js index 186a60ad486..de35d0a4ede 100644 --- a/src/mode/swift.js +++ b/src/mode/swift.js @@ -7,14 +7,14 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var HighlightRules = require("./swift_highlight_rules").HighlightRules; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; +var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; // TODO: pick appropriate fold mode var FoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = HighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour({closeDocComment: true}); + this.$behaviour = new CstyleBehaviour(); this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); From 536939d5bf08d47d6815e94d46ca53129ba5e4a4 Mon Sep 17 00:00:00 2001 From: mkslanc Date: Thu, 4 May 2023 17:16:10 +0400 Subject: [PATCH 6/6] remove unused imports --- src/mode/apex.js | 3 +- src/mode/c_cpp.js | 4 +-- src/mode/crystal.js | 3 +- src/mode/csharp.js | 3 +- src/mode/edifact.js | 3 +- src/mode/glsl.js | 4 +-- src/mode/golang.js | 3 +- src/mode/groovy.js | 3 +- src/mode/haxe.js | 3 +- src/mode/ion.js | 78 +++++++++++++++++++++-------------------- src/mode/jack.js | 3 +- src/mode/jexl.js | 3 +- src/mode/json.js | 3 +- src/mode/json5.js | 3 +- src/mode/jsp.js | 3 +- src/mode/jsx.js | 3 +- src/mode/kotlin.js | 3 +- src/mode/logiql.js | 3 +- src/mode/lsl.js | 4 +-- src/mode/mel.js | 3 +- src/mode/partiql.js | 79 ++++++++++++++++++++++-------------------- src/mode/php.js | 4 +-- src/mode/powershell.js | 3 +- src/mode/puppet.js | 3 +- src/mode/redshift.js | 3 +- src/mode/ruby.js | 3 +- src/mode/scad.js | 3 +- src/mode/scrypt.js | 3 +- src/mode/sh.js | 3 +- src/mode/sjs.js | 3 +- src/mode/smithy.js | 3 +- src/mode/swift.js | 2 -- src/mode/terraform.js | 3 +- src/mode/typescript.js | 3 +- src/mode/vala.js | 5 +-- 35 files changed, 113 insertions(+), 148 deletions(-) diff --git a/src/mode/apex.js b/src/mode/apex.js index b9217d57276..e8dc06d010a 100644 --- a/src/mode/apex.js +++ b/src/mode/apex.js @@ -6,14 +6,13 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var ApexHighlightRules = require("./apex_highlight_rules").ApexHighlightRules; var FoldMode = require("../mode/folding/cstyle").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; function ApexMode() { TextMode.call(this); this.HighlightRules = ApexHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; } oop.inherits(ApexMode, TextMode); diff --git a/src/mode/c_cpp.js b/src/mode/c_cpp.js index 367a8e9feeb..998e675f28b 100644 --- a/src/mode/c_cpp.js +++ b/src/mode/c_cpp.js @@ -4,15 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var c_cppHighlightRules = require("./c_cpp_highlight_rules").c_cppHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var Range = require("../range").Range; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = c_cppHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; diff --git a/src/mode/crystal.js b/src/mode/crystal.js index b4271a23cbf..9b5cf52eb8f 100644 --- a/src/mode/crystal.js +++ b/src/mode/crystal.js @@ -5,13 +5,12 @@ var TextMode = require("./text").Mode; var CrystalHighlightRules = require("./crystal_highlight_rules").CrystalHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Range = require("../range").Range; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var FoldMode = require("./folding/coffee").FoldMode; var Mode = function() { this.HighlightRules = CrystalHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new FoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/csharp.js b/src/mode/csharp.js index 9ff40297380..b18665b927d 100644 --- a/src/mode/csharp.js +++ b/src/mode/csharp.js @@ -4,13 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var CSharpHighlightRules = require("./csharp_highlight_rules").CSharpHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/csharp").FoldMode; var Mode = function() { this.HighlightRules = CSharpHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/edifact.js b/src/mode/edifact.js index b5bd2fe9692..49a2c297bb6 100644 --- a/src/mode/edifact.js +++ b/src/mode/edifact.js @@ -3,12 +3,11 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var EdifactHighlightRules = require("./edifact_highlight_rules").EdifactHighlightRules; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = EdifactHighlightRules; - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/glsl.js b/src/mode/glsl.js index cfd3216ebd4..d1ed41aea35 100644 --- a/src/mode/glsl.js +++ b/src/mode/glsl.js @@ -4,15 +4,13 @@ var oop = require("../lib/oop"); var CMode = require("./c_cpp").Mode; var glslHighlightRules = require("./glsl_highlight_rules").glslHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var Range = require("../range").Range; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = glslHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, CMode); diff --git a/src/mode/golang.js b/src/mode/golang.js index ecbe7fb2b4d..60d217abd02 100644 --- a/src/mode/golang.js +++ b/src/mode/golang.js @@ -2,14 +2,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var GolangHighlightRules = require("./golang_highlight_rules").GolangHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = GolangHighlightRules; this.$outdent = new MatchingBraceOutdent(); this.foldingRules = new CStyleFoldMode(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/groovy.js b/src/mode/groovy.js index 24755a3a232..c91f97b7a66 100644 --- a/src/mode/groovy.js +++ b/src/mode/groovy.js @@ -3,12 +3,11 @@ var oop = require("../lib/oop"); var JavaScriptMode = require("./javascript").Mode; var GroovyHighlightRules = require("./groovy_highlight_rules").GroovyHighlightRules; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { JavaScriptMode.call(this); this.HighlightRules = GroovyHighlightRules; - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, JavaScriptMode); diff --git a/src/mode/haxe.js b/src/mode/haxe.js index eda1a3fbc0c..eb11cf77e08 100644 --- a/src/mode/haxe.js +++ b/src/mode/haxe.js @@ -4,14 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var HaxeHighlightRules = require("./haxe_highlight_rules").HaxeHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = HaxeHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/ion.js b/src/mode/ion.js index 59088b89359..260b75f3504 100644 --- a/src/mode/ion.js +++ b/src/mode/ion.js @@ -2,50 +2,52 @@ THIS FILE WAS GENERATED BY 'ligand' USING 'mode.js' */ - "use strict"; - - var oop = require("../lib/oop"); - var TextMode = require("./text").Mode; - var HighlightRules = require("./ion_highlight_rules").IonHighlightRules; - var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; - var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; - var CStyleFoldMode = require("./folding/cstyle").FoldMode; - - var Mode = function() { - this.HighlightRules = HighlightRules; - this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); - this.foldingRules = new CStyleFoldMode(); +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var HighlightRules = require("./ion_highlight_rules").IonHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function () { + this.HighlightRules = HighlightRules; + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = this.$defaultBehaviour; + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function () { + + this.lineCommentStart = "//"; + this.blockComment = { + start: "/*", + end: "*/" }; - oop.inherits(Mode, TextMode); - (function() { + this.getNextLineIndent = function (state, line, tab) { + var indent = this.$getIndent(line); - this.lineCommentStart = "//"; - this.blockComment = {start: "/*", end: "*/"}; - - this.getNextLineIndent = function(state, line, tab) { - var indent = this.$getIndent(line); - - if (state == "start") { - var match = line.match(/^.*[\{\(\[]\s*$/); - if (match) { - indent += tab; - } + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; } + } - return indent; - }; + return indent; + }; - this.checkOutdent = function(state, line, input) { - return this.$outdent.checkOutdent(line, input); - }; + this.checkOutdent = function (state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; - this.autoOutdent = function(state, doc, row) { - this.$outdent.autoOutdent(doc, row); - }; + this.autoOutdent = function (state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; - this.$id = "ace/mode/ion"; - }).call(Mode.prototype); + this.$id = "ace/mode/ion"; +}).call(Mode.prototype); - exports.Mode = Mode; +exports.Mode = Mode; diff --git a/src/mode/jack.js b/src/mode/jack.js index 5a7e8dbcbab..eb47e64b35b 100644 --- a/src/mode/jack.js +++ b/src/mode/jack.js @@ -4,13 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var HighlightRules = require("./jack_highlight_rules").JackHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = HighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/jexl.js b/src/mode/jexl.js index 1e3e234c808..2ea881f123d 100644 --- a/src/mode/jexl.js +++ b/src/mode/jexl.js @@ -3,12 +3,11 @@ var oop = require("../lib/oop"); var JexlHighlightRules = require("./jexl_highlight_rules").JexlHighlightRules; var TextMode = require("./text").Mode; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function () { this.HighlightRules = JexlHighlightRules; - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/json.js b/src/mode/json.js index af668660ff3..cd578701414 100644 --- a/src/mode/json.js +++ b/src/mode/json.js @@ -4,14 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var HighlightRules = require("./json_highlight_rules").JsonHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var WorkerClient = require("../worker/worker_client").WorkerClient; var Mode = function() { this.HighlightRules = HighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/json5.js b/src/mode/json5.js index 26fbc4b376f..3804f228621 100644 --- a/src/mode/json5.js +++ b/src/mode/json5.js @@ -4,13 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var HighlightRules = require("./json5_highlight_rules").Json5HighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = HighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/jsp.js b/src/mode/jsp.js index fea7f73bca0..b52c2e099bc 100644 --- a/src/mode/jsp.js +++ b/src/mode/jsp.js @@ -4,13 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var JspHighlightRules = require("./jsp_highlight_rules").JspHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = JspHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/jsx.js b/src/mode/jsx.js index e9360486767..e2d588beb8b 100644 --- a/src/mode/jsx.js +++ b/src/mode/jsx.js @@ -4,13 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var JsxHighlightRules = require("./jsx_highlight_rules").JsxHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; function Mode() { this.HighlightRules = JsxHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); } oop.inherits(Mode, TextMode); diff --git a/src/mode/kotlin.js b/src/mode/kotlin.js index c74a1e3cb70..44edb6fdc1d 100644 --- a/src/mode/kotlin.js +++ b/src/mode/kotlin.js @@ -7,13 +7,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var KotlinHighlightRules = require("./kotlin_highlight_rules").KotlinHighlightRules; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var FoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = KotlinHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/logiql.js b/src/mode/logiql.js index aba25d9c421..dab41020452 100644 --- a/src/mode/logiql.js +++ b/src/mode/logiql.js @@ -6,14 +6,13 @@ var LogiQLHighlightRules = require("./logiql_highlight_rules").LogiQLHighlightRu var FoldMode = require("./folding/coffee").FoldMode; var TokenIterator = require("../token_iterator").TokenIterator; var Range = require("../range").Range; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Mode = function() { this.HighlightRules = LogiQLHighlightRules; this.foldingRules = new FoldMode(); this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/lsl.js b/src/mode/lsl.js index e510a26b25f..49ca28ae3d2 100644 --- a/src/mode/lsl.js +++ b/src/mode/lsl.js @@ -2,16 +2,14 @@ var Rules = require("./lsl_highlight_rules").LSLHighlightRules; var Outdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var Range = require("../range").Range; var TextMode = require("./text").Mode; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var oop = require("../lib/oop"); var Mode = function() { this.HighlightRules = Rules; this.$outdent = new Outdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/mel.js b/src/mode/mel.js index 6f7486f93e4..cbed4b2126e 100644 --- a/src/mode/mel.js +++ b/src/mode/mel.js @@ -3,12 +3,11 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var MELHighlightRules = require("./mel_highlight_rules").MELHighlightRules; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = MELHighlightRules; - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/partiql.js b/src/mode/partiql.js index 4ccb43bb0f8..c2b64d3a783 100644 --- a/src/mode/partiql.js +++ b/src/mode/partiql.js @@ -2,50 +2,53 @@ THIS FILE WAS GENERATED BY 'ligand' USING 'mode.js' */ - "use strict"; - - var oop = require("../lib/oop"); - var TextMode = require("./text").Mode; - var HighlightRules = require("./partiql_highlight_rules").PartiqlHighlightRules; - var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; - var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; - var CStyleFoldMode = require("./folding/cstyle").FoldMode; - - var Mode = function() { - this.HighlightRules = HighlightRules; - this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); - this.foldingRules = new CStyleFoldMode(); +"use strict"; + +var oop = require("../lib/oop"); +var TextMode = require("./text").Mode; +var HighlightRules = require("./partiql_highlight_rules").PartiqlHighlightRules; +var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; +var CStyleFoldMode = require("./folding/cstyle").FoldMode; + +var Mode = function () { + this.HighlightRules = HighlightRules; + this.$outdent = new MatchingBraceOutdent(); + this.$behaviour = this.$defaultBehaviour; + this.foldingRules = new CStyleFoldMode(); +}; +oop.inherits(Mode, TextMode); + +(function () { + + this.lineCommentStart = "--"; + this.blockComment = { + start: "/*", + end: "*/", + nestable: true }; - oop.inherits(Mode, TextMode); - (function() { + this.getNextLineIndent = function (state, line, tab) { + var indent = this.$getIndent(line); - this.lineCommentStart = "--"; - this.blockComment = {start: "/*", end: "*/", nestable:true}; - - this.getNextLineIndent = function(state, line, tab) { - var indent = this.$getIndent(line); - - if (state == "start") { - var match = line.match(/^.*[\{\(\[]\s*$/); - if (match) { - indent += tab; - } + if (state == "start") { + var match = line.match(/^.*[\{\(\[]\s*$/); + if (match) { + indent += tab; } + } - return indent; - }; + return indent; + }; - this.checkOutdent = function(state, line, input) { - return this.$outdent.checkOutdent(line, input); - }; + this.checkOutdent = function (state, line, input) { + return this.$outdent.checkOutdent(line, input); + }; - this.autoOutdent = function(state, doc, row) { - this.$outdent.autoOutdent(doc, row); - }; + this.autoOutdent = function (state, doc, row) { + this.$outdent.autoOutdent(doc, row); + }; - this.$id = "ace/mode/partiql"; - }).call(Mode.prototype); + this.$id = "ace/mode/partiql"; +}).call(Mode.prototype); - exports.Mode = Mode; +exports.Mode = Mode; diff --git a/src/mode/php.js b/src/mode/php.js index 8c63316ac56..459f02661c6 100644 --- a/src/mode/php.js +++ b/src/mode/php.js @@ -5,10 +5,8 @@ var TextMode = require("./text").Mode; var PhpHighlightRules = require("./php_highlight_rules").PhpHighlightRules; var PhpLangHighlightRules = require("./php_highlight_rules").PhpLangHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var Range = require("../range").Range; var WorkerClient = require("../worker/worker_client").WorkerClient; var PhpCompletions = require("./php_completions").PhpCompletions; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var unicode = require("../unicode"); var HtmlMode = require("./html").Mode; @@ -18,7 +16,7 @@ var CssMode = require("./css").Mode; var PhpMode = function(opts) { this.HighlightRules = PhpLangHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.$completer = new PhpCompletions(); this.foldingRules = new CStyleFoldMode(); }; diff --git a/src/mode/powershell.js b/src/mode/powershell.js index 00ec972f7b0..34882aec07c 100644 --- a/src/mode/powershell.js +++ b/src/mode/powershell.js @@ -4,13 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var PowershellHighlightRules = require("./powershell_highlight_rules").PowershellHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = PowershellHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode({start: "^\\s*(<#)", end: "^[#\\s]>\\s*$"}); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/puppet.js b/src/mode/puppet.js index 555d688e416..a743e3ebd4b 100644 --- a/src/mode/puppet.js +++ b/src/mode/puppet.js @@ -3,7 +3,6 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var PuppetHighlightRules = require("./puppet_highlight_rules").PuppetHighlightRules; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; @@ -11,7 +10,7 @@ var Mode = function () { TextMode.call(this); this.HighlightRules = PuppetHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; diff --git a/src/mode/redshift.js b/src/mode/redshift.js index b7c48770318..0ca551d14ba 100644 --- a/src/mode/redshift.js +++ b/src/mode/redshift.js @@ -1,11 +1,10 @@ var oop = require("../lib/oop"); var TextMode = require("../mode/text").Mode; var RedshiftHighlightRules = require("./redshift_highlight_rules").RedshiftHighlightRules; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = RedshiftHighlightRules; - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/ruby.js b/src/mode/ruby.js index 57033ebd569..6d1309fa9a1 100644 --- a/src/mode/ruby.js +++ b/src/mode/ruby.js @@ -5,13 +5,12 @@ var TextMode = require("./text").Mode; var RubyHighlightRules = require("./ruby_highlight_rules").RubyHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; var Range = require("../range").Range; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var FoldMode = require("./folding/ruby").FoldMode; var Mode = function() { this.HighlightRules = RubyHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new FoldMode(); this.indentKeywords = this.foldingRules.indentKeywords; }; diff --git a/src/mode/scad.js b/src/mode/scad.js index 35035630e57..fb36070f628 100644 --- a/src/mode/scad.js +++ b/src/mode/scad.js @@ -4,13 +4,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var scadHighlightRules = require("./scad_highlight_rules").scadHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = scadHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/scrypt.js b/src/mode/scrypt.js index 378968bb2e4..e677366c3e0 100644 --- a/src/mode/scrypt.js +++ b/src/mode/scrypt.js @@ -8,12 +8,11 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var scryptHighlightRules = require("./scrypt_highlight_rules").scryptHighlightRules; var FoldMode = require("./folding/cstyle").FoldMode; -var CstyleBehaviour = require("../mode/behaviour/cstyle").CstyleBehaviour; var Mode = function () { this.HighlightRules = scryptHighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/sh.js b/src/mode/sh.js index 57551d861e5..f65cbbcf045 100644 --- a/src/mode/sh.js +++ b/src/mode/sh.js @@ -5,12 +5,11 @@ var TextMode = require("./text").Mode; var ShHighlightRules = require("./sh_highlight_rules").ShHighlightRules; var Range = require("../range").Range; var CStyleFoldMode = require("./folding/cstyle").FoldMode; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var Mode = function() { this.HighlightRules = ShHighlightRules; this.foldingRules = new CStyleFoldMode(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/sjs.js b/src/mode/sjs.js index 74ead7d0a02..d572895cdb3 100644 --- a/src/mode/sjs.js +++ b/src/mode/sjs.js @@ -3,13 +3,12 @@ var oop = require("../lib/oop"); var JSMode = require("./javascript").Mode; var SJSHighlightRules = require("./sjs_highlight_rules").SJSHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = SJSHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, JSMode); diff --git a/src/mode/smithy.js b/src/mode/smithy.js index 61089126ec5..fab586a9ebc 100644 --- a/src/mode/smithy.js +++ b/src/mode/smithy.js @@ -4,14 +4,13 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var SmithyHighlightRules = require("./smithy_highlight_rules").SmithyHighlightRules; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = SmithyHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode); diff --git a/src/mode/swift.js b/src/mode/swift.js index de35d0a4ede..656c2ce7f02 100644 --- a/src/mode/swift.js +++ b/src/mode/swift.js @@ -7,14 +7,12 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var HighlightRules = require("./swift_highlight_rules").HighlightRules; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; // TODO: pick appropriate fold mode var FoldMode = require("./folding/cstyle").FoldMode; var Mode = function() { this.HighlightRules = HighlightRules; this.foldingRules = new FoldMode(); - this.$behaviour = new CstyleBehaviour(); this.$behaviour = this.$defaultBehaviour; }; oop.inherits(Mode, TextMode); diff --git a/src/mode/terraform.js b/src/mode/terraform.js index b0df9333694..8811d699bc2 100644 --- a/src/mode/terraform.js +++ b/src/mode/terraform.js @@ -3,7 +3,6 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; var TerraformHighlightRules = require("./terraform_highlight_rules").TerraformHighlightRules; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; @@ -11,7 +10,7 @@ var Mode = function () { TextMode.call(this); this.HighlightRules = TerraformHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; diff --git a/src/mode/typescript.js b/src/mode/typescript.js index 8ba5ac1591d..1af0433e045 100644 --- a/src/mode/typescript.js +++ b/src/mode/typescript.js @@ -7,7 +7,6 @@ var oop = require("../lib/oop"); var jsMode = require("./javascript").Mode; var TypeScriptHighlightRules = require("./typescript_highlight_rules").TypeScriptHighlightRules; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; @@ -15,7 +14,7 @@ var Mode = function() { this.HighlightRules = TypeScriptHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, jsMode); diff --git a/src/mode/vala.js b/src/mode/vala.js index 75453236ae9..9a2e69e7756 100644 --- a/src/mode/vala.js +++ b/src/mode/vala.js @@ -6,10 +6,7 @@ var oop = require("../lib/oop"); var TextMode = require("./text").Mode; -var Tokenizer = require("../tokenizer").Tokenizer; var ValaHighlightRules = require("./vala_highlight_rules").ValaHighlightRules; -var FoldMode = require("./folding/cstyle").FoldMode; -var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CStyleFoldMode = require("./folding/cstyle").FoldMode; var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent; @@ -17,7 +14,7 @@ var Mode = function() { this.HighlightRules = ValaHighlightRules; this.$outdent = new MatchingBraceOutdent(); - this.$behaviour = new CstyleBehaviour(); + this.$behaviour = this.$defaultBehaviour; this.foldingRules = new CStyleFoldMode(); }; oop.inherits(Mode, TextMode);