Add support for doc doc comments:
- special highlighting - highlight jsdoc tags - special auto indent mode
This commit is contained in:
parent
80f6cd7726
commit
257d80f379
7 changed files with 103 additions and 43 deletions
|
|
@ -50,32 +50,23 @@ var JavaScriptTest = new TestCase("mode.JavaScriptTest", {
|
|||
},
|
||||
|
||||
"test: auto indent after opening brace" : function() {
|
||||
var doc = new ace.TextDocument(["if () {"].join("\n"));
|
||||
var editor = new ace.Editor(new MockRenderer(), doc, this.mode);
|
||||
|
||||
editor.navigateLineEnd();
|
||||
editor.onTextInput("\n");
|
||||
|
||||
assertEquals(["if () {", doc.getTabString()].join("\n"), doc.toString());
|
||||
assertEquals(" ", this.mode.getNextLineIndent("if () {", "start", " "));
|
||||
},
|
||||
|
||||
"test: no auto indent after opening brace in multi line comment" : function() {
|
||||
var doc = new ace.TextDocument(["/*if () {"].join("\n"));
|
||||
var editor = new ace.Editor(new MockRenderer(), doc, this.mode);
|
||||
|
||||
editor.navigateLineEnd();
|
||||
editor.onTextInput("\n");
|
||||
|
||||
assertEquals(["/*if () {", ""].join("\n"), doc.toString());
|
||||
assertEquals("", this.mode.getNextLineIndent("/*if () {", " "));
|
||||
},
|
||||
|
||||
"test: no auto indent should add to existing indent" : function() {
|
||||
var doc = new ace.TextDocument([" if () {"].join("\n"));
|
||||
var editor = new ace.Editor(new MockRenderer(), doc, this.mode);
|
||||
assertEquals(" ", this.mode.getNextLineIndent(" if () {", "start", " "));
|
||||
assertEquals(" ", this.mode.getNextLineIndent(" cde", "start", " "));
|
||||
},
|
||||
|
||||
editor.navigateLineEnd();
|
||||
editor.onTextInput("\n");
|
||||
|
||||
assertEquals([" if () {", " " + doc.getTabString()].join("\n"), doc.toString());
|
||||
"test: special indent in doc comments" : function() {
|
||||
assertEquals(" * ", this.mode.getNextLineIndent("/**", "doc-comment", " "));
|
||||
assertEquals(" * ", this.mode.getNextLineIndent(" /**", "doc-comment", " "));
|
||||
assertEquals(" * ", this.mode.getNextLineIndent(" *", "doc-comment", " "));
|
||||
assertEquals(" * ", this.mode.getNextLineIndent(" *", "doc-comment", " "));
|
||||
assertEquals(" ", this.mode.getNextLineIndent(" abc", "doc-comment", " "));
|
||||
}
|
||||
});
|
||||
|
|
@ -9,12 +9,33 @@ var JavaScriptTokenizerTest = new TestCase("mode.JavaScriptTokenizerTest", {
|
|||
|
||||
var tokens = this.tokenizer.getLineTokens(line, "start").tokens;
|
||||
|
||||
assertEquals(3, tokens.length);
|
||||
assertEquals("identifier", tokens[0].type);
|
||||
assertEquals("text", tokens[1].type);
|
||||
assertEquals("keyword", tokens[2].type);
|
||||
},
|
||||
|
||||
"test: tokenize doc comment" : function() {
|
||||
var line = "abc /** de */ fg";
|
||||
|
||||
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("doc-comment", tokens[2].type);
|
||||
assertEquals("text", tokens[3].type);
|
||||
assertEquals("keyword", tokens[4].type);
|
||||
}
|
||||
assertEquals("identifier", tokens[4].type);
|
||||
},
|
||||
|
||||
"test: tokenize doc comment with tag" : function() {
|
||||
var line = "/** @param {} */";
|
||||
|
||||
var tokens = this.tokenizer.getLineTokens(line, "start").tokens;
|
||||
|
||||
assertEquals(3, tokens.length);
|
||||
assertEquals("doc-comment", tokens[0].type);
|
||||
assertEquals("doc-comment-tag", tokens[1].type);
|
||||
assertEquals("doc-comment", tokens[2].type);
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue