haxe mode
This commit is contained in:
parent
c97fc93a71
commit
74beb8070d
2 changed files with 37 additions and 37 deletions
|
|
@ -1,11 +1,11 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("pilot/oop");
|
var oop = require("../lib/oop");
|
||||||
var TextMode = require("ace/mode/text").Mode;
|
var TextMode = require("./text").Mode;
|
||||||
var Tokenizer = require("ace/tokenizer").Tokenizer;
|
var Tokenizer = require("../tokenizer").Tokenizer;
|
||||||
var HaxeHighlightRules = require("ace/mode/haxe_highlight_rules").HaxeHighlightRules;
|
var HaxeHighlightRules = require("./haxe_highlight_rules").HaxeHighlightRules;
|
||||||
var MatchingBraceOutdent = require("ace/mode/matching_brace_outdent").MatchingBraceOutdent;
|
var MatchingBraceOutdent = require("./matching_brace_outdent").MatchingBraceOutdent;
|
||||||
var CstyleBehaviour = require("ace/mode/behaviour/cstyle").CstyleBehaviour;
|
var CstyleBehaviour = require("./behaviour/cstyle").CstyleBehaviour;
|
||||||
|
|
||||||
var Mode = function() {
|
var Mode = function() {
|
||||||
this.$tokenizer = new Tokenizer(new HaxeHighlightRules().getRules());
|
this.$tokenizer = new Tokenizer(new HaxeHighlightRules().getRules());
|
||||||
|
|
@ -15,35 +15,35 @@ var Mode = function() {
|
||||||
oop.inherits(Mode, TextMode);
|
oop.inherits(Mode, TextMode);
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
this.getNextLineIndent = function(state, line, tab) {
|
|
||||||
var indent = this.$getIndent(line);
|
|
||||||
|
|
||||||
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
this.getNextLineIndent = function(state, line, tab) {
|
||||||
var tokens = tokenizedLine.tokens;
|
var indent = this.$getIndent(line);
|
||||||
var endState = tokenizedLine.state;
|
|
||||||
|
|
||||||
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
var tokenizedLine = this.$tokenizer.getLineTokens(line, state);
|
||||||
return indent;
|
var tokens = tokenizedLine.tokens;
|
||||||
}
|
var endState = tokenizedLine.state;
|
||||||
|
|
||||||
if (state == "start") {
|
|
||||||
var match = line.match(/^.*[\{\(\[]\s*$/);
|
|
||||||
if (match) {
|
|
||||||
indent += tab;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return indent;
|
if (tokens.length && tokens[tokens.length-1].type == "comment") {
|
||||||
};
|
return indent;
|
||||||
|
}
|
||||||
|
|
||||||
this.checkOutdent = function(state, line, input) {
|
if (state == "start") {
|
||||||
return this.$outdent.checkOutdent(line, input);
|
var match = line.match(/^.*[\{\(\[]\s*$/);
|
||||||
};
|
if (match) {
|
||||||
|
indent += tab;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
this.autoOutdent = function(state, doc, row) {
|
return indent;
|
||||||
this.$outdent.autoOutdent(doc, row);
|
};
|
||||||
};
|
|
||||||
|
this.checkOutdent = function(state, line, input) {
|
||||||
|
return this.$outdent.checkOutdent(line, input);
|
||||||
|
};
|
||||||
|
|
||||||
|
this.autoOutdent = function(state, doc, row) {
|
||||||
|
this.$outdent.autoOutdent(doc, row);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
this.createWorker = function(session) {
|
this.createWorker = function(session) {
|
||||||
|
|
|
||||||
|
|
@ -1,14 +1,14 @@
|
||||||
define(function(require, exports, module) {
|
define(function(require, exports, module) {
|
||||||
|
|
||||||
var oop = require("pilot/oop");
|
var oop = require("../lib/oop");
|
||||||
var lang = require("pilot/lang");
|
var lang = require("../lib/lang");
|
||||||
var DocCommentHighlightRules = require("ace/mode/doc_comment_highlight_rules").DocCommentHighlightRules;
|
var DocCommentHighlightRules = require("./doc_comment_highlight_rules").DocCommentHighlightRules;
|
||||||
var TextHighlightRules = require("ace/mode/text_highlight_rules").TextHighlightRules;
|
var TextHighlightRules = require("./text_highlight_rules").TextHighlightRules;
|
||||||
|
|
||||||
var HaxeHighlightRules = function() {
|
var HaxeHighlightRules = function() {
|
||||||
|
|
||||||
var keywords = lang.arrayToMap(
|
var keywords = lang.arrayToMap(
|
||||||
("break|case|cast|catch|class|continue|default|else|enum|extends|for|function|if|implements|import|in|inline|interface|new|override|package|private|public|return|static|super|switch|this|throw|trace|try|typedef|untyped|var|while|Array|Void|Bool|Int|UInt|Float|Dynamic|String|List|Hash|IntHash|Error|Unknown|Type|Std").split("|")
|
("break|case|cast|catch|class|continue|default|else|enum|extends|for|function|if|implements|import|in|inline|interface|new|override|package|private|public|return|static|super|switch|this|throw|trace|try|typedef|untyped|var|while|Array|Void|Bool|Int|UInt|Float|Dynamic|String|List|Hash|IntHash|Error|Unknown|Type|Std").split("|")
|
||||||
);
|
);
|
||||||
|
|
||||||
var buildinConstants = lang.arrayToMap(
|
var buildinConstants = lang.arrayToMap(
|
||||||
|
|
@ -92,7 +92,7 @@ var HaxeHighlightRules = function() {
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
||||||
this.embedRules(DocCommentHighlightRules, "doc-",
|
this.embedRules(DocCommentHighlightRules, "doc-",
|
||||||
[ new DocCommentHighlightRules().getEndRule("start") ]);
|
[ new DocCommentHighlightRules().getEndRule("start") ]);
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue