minor fixes
This commit is contained in:
parent
58d2b6917f
commit
b7e69d5da5
4 changed files with 32 additions and 13 deletions
|
|
@ -44,6 +44,7 @@ ace.Editor.prototype.setDocument = function(doc) {
|
|||
};
|
||||
|
||||
ace.Editor.prototype.setMode = function(mode) {
|
||||
if (this.mode == mode) return;
|
||||
|
||||
this.mode = mode;
|
||||
var tokenizer = mode.getTokenizer();
|
||||
|
|
|
|||
|
|
@ -10,11 +10,10 @@ ace.Tokenizer = function(rules) {
|
|||
|
||||
for ( var i = 0; i < state.length; i++) {
|
||||
ruleRegExps.push(state[i].regex);
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
this.regExps[key] = new RegExp("(?:(" + ruleRegExps.join(")|(")
|
||||
+ ")|(.+))", "g");
|
||||
+ ")|(.))", "g");
|
||||
}
|
||||
};
|
||||
|
||||
|
|
@ -37,7 +36,7 @@ ace.Tokenizer.prototype.getLineTokens = function(line, startState) {
|
|||
if (re.lastIndex == lastIndex) { throw new Error("tokenizer error"); }
|
||||
lastIndex = re.lastIndex;
|
||||
|
||||
// console.log(match);
|
||||
// window.LOG && console.log(match);
|
||||
|
||||
for ( var i = 0; i < state.length; i++) {
|
||||
if (match[i + 1]) {
|
||||
|
|
@ -58,14 +57,12 @@ ace.Tokenizer.prototype.getLineTokens = function(line, startState) {
|
|||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
tokens.push(token);
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
// console.log(tokens, currentState)
|
||||
// window.LOG && console.log(tokens, currentState);
|
||||
|
||||
return {
|
||||
tokens : tokens,
|
||||
|
|
|
|||
|
|
@ -19,11 +19,12 @@ ace.mode.JavaScript.prototype.increaseIndentPatterns = {
|
|||
|
||||
ace.mode.JavaScript.prototype.getNextLineIndent = function(line, state, tab) {
|
||||
var re = this.increaseIndentPatterns[state];
|
||||
if (!re) return
|
||||
|
||||
var match = line.match(re);
|
||||
if (match) {
|
||||
return (match[1] || "") + tab;
|
||||
if (re) {
|
||||
var match = line.match(re);
|
||||
if (match) {
|
||||
return (match[1] || "") + tab;
|
||||
}
|
||||
}
|
||||
|
||||
var match = line.match(/^(\s+).*$/);
|
||||
|
|
|
|||
20
test/mode/JavaScriptTokenizerTest.js
Normal file
20
test/mode/JavaScriptTokenizerTest.js
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
var JavaScriptTokenizerTest = new TestCase("mode.JavaScriptTokenizerTest", {
|
||||
|
||||
setUp : function() {
|
||||
this.tokenizer = new ace.mode.JavaScript().getTokenizer();
|
||||
},
|
||||
|
||||
"test: tokenize1" : function() {
|
||||
var line = "foo = function";
|
||||
|
||||
var tokens = this.tokenizer.getLineTokens(line, "start").tokens;
|
||||
|
||||
assertEquals(5, tokens.length);
|
||||
assertEquals("identifier", tokens[0].type);
|
||||
assertEquals("text", tokens[1].type);
|
||||
assertEquals("text", tokens[2].type);
|
||||
assertEquals("text", tokens[3].type);
|
||||
assertEquals("keyword", tokens[4].type);
|
||||
}
|
||||
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue