Created
June 20, 2015 10:10
-
-
Save osxpeppermint/99f25a1e2ce8476db801 to your computer and use it in GitHub Desktop.
HaxeLinter - Peppermint $Builtin (in JavaScript)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var HaxeLinter, | |
extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; }, | |
hasProp = {}.hasOwnProperty; | |
HaxeLinter = (function(superClass) { | |
extend(HaxeLinter, superClass); | |
function HaxeLinter() { | |
return HaxeLinter.__super__.constructor.apply(this, arguments); | |
} | |
HaxeLinter.prototype.init = function() { | |
return this.startRun(1000); | |
}; | |
HaxeLinter.prototype.run = function() { | |
var doc; | |
doc = $Document.temp($Editor.content(), "hx", "HaxeLinter"); | |
return $Terminal.execBg("haxe", "--cwd", doc.folder, doc.filename, "--no-output", (function(_this) { | |
return function(intermediate) {}; | |
})(this), (function(_this) { | |
return function(result) { | |
var errors, i, len, line, lines, p; | |
lines = result.split("\n"); | |
errors = []; | |
for (i = 0, len = lines.length; i < len; i++) { | |
line = lines[i]; | |
if (line.trim()) { | |
p = line.replace(doc.filename, "").split(":"); | |
errors.push({ | |
column: 0, | |
row: parseInt(p[1]) - 1, | |
text: p[3].trim(), | |
type: "error" | |
}); | |
} | |
} | |
return $Editor.annotate(errors); | |
}; | |
})(this)); | |
}; | |
HaxeLinter.prototype.halt = function() { | |
return $Editor.annotate(); | |
}; | |
return HaxeLinter; | |
})($Builtin); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment