fix xquery mode breaking autocompletion and add tests

This commit is contained in:
nightwing 2014-11-01 19:27:40 +04:00
commit 5b3bbba54e
21 changed files with 871 additions and 10 deletions

View file

@ -40,6 +40,9 @@ var util = require("../autocomplete/util");
var textCompleter = require("../autocomplete/text_completer");
var keyWordCompleter = {
getCompletions: function(editor, session, pos, prefix, callback) {
if (session.$mode.completer) {
return session.$mode.completer.getCompletions(editor, session, pos, prefix, callback);
}
var state = editor.session.getState(pos.row);
var completions = session.$mode.getCompletions(state, session, pos, prefix);
callback(null, completions);

View file

@ -58,7 +58,8 @@ function checkModes() {
}
function generateTestData() {
var docs = jsFileList(cwd + root);
var docRoot = root + "/demo/kitchen-sink/docs";
var docs = fs.readdirSync(docRoot);
var specialDocs = fs.readdirSync(cwd);
var modes = modeList();
@ -79,10 +80,12 @@ function generateTestData() {
var filePath = "text_" + modeName + ".txt";
if (specialDocs.indexOf(filePath) == -1) {
filePath = root + "/" + docName;
filePath = docRoot + "/" + docName;
} else {
filePath = cwd + filePath;
}
var text = fs.readFileSync(cwd + filePath, "utf8");
var text = fs.readFileSync(filePath, "utf8");
try {
var Mode = require("../" + modeName).Mode;
} catch(e) {

View file

@ -0,0 +1,141 @@
[[
"start",
["keyword","note"]
],[
"start",
["text","\t"],
["identifier","description"],
["keyword.operator",":"],
["text"," "],
["string.quoted.double","\"Represents a person.\""]
],[
"start"
],[
"start",
["keyword","class"]
],[
"start",
["text","\t"],
["entity.name.type","PERSON"]
],[
"start"
],[
"start",
["keyword","create"]
],[
"start",
["text","\t"],
["identifier","make"],
["keyword.operator",","],
["text"," "],
["identifier","make_unknown"]
],[
"start"
],[
"start",
["keyword","feature"],
["text"," "],
["paren.lparen","{"],
["entity.name.type","NONE"],
["paren.rparen","}"],
["text"," "],
["comment.line.double-dash","-- Creation"]
],[
"start"
],[
"start",
["text","\t"],
["identifier","make"],
["text"," "],
["paren.lparen","("],
["identifier","a_name"],
["keyword.operator",":"],
["text"," "],
["keyword","like"],
["text"," "],
["identifier","name"],
["paren.rparen",")"]
],[
"start",
["text","\t\t\t"],
["comment.line.double-dash","-- Create a person with `a_name' as `name'."]
],[
"start",
["text","\t\t"],
["keyword","do"]
],[
"start",
["text","\t\t\t"],
["identifier","name"],
["text"," "],
["keyword.operator",":="],
["text"," "],
["identifier","a_name"]
],[
"start",
["text","\t\t"],
["keyword","ensure"]
],[
"start",
["text","\t\t\t"],
["identifier","name"],
["text"," "],
["keyword.operator","="],
["text"," "],
["identifier","a_name"]
],[
"start",
["text","\t\t"],
["keyword","end"]
],[
"start"
],[
"start",
["text","\t"],
["identifier","make_unknown"]
],[
"start",
["text","\t\t"],
["keyword","do"],
["text"," "],
["keyword","ensure"]
],[
"start",
["text","\t\t\t"],
["identifier","name"],
["text"," "],
["keyword.operator","="],
["text"," "],
["constant.language","Void"]
],[
"start",
["text","\t\t"],
["keyword","end"]
],[
"start"
],[
"start",
["keyword","feature"],
["text"," "],
["comment.line.double-dash","-- Access"]
],[
"start"
],[
"start",
["text","\t"],
["identifier","name"],
["keyword.operator",":"],
["text"," "],
["keyword","detachable"],
["text"," "],
["entity.name.type","STRING"]
],[
"start",
["text","\t\t\t"],
["comment.line.double-dash","-- Full name or Void if unknown."]
],[
"start"
],[
"start",
["keyword","end"]
]]

View file

@ -0,0 +1,198 @@
[[
"start",
["comment.start","{-"],
["comment"," Ace "],
["comment.start","{-"],
["comment"," 4 "],
["comment.end","-}"],
["comment"," Elm "],
["comment.end","-}"]
],[
"start",
["constant.language","main"],
["text"," "],
["keyword","="],
["text"," "],
["identifier","lift"],
["text"," "],
["identifier","clock"],
["text"," "],
["paren.lparen","("],
["identifier","every"],
["text"," "],
["identifier","second"],
["paren.rparen",")"]
],[
"start"
],[
"start",
["constant.language","clock"],
["text"," "],
["identifier","t"],
["text"," "],
["keyword","="],
["text"," "],
["identifier","collage"],
["text"," "],
["constant.numeric","400"],
["text"," "],
["constant.numeric","400"],
["text"," "],
["paren.lparen","["],
["text"," "],
["identifier","filled"],
["text"," "],
["identifier","lightGrey"],
["text"," "],
["paren.lparen","("],
["identifier","ngon"],
["text"," "],
["constant.numeric","12"],
["text"," "],
["constant.numeric","110"],
["paren.rparen",")"]
],[
"start",
["text"," "],
["operator.punctuation",","],
["text"," "],
["identifier","outlined"],
["text"," "],
["paren.lparen","("],
["identifier","solid"],
["text"," "],
["identifier","grey"],
["paren.rparen",")"],
["text"," "],
["paren.lparen","("],
["identifier","ngon"],
["text"," "],
["constant.numeric","12"],
["text"," "],
["constant.numeric","110"],
["paren.rparen",")"]
],[
"start",
["text"," "],
["operator.punctuation",","],
["text"," "],
["identifier","hand"],
["text"," "],
["identifier","orange"],
["text"," "],
["constant.numeric","100"],
["text"," "],
["identifier","t"]
],[
"start",
["text"," "],
["operator.punctuation",","],
["text"," "],
["identifier","hand"],
["text"," "],
["identifier","charcoal"],
["text"," "],
["constant.numeric","100"],
["text"," "],
["paren.lparen","("],
["identifier","t"],
["keyword.operator","/"],
["constant.numeric","60"],
["paren.rparen",")"]
],[
"start",
["text"," "],
["operator.punctuation",","],
["text"," "],
["identifier","hand"],
["text"," "],
["identifier","charcoal"],
["text"," "],
["constant.numeric","60"],
["text"," "],
["paren.lparen","("],
["identifier","t"],
["keyword.operator","/"],
["constant.numeric","720"],
["paren.rparen",")"],
["text"," "],
["paren.rparen","]"]
],[
"start"
],[
"start",
["constant.language","hand"],
["text"," "],
["identifier","clr"],
["text"," "],
["identifier","len"],
["text"," "],
["identifier","time"],
["text"," "],
["keyword","="]
],[
"start",
["text"," "],
["keyword","let"],
["text"," "],
["identifier","angle"],
["text"," "],
["keyword","="],
["text"," "],
["identifier","degrees"],
["text"," "],
["paren.lparen","("],
["constant.numeric","90"],
["text"," "],
["keyword.operator","-"],
["text"," "],
["constant.numeric","6"],
["text"," "],
["keyword.operator","*"],
["text"," "],
["identifier","inSeconds"],
["text"," "],
["identifier","time"],
["paren.rparen",")"]
],[
"start",
["text"," "],
["keyword","in"],
["text"," "],
["identifier","traced"],
["text"," "],
["paren.lparen","("],
["identifier","solid"],
["text"," "],
["identifier","clr"],
["paren.rparen",")"],
["text"," "],
["keyword.operator","<|"],
["text"," "],
["identifier","segment"],
["text"," "],
["paren.lparen","("],
["constant.numeric","0"],
["operator.punctuation",","],
["constant.numeric","0"],
["paren.rparen",")"],
["text"," "],
["paren.lparen","("],
["identifier","len"],
["text"," "],
["keyword.operator","*"],
["text"," "],
["identifier","cos"],
["text"," "],
["identifier","angle"],
["operator.punctuation",","],
["text"," "],
["identifier","len"],
["text"," "],
["keyword.operator","*"],
["text"," "],
["identifier","sin"],
["text"," "],
["identifier","angle"],
["paren.rparen",")"]
]]

View file

@ -0,0 +1,296 @@
[[
"start",
["identifier","O"],
["constant.numeric","003"],
["text"," "],
["comment","(DIAMOND SQUARE)"]
],[
"start",
["comment","N2"],
["text"," "],
["string","G54"],
["text"," "],
["string","G90"],
["text"," "],
["string","G49"],
["text"," "],
["string","G80"]
],[
"start",
["comment","N3"],
["text"," "],
["string","M6"],
["text"," "],
["identifier","T"],
["constant.numeric","1"],
["text"," "],
["comment","(1.ENDMILL)"]
],[
"start",
["comment","N4"],
["text"," "],
["string","M3"],
["text"," "],
["identifier","S"],
["constant.numeric","1800"]
],[
"start",
["comment","N5"],
["text"," "],
["string","G0"],
["text"," "],
["identifier","X"],
["constant.numeric","-.6"],
["text"," "],
["identifier","Y"],
["constant.numeric","2.050"]
],[
"start",
["comment","N6"],
["text"," "],
["string","G43"],
["text"," "],
["identifier","H"],
["constant.numeric","1"],
["text"," "],
["identifier","Z"],
["constant.numeric",".1"]
],[
"start",
["comment","N7"],
["text"," "],
["string","G1"],
["text"," "],
["identifier","Z"],
["constant.numeric","-.3"],
["text"," "],
["identifier","F"],
["constant.numeric","50."]
],[
"start",
["comment","N8"],
["text"," "],
["string","G41"],
["text"," "],
["identifier","D"],
["constant.numeric","1"],
["text"," "],
["identifier","Y"],
["constant.numeric","1.45"]
],[
"start",
["comment","N9"],
["text"," "],
["string","G1"],
["text"," "],
["identifier","X"],
["constant.numeric","0"],
["text"," "],
["identifier","F"],
["constant.numeric","20."]
],[
"start",
["comment","N10"],
["text"," "],
["string","G2"],
["text"," "],
["identifier","J"],
["constant.numeric","-1.45"]
],[
"start",
["comment","(CUTTER COMP CANCEL)"]
],[
"start",
["comment","N11"],
["text"," "],
["string","G1"],
["text"," "],
["identifier","Z"],
["constant.numeric","-.2"],
["text"," "],
["identifier","F"],
["constant.numeric","50."]
],[
"start",
["comment","N12"],
["text"," "],
["identifier","Y"],
["constant.numeric","-.990"]
],[
"start",
["comment","N13"],
["text"," "],
["string","G40"]
],[
"start",
["comment","N14"],
["text"," "],
["string","G0"],
["text"," "],
["identifier","X"],
["constant.numeric","-.6"],
["text"," "],
["identifier","Y"],
["constant.numeric","1.590"]
],[
"start",
["comment","N15"],
["text"," "],
["string","G0"],
["text"," "],
["identifier","Z"],
["constant.numeric",".1"]
],[
"start",
["comment","N16"],
["text"," "],
["string","M5"],
["text"," "],
["string","G49"],
["text"," "],
["string","G28"],
["text"," "],
["string","G91"],
["text"," "],
["identifier","Z"],
["constant.numeric","0"]
],[
"start",
["comment","N17"],
["text"," "],
["identifier","CALL"],
["text"," "],
["identifier","O"],
["constant.numeric","9456"]
],[
"start",
["comment","N18"],
["text"," #"],
["constant.numeric","500"],
["text","="],
["constant.numeric","0.004"]
],[
"start",
["comment","N19"],
["text"," #"],
["constant.numeric","503"],
["text","="],
["paren.lparen","["],
["text","#"],
["constant.numeric","500"],
["text","+#"],
["constant.numeric","501"],
["paren.rparen","]"]
],[
"start",
["comment","N20"],
["text"," "],
["identifier","VC"],
["constant.numeric","45"],
["text","="],
["constant.numeric","0.0006"]
],[
"start",
["identifier","VS"],
["constant.numeric","4"],
["text","="],
["constant.numeric","0.0007"]
],[
"start",
["comment","N21"],
["text"," "],
["string","G90"],
["text"," "],
["string","G10"],
["text"," "],
["identifier","L"],
["constant.numeric","20"],
["text"," "],
["identifier","P"],
["constant.numeric","3"],
["text"," "],
["identifier","X"],
["constant.numeric","5."],
["identifier","Y"],
["constant.numeric","4."],
["text"," "],
["identifier","Z"],
["constant.numeric","6.567"]
],[
"start",
["comment","N22"],
["text"," "],
["string","G0"],
["text"," "],
["identifier","X"],
["constant.numeric","5000"]
],[
"start",
["comment","N23"],
["text"," "],
["identifier","IF"],
["text"," "],
["paren.lparen","["],
["text","#"],
["constant.numeric","1"],
["text"," "],
["identifier","LT"],
["text"," "],
["constant.numeric","0.370"],
["paren.rparen","]"],
["text"," "],
["identifier","GOTO"],
["text"," "],
["constant.numeric","49"]
],[
"start",
["comment","N24"],
["text"," "],
["identifier","X"],
["constant.numeric","-0.678"],
["text"," "],
["identifier","Y"],
["constant.numeric","+.990"]
],[
"start",
["comment","N25"],
["text"," "],
["string","G84.3"],
["text"," "],
["identifier","X"],
["constant.numeric","-0.1"]
],[
"start",
["comment","N26"],
["text"," #"],
["constant.numeric","4"],
["text","=#"],
["constant.numeric","5"],
["text","*"],
["identifier","COS"],
["paren.lparen","["],
["constant.numeric","45"],
["paren.rparen","]"]
],[
"start",
["comment","N27"],
["text"," #"],
["constant.numeric","4"],
["text","=#"],
["constant.numeric","5"],
["text","*"],
["identifier","SIN"],
["paren.lparen","["],
["constant.numeric","45"],
["paren.rparen","]"]
],[
"start",
["comment","N28"],
["text"," "],
["identifier","VZOFZ"],
["text","="],
["constant.numeric","652.9658"]
],[
"start",
["text","%"]
]]

View file

@ -0,0 +1,49 @@
[[
"start",
["punctuation.definition.comment.io","//"],
["comment.line.double-slash.io"," computes factorial of a number"]
],[
"start",
["text","factorial "],
["keyword.operator.io",":="],
["text"," "],
["support.function.io","method"],
["text","(n,"]
],[
"start",
["text"," "],
["keyword.control.io","if"],
["text","(n "],
["keyword.operator.io","=="],
["text"," "],
["constant.numeric.io","0"],
["text",", "],
["keyword.control.io","return"],
["text"," "],
["constant.numeric.io","1"],
["text",")"]
],[
"start",
["text"," res "],
["keyword.operator.io",":="],
["text"," "],
["constant.numeric.io","1"]
],[
"start",
["text"," "],
["support.class.io","Range"],
["text"," "],
["constant.numeric.io","1"],
["text"," "],
["support.function.io","to"],
["text","(n) "],
["keyword.control.io","foreach"],
["text","(i, res "],
["keyword.operator.io","="],
["text"," res "],
["keyword.operator.io","*"],
["text"," i)"]
],[
"start",
["text",")"]
]]

View file

@ -0,0 +1,4 @@
[[
"[\"start\"]",
["support.function","TODO"]
]]

View file

@ -1,4 +1,90 @@
[[
["blockComment","noQstring"],
["comment.start","%{"]
],[
["blockComment","blockComment","blockComment","noQstring"],
["comment.start"," %{"]
],[
["blockComment","blockComment","blockComment","noQstring"],
["comment"," Ace Matlab demo"]
],[
["blockComment","noQstring"],
["comment.end"," %}"]
],[
"noQstring",
["comment.end","%}"]
],[
"start"
],[
"start",
["identifier","TODO"]
["keyword","classdef"],
["text"," "],
["identifier","hello"]
],[
"start",
["text"," "],
["support.function","methods"]
],[
"start",
["text"," "],
["keyword","function"],
["text"," "],
["identifier","greet"],
["paren.lparen","("],
["identifier","this"],
["paren.rparen",")"]
],[
"start",
["text"," "],
["support.function","disp"],
["paren.lparen","("],
["string","'Hello!'"],
["paren.rparen",")"],
["text"," "],
["comment","% say hi"]
],[
"start",
["text"," "],
["keyword","end"]
],[
"start",
["text"," "],
["keyword","end"]
],[
"start",
["keyword","end"]
],[
"noQstring"
],[
"start",
["comment","% transpose "]
],[
"qqstring",
["identifier","a"],
["text"," "],
["keyword.operator","="],
["text"," "],
["paren.lparen","["],
["text"," "],
["string","'x"],
["constant.language.escape","''"],
["string","y'"],
["punctuation.operator",","],
["text"," "],
["string","\"x"],
["constant.language.escape","\\n"],
["string","\\"]
],[
"start",
["string"," y\""],
["punctuation.operator",","],
["text"," "],
["constant.numeric","1"],
["text","' "],
["paren.rparen","]"],
["text","' "],
["keyword.operator","+"],
["text"," "],
["constant.numeric","2"],
["text","'"]
]]

View file

@ -0,0 +1,44 @@
[[
"[\"start\"]",
["keyword","xquery"],
["text"," "],
["keyword","version"],
["text"," "],
["string","\""],
["string","1.0"],
["string","\""],
["text",";"]
],[
"[\"start\"]"
],[
"[\"start\"]",
["keyword","let"],
["text"," "],
["variable","$message"],
["text"," "],
["keyword.operator",":="],
["text"," "],
["string","\""],
["string","Hello World!"],
["string","\""]
],[
"[\"start\",\"StartTag\",\"TagContent\"]",
["keyword","return"],
["text"," "],
["meta.tag","<results"],
["meta.tag",">"]
],[
"[\"start\",\"StartTag\",\"TagContent\"]",
["text"," "],
["meta.tag","<message"],
["meta.tag",">"],
["text","{"],
["variable","$message"],
["text","}"],
["meta.tag","</message>"]
],[
"[\"start\"]",
["meta.tag","</results>"]
],[
"[\"start\"]"
]]

View file

@ -39,7 +39,6 @@ var Range = require("../range").Range;
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Anchor = require("../anchor").Anchor;
var LanguageTools = require("../ext/language_tools");
var Mode = function() {
this.$tokenizer = new JSONiqLexer();
@ -52,14 +51,16 @@ oop.inherits(Mode, TextMode);
(function() {
LanguageTools.addCompleter({
this.completer = {
getCompletions: function(editor, session, pos, prefix, callback) {
if (!session.$worker)
return callback();
session.$worker.emit("complete", { data: { pos: pos, prefix: prefix } });
session.$worker.on("complete", function(e){
callback(null, e.data);
});
}
});
};
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);

View file

@ -39,7 +39,6 @@ var Range = require("../range").Range;
var XQueryBehaviour = require("./behaviour/xquery").XQueryBehaviour;
var CStyleFoldMode = require("./folding/cstyle").FoldMode;
var Anchor = require("../anchor").Anchor;
var LanguageTools = require("../ext/language_tools");
var Mode = function() {
this.$tokenizer = new XQueryLexer();
@ -51,14 +50,16 @@ oop.inherits(Mode, TextMode);
(function() {
LanguageTools.addCompleter({
this.completer = {
getCompletions: function(editor, session, pos, prefix, callback) {
if (!session.$worker)
return callback();
session.$worker.emit("complete", { data: { pos: pos, prefix: prefix } });
session.$worker.on("complete", function(e){
callback(null, e.data);
});
}
});
};
this.getNextLineIndent = function(state, line, tab) {
var indent = this.$getIndent(line);

View file

@ -0,0 +1,7 @@
define(function(require, exports, module) {
"use strict";
exports.snippetText = require("../requirejs/text!./dockerfile.snippets");
exports.scope = "dockerfile";
});

View file

View file

@ -0,0 +1,7 @@
define(function(require, exports, module) {
"use strict";
exports.snippetText = require("../requirejs/text!./.snippets");
exports.scope = "";
});

View file

@ -0,0 +1,7 @@
define(function(require, exports, module) {
"use strict";
exports.snippetText = require("../requirejs/text!./.snippets");
exports.scope = "";
});

View file

@ -0,0 +1,7 @@
define(function(require, exports, module) {
"use strict";
exports.snippetText = require("../requirejs/text!./eiffel.snippets");
exports.scope = "eiffel";
});

View file

7
lib/ace/snippets/elm.js Normal file
View file

@ -0,0 +1,7 @@
define(function(require, exports, module) {
"use strict";
exports.snippetText = require("../requirejs/text!./elm.snippets");
exports.scope = "elm";
});

View file

View file

View file