-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathreporterHandlers.js
60 lines (48 loc) · 2.09 KB
/
reporterHandlers.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
define(function (require, exports, module) {
"use strict";
var Reporter = require("reporter"),
CodeInspection = brackets.getModule('language/CodeInspection'),
DocumentManager = brackets.getModule("document/DocumentManager");
var reporter = null;
var integration = null;
function ReporterHandler(integration_) {
reporter = new Reporter();
this.reporter = reporter;
integration = integration_;
}
ReporterHandler.prototype.constructor = ReporterHandler;
ReporterHandler.prototype.addGutter = function(editor) {
var cm = editor._codeMirror;
var gutters = cm.getOption("gutters").slice(0);
if (gutters.indexOf("repometric-linterhub-gutter") === -1) {
gutters.unshift("repometric-linterhub-gutter");
cm.setOption("gutters", gutters);
}
}
ReporterHandler.prototype.activateEditor = function(editor) {
if(editor !== null)
editor._codeMirror.on("gutterClick", this.gutterClick);
}
ReporterHandler.prototype.deactivateEditor = function(editor) {
if(editor !== null)
editor._codeMirror.off("gutterClick", this.gutterClick);
}
ReporterHandler.prototype.gutterClick = function(cm, lineIndex, gutterId) {
if (gutterId === "repometric-linterhub-gutter") {
reporter.toggleLineDetails(lineIndex);
$(".repometric-linterhub-message-ignore").click(function(event) {
var line = event.target.getAttribute("line");
var file = event.target.getAttribute("file");
var rule = event.target.getAttribute("rule");
integration.exec("ignore", file, line, rule).then(function(){
if(DocumentManager.getCurrentDocument() !== null)
CodeInspection.inspectFile(DocumentManager.getCurrentDocument().file);
});
});
}
}
ReporterHandler.prototype.handleToggleLineDetails = function() {
this.reporter.toggleLineDetails();
}
module.exports = ReporterHandler;
});