ll-plus 2.10.24 → 2.10.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/theme-chalk/code-editor-vue3/addon/comment/comment.js +211 -0
- package/theme-chalk/code-editor-vue3/addon/comment/continuecomment.js +114 -0
- package/theme-chalk/code-editor-vue3/addon/dialog/dialog.css +32 -0
- package/theme-chalk/code-editor-vue3/addon/dialog/dialog.js +163 -0
- package/theme-chalk/code-editor-vue3/addon/display/autorefresh.js +47 -0
- package/theme-chalk/code-editor-vue3/addon/display/fullscreen.css +6 -0
- package/theme-chalk/code-editor-vue3/addon/display/fullscreen.js +41 -0
- package/theme-chalk/code-editor-vue3/addon/display/panel.js +133 -0
- package/theme-chalk/code-editor-vue3/addon/display/placeholder.js +78 -0
- package/theme-chalk/code-editor-vue3/addon/display/rulers.js +51 -0
- package/theme-chalk/code-editor-vue3/addon/edit/closebrackets.js +201 -0
- package/theme-chalk/code-editor-vue3/addon/edit/closetag.js +185 -0
- package/theme-chalk/code-editor-vue3/addon/edit/continuelist.js +101 -0
- package/theme-chalk/code-editor-vue3/addon/edit/matchbrackets.js +160 -0
- package/theme-chalk/code-editor-vue3/addon/edit/matchtags.js +66 -0
- package/theme-chalk/code-editor-vue3/addon/edit/trailingspace.js +27 -0
- package/theme-chalk/code-editor-vue3/addon/fold/brace-fold.js +119 -0
- package/theme-chalk/code-editor-vue3/addon/fold/comment-fold.js +59 -0
- package/theme-chalk/code-editor-vue3/addon/fold/foldcode.js +159 -0
- package/theme-chalk/code-editor-vue3/addon/fold/foldgutter.css +20 -0
- package/theme-chalk/code-editor-vue3/addon/fold/foldgutter.js +169 -0
- package/theme-chalk/code-editor-vue3/addon/fold/indent-fold.js +48 -0
- package/theme-chalk/code-editor-vue3/addon/fold/markdown-fold.js +49 -0
- package/theme-chalk/code-editor-vue3/addon/fold/xml-fold.js +184 -0
- package/theme-chalk/code-editor-vue3/addon/hint/anyword-hint.js +41 -0
- package/theme-chalk/code-editor-vue3/addon/hint/css-hint.js +66 -0
- package/theme-chalk/code-editor-vue3/addon/hint/html-hint.js +351 -0
- package/theme-chalk/code-editor-vue3/addon/hint/javascript-hint.js +162 -0
- package/theme-chalk/code-editor-vue3/addon/hint/show-hint.css +37 -0
- package/theme-chalk/code-editor-vue3/addon/hint/show-hint.js +523 -0
- package/theme-chalk/code-editor-vue3/addon/hint/sql-hint.js +304 -0
- package/theme-chalk/code-editor-vue3/addon/hint/xml-hint.js +132 -0
- package/theme-chalk/code-editor-vue3/addon/lint/coffeescript-lint.js +47 -0
- package/theme-chalk/code-editor-vue3/addon/lint/css-lint.js +40 -0
- package/theme-chalk/code-editor-vue3/addon/lint/html-lint.js +59 -0
- package/theme-chalk/code-editor-vue3/addon/lint/javascript-lint.js +65 -0
- package/theme-chalk/code-editor-vue3/addon/lint/json-lint.js +40 -0
- package/theme-chalk/code-editor-vue3/addon/lint/lint.css +79 -0
- package/theme-chalk/code-editor-vue3/addon/lint/lint.js +288 -0
- package/theme-chalk/code-editor-vue3/addon/lint/yaml-lint.js +41 -0
- package/theme-chalk/code-editor-vue3/addon/merge/merge.css +119 -0
- package/theme-chalk/code-editor-vue3/addon/merge/merge.js +1018 -0
- package/theme-chalk/code-editor-vue3/addon/mode/loadmode.js +66 -0
- package/theme-chalk/code-editor-vue3/addon/mode/multiplex.js +136 -0
- package/theme-chalk/code-editor-vue3/addon/mode/multiplex_test.js +49 -0
- package/theme-chalk/code-editor-vue3/addon/mode/overlay.js +90 -0
- package/theme-chalk/code-editor-vue3/addon/mode/simple.js +216 -0
- package/theme-chalk/code-editor-vue3/addon/runmode/colorize.js +40 -0
- package/theme-chalk/code-editor-vue3/addon/runmode/runmode-standalone.js +334 -0
- package/theme-chalk/code-editor-vue3/addon/runmode/runmode.js +76 -0
- package/theme-chalk/code-editor-vue3/addon/runmode/runmode.node.js +329 -0
- package/theme-chalk/code-editor-vue3/addon/scroll/annotatescrollbar.js +128 -0
- package/theme-chalk/code-editor-vue3/addon/scroll/scrollpastend.js +48 -0
- package/theme-chalk/code-editor-vue3/addon/scroll/simplescrollbars.css +66 -0
- package/theme-chalk/code-editor-vue3/addon/scroll/simplescrollbars.js +152 -0
- package/theme-chalk/code-editor-vue3/addon/search/jump-to-line.js +53 -0
- package/theme-chalk/code-editor-vue3/addon/search/match-highlighter.js +167 -0
- package/theme-chalk/code-editor-vue3/addon/search/matchesonscrollbar.css +8 -0
- package/theme-chalk/code-editor-vue3/addon/search/matchesonscrollbar.js +97 -0
- package/theme-chalk/code-editor-vue3/addon/search/search.js +295 -0
- package/theme-chalk/code-editor-vue3/addon/search/searchcursor.js +305 -0
- package/theme-chalk/code-editor-vue3/addon/selection/active-line.js +72 -0
- package/theme-chalk/code-editor-vue3/addon/selection/mark-selection.js +119 -0
- package/theme-chalk/code-editor-vue3/addon/selection/selection-pointer.js +98 -0
- package/theme-chalk/code-editor-vue3/addon/tern/tern.css +87 -0
- package/theme-chalk/code-editor-vue3/addon/tern/tern.js +756 -0
- package/theme-chalk/code-editor-vue3/addon/tern/worker.js +44 -0
- package/theme-chalk/code-editor-vue3/addon/wrap/hardwrap.js +160 -0
- package/theme-chalk/code-editor-vue3/lib/codemirror.css +344 -0
- package/theme-chalk/code-editor-vue3/lib/codemirror.js +9884 -0
- package/theme-chalk/code-editor-vue3/mode/apl/apl.js +174 -0
- package/theme-chalk/code-editor-vue3/mode/asciiarmor/asciiarmor.js +74 -0
- package/theme-chalk/code-editor-vue3/mode/asn.1/asn.1.js +204 -0
- package/theme-chalk/code-editor-vue3/mode/asterisk/asterisk.js +220 -0
- package/theme-chalk/code-editor-vue3/mode/brainfuck/brainfuck.js +85 -0
- package/theme-chalk/code-editor-vue3/mode/clike/clike.js +942 -0
- package/theme-chalk/code-editor-vue3/mode/clojure/clojure.js +293 -0
- package/theme-chalk/code-editor-vue3/mode/cmake/cmake.js +97 -0
- package/theme-chalk/code-editor-vue3/mode/cobol/cobol.js +255 -0
- package/theme-chalk/code-editor-vue3/mode/coffeescript/coffeescript.js +359 -0
- package/theme-chalk/code-editor-vue3/mode/commonlisp/commonlisp.js +125 -0
- package/theme-chalk/code-editor-vue3/mode/crystal/crystal.js +433 -0
- package/theme-chalk/code-editor-vue3/mode/cypher/cypher.js +152 -0
- package/theme-chalk/code-editor-vue3/mode/d/d.js +223 -0
- package/theme-chalk/code-editor-vue3/mode/dart/dart.js +168 -0
- package/theme-chalk/code-editor-vue3/mode/diff/diff.js +47 -0
- package/theme-chalk/code-editor-vue3/mode/django/django.js +356 -0
- package/theme-chalk/code-editor-vue3/mode/dockerfile/dockerfile.js +211 -0
- package/theme-chalk/code-editor-vue3/mode/dtd/dtd.js +142 -0
- package/theme-chalk/code-editor-vue3/mode/dylan/dylan.js +352 -0
- package/theme-chalk/code-editor-vue3/mode/ebnf/ebnf.js +195 -0
- package/theme-chalk/code-editor-vue3/mode/ecl/ecl.js +206 -0
- package/theme-chalk/code-editor-vue3/mode/eiffel/eiffel.js +160 -0
- package/theme-chalk/code-editor-vue3/mode/elm/elm.js +245 -0
- package/theme-chalk/code-editor-vue3/mode/erlang/erlang.js +619 -0
- package/theme-chalk/code-editor-vue3/mode/factor/factor.js +85 -0
- package/theme-chalk/code-editor-vue3/mode/fcl/fcl.js +173 -0
- package/theme-chalk/code-editor-vue3/mode/forth/forth.js +180 -0
- package/theme-chalk/code-editor-vue3/mode/fortran/fortran.js +188 -0
- package/theme-chalk/code-editor-vue3/mode/gas/gas.js +353 -0
- package/theme-chalk/code-editor-vue3/mode/gfm/gfm.js +129 -0
- package/theme-chalk/code-editor-vue3/mode/gherkin/gherkin.js +178 -0
- package/theme-chalk/code-editor-vue3/mode/go/go.js +187 -0
- package/theme-chalk/code-editor-vue3/mode/groovy/groovy.js +245 -0
- package/theme-chalk/code-editor-vue3/mode/haml/haml.js +161 -0
- package/theme-chalk/code-editor-vue3/mode/handlebars/handlebars.js +70 -0
- package/theme-chalk/code-editor-vue3/mode/haskell/haskell.js +268 -0
- package/theme-chalk/code-editor-vue3/mode/haskell-literate/haskell-literate.js +43 -0
- package/theme-chalk/code-editor-vue3/mode/haxe/haxe.js +515 -0
- package/theme-chalk/code-editor-vue3/mode/htmlmixed/htmlmixed.js +153 -0
- package/theme-chalk/code-editor-vue3/mode/http/http.js +113 -0
- package/theme-chalk/code-editor-vue3/mode/idl/idl.js +290 -0
- package/theme-chalk/code-editor-vue3/mode/jinja2/jinja2.js +193 -0
- package/theme-chalk/code-editor-vue3/mode/julia/julia.js +390 -0
- package/theme-chalk/code-editor-vue3/mode/livescript/livescript.js +280 -0
- package/theme-chalk/code-editor-vue3/mode/lua/lua.js +160 -0
- package/theme-chalk/code-editor-vue3/mode/markdown/markdown.js +886 -0
- package/theme-chalk/code-editor-vue3/mode/mathematica/mathematica.js +176 -0
- package/theme-chalk/code-editor-vue3/mode/mbox/mbox.js +129 -0
- package/theme-chalk/code-editor-vue3/mode/meta.js +221 -0
- package/theme-chalk/code-editor-vue3/mode/mirc/mirc.js +193 -0
- package/theme-chalk/code-editor-vue3/mode/mllike/mllike.js +359 -0
- package/theme-chalk/code-editor-vue3/mode/modelica/modelica.js +245 -0
- package/theme-chalk/code-editor-vue3/mode/mscgen/mscgen.js +175 -0
- package/theme-chalk/code-editor-vue3/mode/mumps/mumps.js +148 -0
- package/theme-chalk/code-editor-vue3/mode/nginx/nginx.js +178 -0
- package/theme-chalk/code-editor-vue3/mode/nsis/nsis.js +95 -0
- package/theme-chalk/code-editor-vue3/mode/ntriples/ntriples.js +195 -0
- package/theme-chalk/code-editor-vue3/mode/octave/octave.js +139 -0
- package/theme-chalk/code-editor-vue3/mode/oz/oz.js +252 -0
- package/theme-chalk/code-editor-vue3/mode/pascal/pascal.js +136 -0
- package/theme-chalk/code-editor-vue3/mode/pegjs/pegjs.js +111 -0
- package/theme-chalk/code-editor-vue3/mode/perl/perl.js +836 -0
- package/theme-chalk/code-editor-vue3/mode/php/php.js +234 -0
- package/theme-chalk/code-editor-vue3/mode/pig/pig.js +178 -0
- package/theme-chalk/code-editor-vue3/mode/powershell/powershell.js +398 -0
- package/theme-chalk/code-editor-vue3/mode/properties/properties.js +78 -0
- package/theme-chalk/code-editor-vue3/mode/protobuf/protobuf.js +72 -0
- package/theme-chalk/code-editor-vue3/mode/pug/pug.js +591 -0
- package/theme-chalk/code-editor-vue3/mode/puppet/puppet.js +220 -0
- package/theme-chalk/code-editor-vue3/mode/python/python.js +402 -0
- package/theme-chalk/code-editor-vue3/mode/q/q.js +139 -0
- package/theme-chalk/code-editor-vue3/mode/r/r.js +190 -0
- package/theme-chalk/code-editor-vue3/mode/rpm/changes/index.html +66 -0
- package/theme-chalk/code-editor-vue3/mode/rpm/rpm.js +109 -0
- package/theme-chalk/code-editor-vue3/mode/rst/rst.js +557 -0
- package/theme-chalk/code-editor-vue3/mode/ruby/ruby.js +303 -0
- package/theme-chalk/code-editor-vue3/mode/rust/rust.js +72 -0
- package/theme-chalk/code-editor-vue3/mode/sas/sas.js +303 -0
- package/theme-chalk/code-editor-vue3/mode/sass/sass.js +459 -0
- package/theme-chalk/code-editor-vue3/mode/scheme/scheme.js +284 -0
- package/theme-chalk/code-editor-vue3/mode/shell/shell.js +168 -0
- package/theme-chalk/code-editor-vue3/mode/sieve/sieve.js +193 -0
- package/theme-chalk/code-editor-vue3/mode/slim/slim.js +575 -0
- package/theme-chalk/code-editor-vue3/mode/smalltalk/smalltalk.js +168 -0
- package/theme-chalk/code-editor-vue3/mode/smarty/smarty.js +225 -0
- package/theme-chalk/code-editor-vue3/mode/solr/solr.js +104 -0
- package/theme-chalk/code-editor-vue3/mode/soy/soy.js +665 -0
- package/theme-chalk/code-editor-vue3/mode/sparql/sparql.js +184 -0
- package/theme-chalk/code-editor-vue3/mode/spreadsheet/spreadsheet.js +112 -0
- package/theme-chalk/code-editor-vue3/mode/sql/sql.js +525 -0
- package/theme-chalk/code-editor-vue3/mode/stex/stex.js +264 -0
- package/theme-chalk/code-editor-vue3/mode/stylus/stylus.js +775 -0
- package/theme-chalk/code-editor-vue3/mode/swift/swift.js +221 -0
- package/theme-chalk/code-editor-vue3/mode/tcl/tcl.js +140 -0
- package/theme-chalk/code-editor-vue3/mode/textile/textile.js +469 -0
- package/theme-chalk/code-editor-vue3/mode/tiddlywiki/tiddlywiki.css +14 -0
- package/theme-chalk/code-editor-vue3/mode/tiddlywiki/tiddlywiki.js +308 -0
- package/theme-chalk/code-editor-vue3/mode/tiki/tiki.css +26 -0
- package/theme-chalk/code-editor-vue3/mode/tiki/tiki.js +312 -0
- package/theme-chalk/code-editor-vue3/mode/toml/toml.js +88 -0
- package/theme-chalk/code-editor-vue3/mode/tornado/tornado.js +68 -0
- package/theme-chalk/code-editor-vue3/mode/troff/troff.js +84 -0
- package/theme-chalk/code-editor-vue3/mode/ttcn/ttcn.js +283 -0
- package/theme-chalk/code-editor-vue3/mode/ttcn-cfg/ttcn-cfg.js +214 -0
- package/theme-chalk/code-editor-vue3/mode/turtle/turtle.js +162 -0
- package/theme-chalk/code-editor-vue3/mode/twig/twig.js +141 -0
- package/theme-chalk/code-editor-vue3/mode/vb/vb.js +275 -0
- package/theme-chalk/code-editor-vue3/mode/vbscript/vbscript.js +350 -0
- package/theme-chalk/code-editor-vue3/mode/velocity/velocity.js +202 -0
- package/theme-chalk/code-editor-vue3/mode/verilog/verilog.js +781 -0
- package/theme-chalk/code-editor-vue3/mode/vhdl/vhdl.js +189 -0
- package/theme-chalk/code-editor-vue3/mode/wast/wast.js +132 -0
- package/theme-chalk/code-editor-vue3/mode/webidl/webidl.js +195 -0
- package/theme-chalk/code-editor-vue3/mode/xml/xml.js +417 -0
- package/theme-chalk/code-editor-vue3/mode/xquery/xquery.js +448 -0
- package/theme-chalk/code-editor-vue3/mode/yacas/yacas.js +204 -0
- package/theme-chalk/code-editor-vue3/mode/yaml/yaml.js +120 -0
- package/theme-chalk/code-editor-vue3/mode/yaml-frontmatter/yaml-frontmatter.js +72 -0
- package/theme-chalk/code-editor-vue3/mode/z80/z80.js +116 -0
|
@@ -0,0 +1,304 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
3
|
+
|
|
4
|
+
(function(mod) {
|
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
6
|
+
mod(require("../../lib/codemirror"), require("../../mode/sql/sql"));
|
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
|
8
|
+
define(["../../lib/codemirror", "../../mode/sql/sql"], mod);
|
|
9
|
+
else // Plain browser env
|
|
10
|
+
mod(CodeMirror);
|
|
11
|
+
})(function(CodeMirror) {
|
|
12
|
+
"use strict";
|
|
13
|
+
|
|
14
|
+
var tables;
|
|
15
|
+
var defaultTable;
|
|
16
|
+
var keywords;
|
|
17
|
+
var identifierQuote;
|
|
18
|
+
var CONS = {
|
|
19
|
+
QUERY_DIV: ";",
|
|
20
|
+
ALIAS_KEYWORD: "AS"
|
|
21
|
+
};
|
|
22
|
+
var Pos = CodeMirror.Pos, cmpPos = CodeMirror.cmpPos;
|
|
23
|
+
|
|
24
|
+
function isArray(val) { return Object.prototype.toString.call(val) == "[object Array]" }
|
|
25
|
+
|
|
26
|
+
function getModeConf(editor, field) {
|
|
27
|
+
return editor.getModeAt(editor.getCursor()).config[field] || CodeMirror.resolveMode("text/x-sql")[field]
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function getKeywords(editor) {
|
|
31
|
+
return getModeConf(editor, "keywords") || []
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function getIdentifierQuote(editor) {
|
|
35
|
+
return getModeConf(editor, "identifierQuote") || "`";
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function getText(item) {
|
|
39
|
+
return typeof item == "string" ? item : item.text;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function wrapTable(name, value) {
|
|
43
|
+
if (isArray(value)) value = {columns: value}
|
|
44
|
+
if (!value.text) value.text = name
|
|
45
|
+
return value
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function parseTables(input) {
|
|
49
|
+
var result = {}
|
|
50
|
+
if (isArray(input)) {
|
|
51
|
+
for (var i = input.length - 1; i >= 0; i--) {
|
|
52
|
+
var item = input[i]
|
|
53
|
+
result[getText(item).toUpperCase()] = wrapTable(getText(item), item)
|
|
54
|
+
}
|
|
55
|
+
} else if (input) {
|
|
56
|
+
for (var name in input)
|
|
57
|
+
result[name.toUpperCase()] = wrapTable(name, input[name])
|
|
58
|
+
}
|
|
59
|
+
return result
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function getTable(name) {
|
|
63
|
+
return tables[name.toUpperCase()]
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function shallowClone(object) {
|
|
67
|
+
var result = {};
|
|
68
|
+
for (var key in object) if (object.hasOwnProperty(key))
|
|
69
|
+
result[key] = object[key];
|
|
70
|
+
return result;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function match(string, word) {
|
|
74
|
+
var len = string.length;
|
|
75
|
+
var sub = getText(word).substr(0, len);
|
|
76
|
+
return string.toUpperCase() === sub.toUpperCase();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function addMatches(result, search, wordlist, formatter) {
|
|
80
|
+
if (isArray(wordlist)) {
|
|
81
|
+
for (var i = 0; i < wordlist.length; i++)
|
|
82
|
+
if (match(search, wordlist[i])) result.push(formatter(wordlist[i]))
|
|
83
|
+
} else {
|
|
84
|
+
for (var word in wordlist) if (wordlist.hasOwnProperty(word)) {
|
|
85
|
+
var val = wordlist[word]
|
|
86
|
+
if (!val || val === true)
|
|
87
|
+
val = word
|
|
88
|
+
else
|
|
89
|
+
val = val.displayText ? {text: val.text, displayText: val.displayText} : val.text
|
|
90
|
+
if (match(search, val)) result.push(formatter(val))
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function cleanName(name) {
|
|
96
|
+
// Get rid name from identifierQuote and preceding dot(.)
|
|
97
|
+
if (name.charAt(0) == ".") {
|
|
98
|
+
name = name.substr(1);
|
|
99
|
+
}
|
|
100
|
+
// replace duplicated identifierQuotes with single identifierQuotes
|
|
101
|
+
// and remove single identifierQuotes
|
|
102
|
+
var nameParts = name.split(identifierQuote+identifierQuote);
|
|
103
|
+
for (var i = 0; i < nameParts.length; i++)
|
|
104
|
+
nameParts[i] = nameParts[i].replace(new RegExp(identifierQuote,"g"), "");
|
|
105
|
+
return nameParts.join(identifierQuote);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function insertIdentifierQuotes(name) {
|
|
109
|
+
var nameParts = getText(name).split(".");
|
|
110
|
+
for (var i = 0; i < nameParts.length; i++)
|
|
111
|
+
nameParts[i] = identifierQuote +
|
|
112
|
+
// duplicate identifierQuotes
|
|
113
|
+
nameParts[i].replace(new RegExp(identifierQuote,"g"), identifierQuote+identifierQuote) +
|
|
114
|
+
identifierQuote;
|
|
115
|
+
var escaped = nameParts.join(".");
|
|
116
|
+
if (typeof name == "string") return escaped;
|
|
117
|
+
name = shallowClone(name);
|
|
118
|
+
name.text = escaped;
|
|
119
|
+
return name;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function nameCompletion(cur, token, result, editor) {
|
|
123
|
+
// Try to complete table, column names and return start position of completion
|
|
124
|
+
var useIdentifierQuotes = false;
|
|
125
|
+
var nameParts = [];
|
|
126
|
+
var start = token.start;
|
|
127
|
+
var cont = true;
|
|
128
|
+
while (cont) {
|
|
129
|
+
cont = (token.string.charAt(0) == ".");
|
|
130
|
+
useIdentifierQuotes = useIdentifierQuotes || (token.string.charAt(0) == identifierQuote);
|
|
131
|
+
|
|
132
|
+
start = token.start;
|
|
133
|
+
nameParts.unshift(cleanName(token.string));
|
|
134
|
+
|
|
135
|
+
token = editor.getTokenAt(Pos(cur.line, token.start));
|
|
136
|
+
if (token.string == ".") {
|
|
137
|
+
cont = true;
|
|
138
|
+
token = editor.getTokenAt(Pos(cur.line, token.start));
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Try to complete table names
|
|
143
|
+
var string = nameParts.join(".");
|
|
144
|
+
addMatches(result, string, tables, function(w) {
|
|
145
|
+
return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// Try to complete columns from defaultTable
|
|
149
|
+
addMatches(result, string, defaultTable, function(w) {
|
|
150
|
+
return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
// Try to complete columns
|
|
154
|
+
string = nameParts.pop();
|
|
155
|
+
var table = nameParts.join(".");
|
|
156
|
+
|
|
157
|
+
var alias = false;
|
|
158
|
+
var aliasTable = table;
|
|
159
|
+
// Check if table is available. If not, find table by Alias
|
|
160
|
+
if (!getTable(table)) {
|
|
161
|
+
var oldTable = table;
|
|
162
|
+
table = findTableByAlias(table, editor);
|
|
163
|
+
if (table !== oldTable) alias = true;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
var columns = getTable(table);
|
|
167
|
+
if (columns && columns.columns)
|
|
168
|
+
columns = columns.columns;
|
|
169
|
+
|
|
170
|
+
if (columns) {
|
|
171
|
+
addMatches(result, string, columns, function(w) {
|
|
172
|
+
var tableInsert = table;
|
|
173
|
+
if (alias == true) tableInsert = aliasTable;
|
|
174
|
+
if (typeof w == "string") {
|
|
175
|
+
w = tableInsert + "." + w;
|
|
176
|
+
} else {
|
|
177
|
+
w = shallowClone(w);
|
|
178
|
+
w.text = tableInsert + "." + w.text;
|
|
179
|
+
}
|
|
180
|
+
return useIdentifierQuotes ? insertIdentifierQuotes(w) : w;
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return start;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function eachWord(lineText, f) {
|
|
188
|
+
var words = lineText.split(/\s+/)
|
|
189
|
+
for (var i = 0; i < words.length; i++)
|
|
190
|
+
if (words[i]) f(words[i].replace(/[`,;]/g, ''))
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function findTableByAlias(alias, editor) {
|
|
194
|
+
var doc = editor.doc;
|
|
195
|
+
var fullQuery = doc.getValue();
|
|
196
|
+
var aliasUpperCase = alias.toUpperCase();
|
|
197
|
+
var previousWord = "";
|
|
198
|
+
var table = "";
|
|
199
|
+
var separator = [];
|
|
200
|
+
var validRange = {
|
|
201
|
+
start: Pos(0, 0),
|
|
202
|
+
end: Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).length)
|
|
203
|
+
};
|
|
204
|
+
|
|
205
|
+
//add separator
|
|
206
|
+
var indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV);
|
|
207
|
+
while(indexOfSeparator != -1) {
|
|
208
|
+
separator.push(doc.posFromIndex(indexOfSeparator));
|
|
209
|
+
indexOfSeparator = fullQuery.indexOf(CONS.QUERY_DIV, indexOfSeparator+1);
|
|
210
|
+
}
|
|
211
|
+
separator.unshift(Pos(0, 0));
|
|
212
|
+
separator.push(Pos(editor.lastLine(), editor.getLineHandle(editor.lastLine()).text.length));
|
|
213
|
+
|
|
214
|
+
//find valid range
|
|
215
|
+
var prevItem = null;
|
|
216
|
+
var current = editor.getCursor()
|
|
217
|
+
for (var i = 0; i < separator.length; i++) {
|
|
218
|
+
if ((prevItem == null || cmpPos(current, prevItem) > 0) && cmpPos(current, separator[i]) <= 0) {
|
|
219
|
+
validRange = {start: prevItem, end: separator[i]};
|
|
220
|
+
break;
|
|
221
|
+
}
|
|
222
|
+
prevItem = separator[i];
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
if (validRange.start) {
|
|
226
|
+
var query = doc.getRange(validRange.start, validRange.end, false);
|
|
227
|
+
|
|
228
|
+
for (var i = 0; i < query.length; i++) {
|
|
229
|
+
var lineText = query[i];
|
|
230
|
+
eachWord(lineText, function(word) {
|
|
231
|
+
var wordUpperCase = word.toUpperCase();
|
|
232
|
+
if (wordUpperCase === aliasUpperCase && getTable(previousWord))
|
|
233
|
+
table = previousWord;
|
|
234
|
+
if (wordUpperCase !== CONS.ALIAS_KEYWORD)
|
|
235
|
+
previousWord = word;
|
|
236
|
+
});
|
|
237
|
+
if (table) break;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
return table;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
CodeMirror.registerHelper("hint", "sql", function(editor, options) {
|
|
244
|
+
tables = parseTables(options && options.tables)
|
|
245
|
+
var defaultTableName = options && options.defaultTable;
|
|
246
|
+
var disableKeywords = options && options.disableKeywords;
|
|
247
|
+
defaultTable = defaultTableName && getTable(defaultTableName);
|
|
248
|
+
keywords = getKeywords(editor);
|
|
249
|
+
identifierQuote = getIdentifierQuote(editor);
|
|
250
|
+
|
|
251
|
+
if (defaultTableName && !defaultTable)
|
|
252
|
+
defaultTable = findTableByAlias(defaultTableName, editor);
|
|
253
|
+
|
|
254
|
+
defaultTable = defaultTable || [];
|
|
255
|
+
|
|
256
|
+
if (defaultTable.columns)
|
|
257
|
+
defaultTable = defaultTable.columns;
|
|
258
|
+
|
|
259
|
+
var cur = editor.getCursor();
|
|
260
|
+
var result = [];
|
|
261
|
+
var token = editor.getTokenAt(cur), start, end, search;
|
|
262
|
+
if (token.end > cur.ch) {
|
|
263
|
+
token.end = cur.ch;
|
|
264
|
+
token.string = token.string.slice(0, cur.ch - token.start);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
if (token.string.match(/^[.`"'\w@][\w$#]*$/g)) {
|
|
268
|
+
search = token.string;
|
|
269
|
+
start = token.start;
|
|
270
|
+
end = token.end;
|
|
271
|
+
} else {
|
|
272
|
+
start = end = cur.ch;
|
|
273
|
+
search = "";
|
|
274
|
+
}
|
|
275
|
+
if (search.charAt(0) == "." || search.charAt(0) == identifierQuote) {
|
|
276
|
+
start = nameCompletion(cur, token, result, editor);
|
|
277
|
+
} else {
|
|
278
|
+
var objectOrClass = function(w, className) {
|
|
279
|
+
if (typeof w === "object") {
|
|
280
|
+
w.className = className;
|
|
281
|
+
} else {
|
|
282
|
+
w = { text: w, className: className };
|
|
283
|
+
}
|
|
284
|
+
return w;
|
|
285
|
+
};
|
|
286
|
+
addMatches(result, search, defaultTable, function(w) {
|
|
287
|
+
return objectOrClass(w, "CodeMirror-hint-table CodeMirror-hint-default-table");
|
|
288
|
+
});
|
|
289
|
+
addMatches(
|
|
290
|
+
result,
|
|
291
|
+
search,
|
|
292
|
+
tables, function(w) {
|
|
293
|
+
return objectOrClass(w, "CodeMirror-hint-table");
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
if (!disableKeywords)
|
|
297
|
+
addMatches(result, search, keywords, function(w) {
|
|
298
|
+
return objectOrClass(w.toUpperCase(), "CodeMirror-hint-keyword");
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
return {list: result, from: Pos(cur.line, start), to: Pos(cur.line, end)};
|
|
303
|
+
});
|
|
304
|
+
});
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
3
|
+
|
|
4
|
+
(function(mod) {
|
|
5
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
6
|
+
mod(require("../../lib/codemirror"));
|
|
7
|
+
else if (typeof define == "function" && define.amd) // AMD
|
|
8
|
+
define(["../../lib/codemirror"], mod);
|
|
9
|
+
else // Plain browser env
|
|
10
|
+
mod(CodeMirror);
|
|
11
|
+
})(function(CodeMirror) {
|
|
12
|
+
"use strict";
|
|
13
|
+
|
|
14
|
+
var Pos = CodeMirror.Pos;
|
|
15
|
+
|
|
16
|
+
function matches(hint, typed, matchInMiddle) {
|
|
17
|
+
if (matchInMiddle) return hint.indexOf(typed) >= 0;
|
|
18
|
+
else return hint.lastIndexOf(typed, 0) == 0;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
function getHints(cm, options) {
|
|
22
|
+
var tags = options && options.schemaInfo;
|
|
23
|
+
var quote = (options && options.quoteChar) || '"';
|
|
24
|
+
var matchInMiddle = options && options.matchInMiddle;
|
|
25
|
+
if (!tags) return;
|
|
26
|
+
var cur = cm.getCursor(), token = cm.getTokenAt(cur);
|
|
27
|
+
if (token.end > cur.ch) {
|
|
28
|
+
token.end = cur.ch;
|
|
29
|
+
token.string = token.string.slice(0, cur.ch - token.start);
|
|
30
|
+
}
|
|
31
|
+
var inner = CodeMirror.innerMode(cm.getMode(), token.state);
|
|
32
|
+
if (!inner.mode.xmlCurrentTag) return
|
|
33
|
+
var result = [], replaceToken = false, prefix;
|
|
34
|
+
var tag = /\btag\b/.test(token.type) && !/>$/.test(token.string);
|
|
35
|
+
var tagName = tag && /^\w/.test(token.string), tagStart;
|
|
36
|
+
|
|
37
|
+
if (tagName) {
|
|
38
|
+
var before = cm.getLine(cur.line).slice(Math.max(0, token.start - 2), token.start);
|
|
39
|
+
var tagType = /<\/$/.test(before) ? "close" : /<$/.test(before) ? "open" : null;
|
|
40
|
+
if (tagType) tagStart = token.start - (tagType == "close" ? 2 : 1);
|
|
41
|
+
} else if (tag && token.string == "<") {
|
|
42
|
+
tagType = "open";
|
|
43
|
+
} else if (tag && token.string == "</") {
|
|
44
|
+
tagType = "close";
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var tagInfo = inner.mode.xmlCurrentTag(inner.state)
|
|
48
|
+
if (!tag && !tagInfo || tagType) {
|
|
49
|
+
if (tagName)
|
|
50
|
+
prefix = token.string;
|
|
51
|
+
replaceToken = tagType;
|
|
52
|
+
var context = inner.mode.xmlCurrentContext ? inner.mode.xmlCurrentContext(inner.state) : []
|
|
53
|
+
var inner = context.length && context[context.length - 1]
|
|
54
|
+
var curTag = inner && tags[inner]
|
|
55
|
+
var childList = inner ? curTag && curTag.children : tags["!top"];
|
|
56
|
+
if (childList && tagType != "close") {
|
|
57
|
+
for (var i = 0; i < childList.length; ++i) if (!prefix || matches(childList[i], prefix, matchInMiddle))
|
|
58
|
+
result.push("<" + childList[i]);
|
|
59
|
+
} else if (tagType != "close") {
|
|
60
|
+
for (var name in tags)
|
|
61
|
+
if (tags.hasOwnProperty(name) && name != "!top" && name != "!attrs" && (!prefix || matches(name, prefix, matchInMiddle)))
|
|
62
|
+
result.push("<" + name);
|
|
63
|
+
}
|
|
64
|
+
if (inner && (!prefix || tagType == "close" && matches(inner, prefix, matchInMiddle)))
|
|
65
|
+
result.push("</" + inner + ">");
|
|
66
|
+
} else {
|
|
67
|
+
// Attribute completion
|
|
68
|
+
var curTag = tagInfo && tags[tagInfo.name], attrs = curTag && curTag.attrs;
|
|
69
|
+
var globalAttrs = tags["!attrs"];
|
|
70
|
+
if (!attrs && !globalAttrs) return;
|
|
71
|
+
if (!attrs) {
|
|
72
|
+
attrs = globalAttrs;
|
|
73
|
+
} else if (globalAttrs) { // Combine tag-local and global attributes
|
|
74
|
+
var set = {};
|
|
75
|
+
for (var nm in globalAttrs) if (globalAttrs.hasOwnProperty(nm)) set[nm] = globalAttrs[nm];
|
|
76
|
+
for (var nm in attrs) if (attrs.hasOwnProperty(nm)) set[nm] = attrs[nm];
|
|
77
|
+
attrs = set;
|
|
78
|
+
}
|
|
79
|
+
if (token.type == "string" || token.string == "=") { // A value
|
|
80
|
+
var before = cm.getRange(Pos(cur.line, Math.max(0, cur.ch - 60)),
|
|
81
|
+
Pos(cur.line, token.type == "string" ? token.start : token.end));
|
|
82
|
+
var atName = before.match(/([^\s\u00a0=<>\"\']+)=$/), atValues;
|
|
83
|
+
if (!atName || !attrs.hasOwnProperty(atName[1]) || !(atValues = attrs[atName[1]])) return;
|
|
84
|
+
if (typeof atValues == 'function') atValues = atValues.call(this, cm); // Functions can be used to supply values for autocomplete widget
|
|
85
|
+
if (token.type == "string") {
|
|
86
|
+
prefix = token.string;
|
|
87
|
+
var n = 0;
|
|
88
|
+
if (/['"]/.test(token.string.charAt(0))) {
|
|
89
|
+
quote = token.string.charAt(0);
|
|
90
|
+
prefix = token.string.slice(1);
|
|
91
|
+
n++;
|
|
92
|
+
}
|
|
93
|
+
var len = token.string.length;
|
|
94
|
+
if (/['"]/.test(token.string.charAt(len - 1))) {
|
|
95
|
+
quote = token.string.charAt(len - 1);
|
|
96
|
+
prefix = token.string.substr(n, len - 2);
|
|
97
|
+
}
|
|
98
|
+
if (n) { // an opening quote
|
|
99
|
+
var line = cm.getLine(cur.line);
|
|
100
|
+
if (line.length > token.end && line.charAt(token.end) == quote) token.end++; // include a closing quote
|
|
101
|
+
}
|
|
102
|
+
replaceToken = true;
|
|
103
|
+
}
|
|
104
|
+
var returnHintsFromAtValues = function(atValues) {
|
|
105
|
+
if (atValues)
|
|
106
|
+
for (var i = 0; i < atValues.length; ++i) if (!prefix || matches(atValues[i], prefix, matchInMiddle))
|
|
107
|
+
result.push(quote + atValues[i] + quote);
|
|
108
|
+
return returnHints();
|
|
109
|
+
};
|
|
110
|
+
if (atValues && atValues.then) return atValues.then(returnHintsFromAtValues);
|
|
111
|
+
return returnHintsFromAtValues(atValues);
|
|
112
|
+
} else { // An attribute name
|
|
113
|
+
if (token.type == "attribute") {
|
|
114
|
+
prefix = token.string;
|
|
115
|
+
replaceToken = true;
|
|
116
|
+
}
|
|
117
|
+
for (var attr in attrs) if (attrs.hasOwnProperty(attr) && (!prefix || matches(attr, prefix, matchInMiddle)))
|
|
118
|
+
result.push(attr);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
function returnHints() {
|
|
122
|
+
return {
|
|
123
|
+
list: result,
|
|
124
|
+
from: replaceToken ? Pos(cur.line, tagStart == null ? token.start : tagStart) : cur,
|
|
125
|
+
to: replaceToken ? Pos(cur.line, token.end) : cur
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
return returnHints();
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
CodeMirror.registerHelper("hint", "xml", getHints);
|
|
132
|
+
});
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
3
|
+
|
|
4
|
+
// Depends on coffeelint.js from http://www.coffeelint.org/js/coffeelint.js
|
|
5
|
+
|
|
6
|
+
// declare global: coffeelint
|
|
7
|
+
|
|
8
|
+
(function(mod) {
|
|
9
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
10
|
+
mod(require("../../lib/codemirror"));
|
|
11
|
+
else if (typeof define == "function" && define.amd) // AMD
|
|
12
|
+
define(["../../lib/codemirror"], mod);
|
|
13
|
+
else // Plain browser env
|
|
14
|
+
mod(CodeMirror);
|
|
15
|
+
})(function(CodeMirror) {
|
|
16
|
+
"use strict";
|
|
17
|
+
|
|
18
|
+
CodeMirror.registerHelper("lint", "coffeescript", function(text) {
|
|
19
|
+
var found = [];
|
|
20
|
+
if (!window.coffeelint) {
|
|
21
|
+
if (window.console) {
|
|
22
|
+
window.console.error("Error: window.coffeelint not defined, CodeMirror CoffeeScript linting cannot run.");
|
|
23
|
+
}
|
|
24
|
+
return found;
|
|
25
|
+
}
|
|
26
|
+
var parseError = function(err) {
|
|
27
|
+
var loc = err.lineNumber;
|
|
28
|
+
found.push({from: CodeMirror.Pos(loc-1, 0),
|
|
29
|
+
to: CodeMirror.Pos(loc, 0),
|
|
30
|
+
severity: err.level,
|
|
31
|
+
message: err.message});
|
|
32
|
+
};
|
|
33
|
+
try {
|
|
34
|
+
var res = coffeelint.lint(text);
|
|
35
|
+
for(var i = 0; i < res.length; i++) {
|
|
36
|
+
parseError(res[i]);
|
|
37
|
+
}
|
|
38
|
+
} catch(e) {
|
|
39
|
+
found.push({from: CodeMirror.Pos(e.location.first_line, 0),
|
|
40
|
+
to: CodeMirror.Pos(e.location.last_line, e.location.last_column),
|
|
41
|
+
severity: 'error',
|
|
42
|
+
message: e.message});
|
|
43
|
+
}
|
|
44
|
+
return found;
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
3
|
+
|
|
4
|
+
// Depends on csslint.js from https://github.com/stubbornella/csslint
|
|
5
|
+
|
|
6
|
+
// declare global: CSSLint
|
|
7
|
+
|
|
8
|
+
(function(mod) {
|
|
9
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
10
|
+
mod(require("../../lib/codemirror"));
|
|
11
|
+
else if (typeof define == "function" && define.amd) // AMD
|
|
12
|
+
define(["../../lib/codemirror"], mod);
|
|
13
|
+
else // Plain browser env
|
|
14
|
+
mod(CodeMirror);
|
|
15
|
+
})(function(CodeMirror) {
|
|
16
|
+
"use strict";
|
|
17
|
+
|
|
18
|
+
CodeMirror.registerHelper("lint", "css", function(text, options) {
|
|
19
|
+
var found = [];
|
|
20
|
+
if (!window.CSSLint) {
|
|
21
|
+
if (window.console) {
|
|
22
|
+
window.console.error("Error: window.CSSLint not defined, CodeMirror CSS linting cannot run.");
|
|
23
|
+
}
|
|
24
|
+
return found;
|
|
25
|
+
}
|
|
26
|
+
var results = CSSLint.verify(text, options), messages = results.messages, message = null;
|
|
27
|
+
for ( var i = 0; i < messages.length; i++) {
|
|
28
|
+
message = messages[i];
|
|
29
|
+
var startLine = message.line -1, endLine = message.line -1, startCol = message.col -1, endCol = message.col;
|
|
30
|
+
found.push({
|
|
31
|
+
from: CodeMirror.Pos(startLine, startCol),
|
|
32
|
+
to: CodeMirror.Pos(endLine, endCol),
|
|
33
|
+
message: message.message,
|
|
34
|
+
severity : message.type
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
return found;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
});
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
3
|
+
|
|
4
|
+
// Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js
|
|
5
|
+
|
|
6
|
+
// declare global: HTMLHint
|
|
7
|
+
|
|
8
|
+
(function(mod) {
|
|
9
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
10
|
+
mod(require("../../lib/codemirror"), require("htmlhint"));
|
|
11
|
+
else if (typeof define == "function" && define.amd) // AMD
|
|
12
|
+
define(["../../lib/codemirror", "htmlhint"], mod);
|
|
13
|
+
else // Plain browser env
|
|
14
|
+
mod(CodeMirror, window.HTMLHint);
|
|
15
|
+
})(function(CodeMirror, HTMLHint) {
|
|
16
|
+
"use strict";
|
|
17
|
+
|
|
18
|
+
var defaultRules = {
|
|
19
|
+
"tagname-lowercase": true,
|
|
20
|
+
"attr-lowercase": true,
|
|
21
|
+
"attr-value-double-quotes": true,
|
|
22
|
+
"doctype-first": false,
|
|
23
|
+
"tag-pair": true,
|
|
24
|
+
"spec-char-escape": true,
|
|
25
|
+
"id-unique": true,
|
|
26
|
+
"src-not-empty": true,
|
|
27
|
+
"attr-no-duplication": true
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
CodeMirror.registerHelper("lint", "html", function(text, options) {
|
|
31
|
+
var found = [];
|
|
32
|
+
if (HTMLHint && !HTMLHint.verify) {
|
|
33
|
+
if(typeof HTMLHint.default !== 'undefined') {
|
|
34
|
+
HTMLHint = HTMLHint.default;
|
|
35
|
+
} else {
|
|
36
|
+
HTMLHint = HTMLHint.HTMLHint;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
if (!HTMLHint) HTMLHint = window.HTMLHint;
|
|
40
|
+
if (!HTMLHint) {
|
|
41
|
+
if (window.console) {
|
|
42
|
+
window.console.error("Error: HTMLHint not found, not defined on window, or not available through define/require, CodeMirror HTML linting cannot run.");
|
|
43
|
+
}
|
|
44
|
+
return found;
|
|
45
|
+
}
|
|
46
|
+
var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
|
|
47
|
+
for (var i = 0; i < messages.length; i++) {
|
|
48
|
+
var message = messages[i];
|
|
49
|
+
var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;
|
|
50
|
+
found.push({
|
|
51
|
+
from: CodeMirror.Pos(startLine, startCol),
|
|
52
|
+
to: CodeMirror.Pos(endLine, endCol),
|
|
53
|
+
message: message.message,
|
|
54
|
+
severity : message.type
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return found;
|
|
58
|
+
});
|
|
59
|
+
});
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
3
|
+
|
|
4
|
+
// Depends on jshint.js from https://github.com/jshint/jshint
|
|
5
|
+
|
|
6
|
+
(function(mod) {
|
|
7
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
8
|
+
mod(require("../../lib/codemirror"));
|
|
9
|
+
else if (typeof define == "function" && define.amd) // AMD
|
|
10
|
+
define(["../../lib/codemirror"], mod);
|
|
11
|
+
else // Plain browser env
|
|
12
|
+
mod(CodeMirror);
|
|
13
|
+
})(function(CodeMirror) {
|
|
14
|
+
"use strict";
|
|
15
|
+
// declare global: JSHINT
|
|
16
|
+
|
|
17
|
+
function validator(text, options) {
|
|
18
|
+
if (!window.JSHINT) {
|
|
19
|
+
if (window.console) {
|
|
20
|
+
window.console.error("Error: window.JSHINT not defined, CodeMirror JavaScript linting cannot run.");
|
|
21
|
+
}
|
|
22
|
+
return [];
|
|
23
|
+
}
|
|
24
|
+
if (!options.indent) // JSHint error.character actually is a column index, this fixes underlining on lines using tabs for indentation
|
|
25
|
+
options.indent = 1; // JSHint default value is 4
|
|
26
|
+
JSHINT(text, options, options.globals);
|
|
27
|
+
var errors = JSHINT.data().errors, result = [];
|
|
28
|
+
if (errors) parseErrors(errors, result);
|
|
29
|
+
return result;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
CodeMirror.registerHelper("lint", "javascript", validator);
|
|
33
|
+
|
|
34
|
+
function parseErrors(errors, output) {
|
|
35
|
+
for ( var i = 0; i < errors.length; i++) {
|
|
36
|
+
var error = errors[i];
|
|
37
|
+
if (error) {
|
|
38
|
+
if (error.line <= 0) {
|
|
39
|
+
if (window.console) {
|
|
40
|
+
window.console.warn("Cannot display JSHint error (invalid line " + error.line + ")", error);
|
|
41
|
+
}
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
var start = error.character - 1, end = start + 1;
|
|
46
|
+
if (error.evidence) {
|
|
47
|
+
var index = error.evidence.substring(start).search(/.\b/);
|
|
48
|
+
if (index > -1) {
|
|
49
|
+
end += index;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
// Convert to format expected by validation service
|
|
54
|
+
var hint = {
|
|
55
|
+
message: error.reason,
|
|
56
|
+
severity: error.code ? (error.code.startsWith('W') ? "warning" : "error") : "error",
|
|
57
|
+
from: CodeMirror.Pos(error.line - 1, start),
|
|
58
|
+
to: CodeMirror.Pos(error.line - 1, end)
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
output.push(hint);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
// CodeMirror, copyright (c) by Marijn Haverbeke and others
|
|
2
|
+
// Distributed under an MIT license: https://codemirror.net/5/LICENSE
|
|
3
|
+
|
|
4
|
+
// Depends on jsonlint.js from https://github.com/zaach/jsonlint
|
|
5
|
+
|
|
6
|
+
// declare global: jsonlint
|
|
7
|
+
|
|
8
|
+
(function(mod) {
|
|
9
|
+
if (typeof exports == "object" && typeof module == "object") // CommonJS
|
|
10
|
+
mod(require("../../lib/codemirror"));
|
|
11
|
+
else if (typeof define == "function" && define.amd) // AMD
|
|
12
|
+
define(["../../lib/codemirror"], mod);
|
|
13
|
+
else // Plain browser env
|
|
14
|
+
mod(CodeMirror);
|
|
15
|
+
})(function(CodeMirror) {
|
|
16
|
+
"use strict";
|
|
17
|
+
|
|
18
|
+
CodeMirror.registerHelper("lint", "json", function(text) {
|
|
19
|
+
var found = [];
|
|
20
|
+
if (!window.jsonlint) {
|
|
21
|
+
if (window.console) {
|
|
22
|
+
window.console.error("Error: window.jsonlint not defined, CodeMirror JSON linting cannot run.");
|
|
23
|
+
}
|
|
24
|
+
return found;
|
|
25
|
+
}
|
|
26
|
+
// for jsonlint's web dist jsonlint is exported as an object with a single property parser, of which parseError
|
|
27
|
+
// is a subproperty
|
|
28
|
+
var jsonlint = window.jsonlint.parser || window.jsonlint
|
|
29
|
+
jsonlint.parseError = function(str, hash) {
|
|
30
|
+
var loc = hash.loc;
|
|
31
|
+
found.push({from: CodeMirror.Pos(loc.first_line - 1, loc.first_column),
|
|
32
|
+
to: CodeMirror.Pos(loc.last_line - 1, loc.last_column),
|
|
33
|
+
message: str});
|
|
34
|
+
};
|
|
35
|
+
try { jsonlint.parse(text); }
|
|
36
|
+
catch(e) {}
|
|
37
|
+
return found;
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
});
|