use mode delegates in PHP

fixes #2197
This commit is contained in:
Adam Jimenez 2014-10-29 17:01:41 +00:00
commit b204cd7236

View file

@ -41,8 +41,11 @@ var WorkerClient = require("../worker/worker_client").WorkerClient;
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour; var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode; var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var unicode = require("../unicode"); var unicode = require("../unicode");
var HtmlMode = require("./html").Mode;
var JavaScriptMode = require("./javascript").Mode;
var CssMode = require("./css").Mode;
var Mode = function(opts) { var PhpMode = function(opts) {
this.inlinePhp = opts && opts.inline; this.inlinePhp = opts && opts.inline;
var HighlightRules = this.inlinePhp ? PhpLangHighlightRules : PhpHighlightRules; var HighlightRules = this.inlinePhp ? PhpLangHighlightRules : PhpHighlightRules;
this.HighlightRules = HighlightRules; this.HighlightRules = HighlightRules;
@ -50,7 +53,18 @@ var Mode = function(opts) {
this.$behaviour = new CstyleBehaviour(); this.$behaviour = new CstyleBehaviour();
this.foldingRules = new CStyleFoldMode(); this.foldingRules = new CStyleFoldMode();
}; };
oop.inherits(Mode, TextMode); oop.inherits(PhpMode, TextMode);
var Mode = function() {
HtmlMode.call(this);
this.HighlightRules = PhpHighlightRules;
this.createModeDelegates({
"js-": JavaScriptMode,
"css-": CssMode,
"php-": PhpMode
});
};
oop.inherits(Mode, HtmlMode);
(function() { (function() {
@ -106,11 +120,13 @@ oop.inherits(Mode, TextMode);
}; };
this.checkOutdent = function(state, line, input) { this.checkOutdent = function(state, line, input) {
return this.$outdent.checkOutdent(line, input); if (this.$outdent)
return this.$outdent.checkOutdent(line, input);
}; };
this.autoOutdent = function(state, doc, row) { this.autoOutdent = function(state, doc, row) {
this.$outdent.autoOutdent(doc, row); if (this.$outdent)
this.$outdent.autoOutdent(doc, row);
}; };
this.createWorker = function(session) { this.createWorker = function(session) {