fix php indentation
This commit is contained in:
parent
b204cd7236
commit
2bd2e37367
1 changed files with 45 additions and 43 deletions
|
|
@ -55,6 +55,51 @@ var PhpMode = function(opts) {
|
||||||
};
|
};
|
||||||
oop.inherits(PhpMode, TextMode);
|
oop.inherits(PhpMode, TextMode);
|
||||||
|
|
||||||
|
(function() {
|
||||||
|
|
||||||
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
|
var indent = this.$getIndent(line);
|
||||||
|
|
||||||
|
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
||||||
|
var tokens = tokenizedLine.tokens;
|
||||||
|
var endState = tokenizedLine.state;
|
||||||
|
|
||||||
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
|
return indent;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state == "start") {
|
||||||
|
var match = line.match(/^.*[\{\(\[\:]\s*$/);
|
||||||
|
if (match) {
|
||||||
|
indent += tab;
|
||||||
|
}
|
||||||
|
} else if (state == "doc-start") {
|
||||||
|
if (endState != "doc-start") {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
var match = line.match(/^\s*(\/?)\*/);
|
||||||
|
if (match) {
|
||||||
|
if (match[1]) {
|
||||||
|
indent += " ";
|
||||||
|
}
|
||||||
|
indent += "* ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return indent;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.checkOutdent = function(state, line, input) {
|
||||||
|
return this.$outdent.checkOutdent(line, input);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.autoOutdent = function(state, doc, row) {
|
||||||
|
this.$outdent.autoOutdent(doc, row);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.$id = "ace/mode/php-inline";
|
||||||
|
}).call(PhpMode.prototype);
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
HtmlMode.call(this);
|
HtmlMode.call(this);
|
||||||
this.HighlightRules = PhpHighlightRules;
|
this.HighlightRules = PhpHighlightRules;
|
||||||
|
|
@ -86,49 +131,6 @@ oop.inherits(Mode, HtmlMode);
|
||||||
this.lineCommentStart = ["//", "#"];
|
this.lineCommentStart = ["//", "#"];
|
||||||
this.blockComment = {start: "/*", end: "*/"};
|
this.blockComment = {start: "/*", end: "*/"};
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
|
||||||
var indent = this.$getIndent(line);
|
|
||||||
|
|
||||||
var tokenizedLine = this.getTokenizer().getLineTokens(line, state);
|
|
||||||
var tokens = tokenizedLine.tokens;
|
|
||||||
var endState = tokenizedLine.state;
|
|
||||||
|
|
||||||
|
|
||||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
|
||||||
return indent;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (state == "php-start") {
|
|
||||||
var match = line.match(/^.*[\{\(\[\:]\s*$/);
|
|
||||||
if (match) {
|
|
||||||
indent += tab;
|
|
||||||
}
|
|
||||||
} else if (state == "php-doc-start") {
|
|
||||||
if (endState != "php-doc-start") {
|
|
||||||
return "";
|
|
||||||
}
|
|
||||||
var match = line.match(/^\s*(\/?)\*/);
|
|
||||||
if (match) {
|
|
||||||
if (match[1]) {
|
|
||||||
indent += " ";
|
|
||||||
}
|
|
||||||
indent += "* ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return indent;
|
|
||||||
};
|
|
||||||
|
|
||||||
this.checkOutdent = function(state, line, input) {
|
|
||||||
if (this.$outdent)
|
|
||||||
return this.$outdent.checkOutdent(line, input);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.autoOutdent = function(state, doc, row) {
|
|
||||||
if (this.$outdent)
|
|
||||||
this.$outdent.autoOutdent(doc, row);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.createWorker = function(session) {
|
this.createWorker = function(session) {
|
||||||
var worker = new WorkerClient(["ace"], "ace/mode/php_worker", "PhpWorker");
|
var worker = new WorkerClient(["ace"], "ace/mode/php_worker", "PhpWorker");
|
||||||
worker.attachToDocument(session.getDocument());
|
worker.attachToDocument(session.getDocument());
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue