summaryrefslogtreecommitdiff
path: root/public/vendor/codemirror/addon/lint
diff options
context:
space:
mode:
Diffstat (limited to 'public/vendor/codemirror/addon/lint')
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/coffeescript-lint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/css-lint.js0
-rw-r--r--public/vendor/codemirror/addon/lint/html-lint.js46
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/javascript-lint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/json-lint.js0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/lint.css0
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/lint.js34
-rw-r--r--[-rwxr-xr-x]public/vendor/codemirror/addon/lint/yaml-lint.js0
8 files changed, 75 insertions, 5 deletions
diff --git a/public/vendor/codemirror/addon/lint/coffeescript-lint.js b/public/vendor/codemirror/addon/lint/coffeescript-lint.js
index 7e39428f..7e39428f 100755..100644
--- a/public/vendor/codemirror/addon/lint/coffeescript-lint.js
+++ b/public/vendor/codemirror/addon/lint/coffeescript-lint.js
diff --git a/public/vendor/codemirror/addon/lint/css-lint.js b/public/vendor/codemirror/addon/lint/css-lint.js
index 1f61b479..1f61b479 100755..100644
--- a/public/vendor/codemirror/addon/lint/css-lint.js
+++ b/public/vendor/codemirror/addon/lint/css-lint.js
diff --git a/public/vendor/codemirror/addon/lint/html-lint.js b/public/vendor/codemirror/addon/lint/html-lint.js
new file mode 100644
index 00000000..1e841709
--- /dev/null
+++ b/public/vendor/codemirror/addon/lint/html-lint.js
@@ -0,0 +1,46 @@
+// CodeMirror, copyright (c) by Marijn Haverbeke and others
+// Distributed under an MIT license: http://codemirror.net/LICENSE
+
+// Depends on htmlhint.js from http://htmlhint.com/js/htmlhint.js
+
+// declare global: HTMLHint
+
+(function(mod) {
+ if (typeof exports == "object" && typeof module == "object") // CommonJS
+ mod(require("../../lib/codemirror"), require("htmlhint"));
+ else if (typeof define == "function" && define.amd) // AMD
+ define(["../../lib/codemirror", "htmlhint"], mod);
+ else // Plain browser env
+ mod(CodeMirror);
+})(function(CodeMirror) {
+ "use strict";
+
+ var defaultRules = {
+ "tagname-lowercase": true,
+ "attr-lowercase": true,
+ "attr-value-double-quotes": true,
+ "doctype-first": false,
+ "tag-pair": true,
+ "spec-char-escape": true,
+ "id-unique": true,
+ "src-not-empty": true,
+ "attr-no-duplication": true
+ };
+
+ CodeMirror.registerHelper("lint", "html", function(text, options) {
+ var found = [];
+ if (!window.HTMLHint) return found;
+ var messages = HTMLHint.verify(text, options && options.rules || defaultRules);
+ for (var i = 0; i < messages.length; i++) {
+ var message = messages[i];
+ var startLine = message.line - 1, endLine = message.line - 1, startCol = message.col - 1, endCol = message.col;
+ found.push({
+ from: CodeMirror.Pos(startLine, startCol),
+ to: CodeMirror.Pos(endLine, endCol),
+ message: message.message,
+ severity : message.type
+ });
+ }
+ return found;
+ });
+});
diff --git a/public/vendor/codemirror/addon/lint/javascript-lint.js b/public/vendor/codemirror/addon/lint/javascript-lint.js
index d4f2ae9a..d4f2ae9a 100755..100644
--- a/public/vendor/codemirror/addon/lint/javascript-lint.js
+++ b/public/vendor/codemirror/addon/lint/javascript-lint.js
diff --git a/public/vendor/codemirror/addon/lint/json-lint.js b/public/vendor/codemirror/addon/lint/json-lint.js
index 9dbb616b..9dbb616b 100755..100644
--- a/public/vendor/codemirror/addon/lint/json-lint.js
+++ b/public/vendor/codemirror/addon/lint/json-lint.js
diff --git a/public/vendor/codemirror/addon/lint/lint.css b/public/vendor/codemirror/addon/lint/lint.css
index 414a9a0e..414a9a0e 100755..100644
--- a/public/vendor/codemirror/addon/lint/lint.css
+++ b/public/vendor/codemirror/addon/lint/lint.css
diff --git a/public/vendor/codemirror/addon/lint/lint.js b/public/vendor/codemirror/addon/lint/lint.js
index 3eea203c..5afe49d0 100755..100644
--- a/public/vendor/codemirror/addon/lint/lint.js
+++ b/public/vendor/codemirror/addon/lint/lint.js
@@ -61,6 +61,7 @@
this.timeout = null;
this.hasGutter = hasGutter;
this.onMouseOver = function(e) { onMouseOver(cm, e); };
+ this.waitingFor = 0
}
function parseOptions(_cm, options) {
@@ -115,15 +116,32 @@
return tip;
}
+ function lintAsync(cm, getAnnotations, passOptions) {
+ var state = cm.state.lint
+ var id = ++state.waitingFor
+ function abort() {
+ id = -1
+ cm.off("change", abort)
+ }
+ cm.on("change", abort)
+ getAnnotations(cm.getValue(), function(annotations, arg2) {
+ cm.off("change", abort)
+ if (state.waitingFor != id) return
+ if (arg2 && annotations instanceof CodeMirror) annotations = arg2
+ updateLinting(cm, annotations)
+ }, passOptions, cm);
+ }
+
function startLinting(cm) {
var state = cm.state.lint, options = state.options;
var passOptions = options.options || options; // Support deprecated passing of `options` property in options
var getAnnotations = options.getAnnotations || cm.getHelper(CodeMirror.Pos(0, 0), "lint");
if (!getAnnotations) return;
- if (options.async || getAnnotations.async)
- getAnnotations(cm.getValue(), updateLinting, passOptions, cm);
- else
+ if (options.async || getAnnotations.async) {
+ lintAsync(cm, getAnnotations, passOptions)
+ } else {
updateLinting(cm, getAnnotations(cm.getValue(), passOptions, cm));
+ }
}
function updateLinting(cm, annotationsNotSorted) {
@@ -187,7 +205,8 @@
CodeMirror.defineOption("lint", false, function(cm, val, old) {
if (old && old != CodeMirror.Init) {
clearMarks(cm);
- cm.off("change", onChange);
+ if (cm.state.lint.options.lintOnChange !== false)
+ cm.off("change", onChange);
CodeMirror.off(cm.getWrapperElement(), "mouseover", cm.state.lint.onMouseOver);
clearTimeout(cm.state.lint.timeout);
delete cm.state.lint;
@@ -197,11 +216,16 @@
var gutters = cm.getOption("gutters"), hasLintGutter = false;
for (var i = 0; i < gutters.length; ++i) if (gutters[i] == GUTTER_ID) hasLintGutter = true;
var state = cm.state.lint = new LintState(cm, parseOptions(cm, val), hasLintGutter);
- cm.on("change", onChange);
+ if (state.options.lintOnChange !== false)
+ cm.on("change", onChange);
if (state.options.tooltips != false)
CodeMirror.on(cm.getWrapperElement(), "mouseover", state.onMouseOver);
startLinting(cm);
}
});
+
+ CodeMirror.defineExtension("performLint", function() {
+ if (this.state.lint) startLinting(this);
+ });
});
diff --git a/public/vendor/codemirror/addon/lint/yaml-lint.js b/public/vendor/codemirror/addon/lint/yaml-lint.js
index 3f77e525..3f77e525 100755..100644
--- a/public/vendor/codemirror/addon/lint/yaml-lint.js
+++ b/public/vendor/codemirror/addon/lint/yaml-lint.js