added doc comment highlight to fix folding

This commit is contained in:
sevin7676 2015-04-18 08:24:59 -04:00
commit d38849ef9f
2 changed files with 19 additions and 10 deletions

View file

@ -49,6 +49,7 @@ oop.inherits(FoldMode, BaseFoldMode);
this.foldingStartMarker = /(\bCASE\b|\bBEGIN\b)|^\s*(\/\*)/i; this.foldingStartMarker = /(\bCASE\b|\bBEGIN\b)|^\s*(\/\*)/i;
this.foldingStopMarker = /^(\bEND\b)|^[\s\*]*(\*\/)/i; this.foldingStopMarker = /^(\bEND\b)|^[\s\*]*(\*\/)/i;
// this.foldingStopMarker = /(\bEND\b)|^[\s\*]*(\*\/)/i;?need hat?
// this.foldingStopMarker = /^(?!\bCASE\b|\bBEGIN\b)(\bEND\b)|^[\s\*]*(\*\/)/i; // this.foldingStopMarker = /^(?!\bCASE\b|\bBEGIN\b)(\bEND\b)|^[\s\*]*(\*\/)/i;
// this.foldingStopMarker = /^(?!\bCASE\b|\bBEGIN\b).*(\bEND\b)|^[\s\*]*(\*\/)/i; // this.foldingStopMarker = /^(?!\bCASE\b|\bBEGIN\b).*(\bEND\b)|^[\s\*]*(\*\/)/i;
@ -63,13 +64,9 @@ oop.inherits(FoldMode, BaseFoldMode);
var match = line.match(this.foldingStartMarker); var match = line.match(this.foldingStartMarker);
if (match) { if (match) {
var i = match.index; var i = match.index;
//if first capturing group (CASE|BEGIN)
if (match[1]) return this.getBeginEndBlock(session, row, i, match[1]); if (match[1]) return this.getBeginEndBlock(session, row, i, match[1]);
//still going: match is for second capturing group, which is blockcomment
var range = session.getCommentFoldRange(row, i + match[0].length, 1); var range = session.getCommentFoldRange(row, i + match[0].length, 1);
console.log('getCommentFoldRange',range);
if (range && !range.isMultiLine()) { if (range && !range.isMultiLine()) {
if (forceMultiline) { if (forceMultiline) {
range = this.getSectionRange(session, row); range = this.getSectionRange(session, row);
@ -81,8 +78,7 @@ oop.inherits(FoldMode, BaseFoldMode);
return range; return range;
} }
//no support for end folding markers yet if (foldStyle === "markbegin") return; //no support for end folding markers yet
if (foldStyle === "markbegin") return;
return; return;
}; };

View file

@ -32,6 +32,7 @@ define(function(require, exports, module) {
"use strict"; "use strict";
var oop = require("../lib/oop"); var oop = require("../lib/oop");
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules; var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
var SqlServerHighlightRules = function() { var SqlServerHighlightRules = function() {
@ -167,7 +168,8 @@ var SqlServerHighlightRules = function() {
}, { }, {
defaultToken: "string" defaultToken: "string"
}] }]
}, { },
DocCommentHighlightRules.getStartRule("doc-start"), {
token: "comment", token: "comment",
regex: "--.*$" regex: "--.*$"
}, { }, {
@ -202,7 +204,16 @@ var SqlServerHighlightRules = function() {
}, { }, {
token: "text", token: "text",
regex: "\\s+" regex: "\\s+"
}] }],
comment: [
DocCommentHighlightRules.getTagRule(), {
token: "comment",
regex: "\\*\\/",
next: "no_regex"
}, {
defaultToken: "comment",
caseInsensitive: true
}],
}; };
//add each set statment as regex at top of rules so that they are processed first because they require multiple words //add each set statment as regex at top of rules so that they are processed first because they require multiple words
@ -215,6 +226,8 @@ var SqlServerHighlightRules = function() {
}); });
} }
this.embedRules(DocCommentHighlightRules, "doc-", [DocCommentHighlightRules.getEndRule("start")]);
this.normalizeRules(); this.normalizeRules();
}; };