New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lintingrefactoring #1808

Closed
wants to merge 21 commits into
base: master
from
Commits
Jump to file or symbol
Failed to load files and symbols.
+27 −35
Diff settings

Always

Just for now

Viewing a subset of changes. View all

no longer inject css styles with template

  • Loading branch information...
mikechambers committed Oct 9, 2012
commit a4a08c22673806e56616b500450fecc2027e4605
@@ -1,21 +1,3 @@
<style>
.lint-disabled {
font-size: 1em;
color: #808080; /*@bc-grey*/
}
.lint-errors {
font-size: 1em;
color: #dc322f/*@bc-red*/;
}
.lint-valid {
font-size: 1em;
color: lighten(#b58900, 20%);
/*color: lighten(@bc-yellow, @bc-color-step-size*2);*/
}
</style>
<div class="toolbar simple-toolbar-layout">
<div class="title">{{JSLINT_ERRORS}}</div>
</div>
@@ -14,6 +14,7 @@ define(function (require, exports, module) {
var StatusBar = brackets.getModule("widgets/StatusBar");
var PreferencesManager = brackets.getModule("preferences/PreferencesManager");
var StringUtils = brackets.getModule("utils/StringUtils");
var ExtensionUtils = brackets.getModule("utils/ExtensionUtils");
//todo: readd scrolling code
//todo: save enabled settings and update menu
@@ -88,8 +89,9 @@ define(function (require, exports, module) {
currentErrors = errors;
if (!errors) {
console.log("lint-valid");
StatusBar.updateIndicator(id, true, "lint-valid", Strings.JSLINT_NO_ERRORS);
statusIcon.hide();
//statusIcon.hide();
$(".lint-error-row").off("click", _lintRowClickHandler);
BottomPanel.clearContent();
//BottomPanel.close();
@@ -129,9 +131,10 @@ define(function (require, exports, module) {
var output = $(outputTemplate(context));
BottomPanel.loadContent(output);
statusIcon.show();
//statusIcon.show();
var errorString = (len === 1) ? Strings.JSLINT_ERROR_INFORMATION : StringUtils.format(Strings.JSLINT_ERRORS_INFORMATION, len);
console.log("lint-errors");
StatusBar.updateIndicator(id, true, "lint-errors", errorString);
$(".lint-error-row").on("click", _lintRowClickHandler);
@@ -142,11 +145,6 @@ define(function (require, exports, module) {
*/
function lintDocument(document) {
if (!_isSupportedExtension(document)) {
StatusBar.updateIndicator(id, true, "lint-disabled", Strings.JSLINT_DISABLED);
return;
}
var text = document.getText();
if (ignoreEmptyLines) {
@@ -163,7 +161,16 @@ define(function (require, exports, module) {
}
function _lintCurrentDocument() {
var errors = lintDocument(DocumentManager.getCurrentDocument());
var document = DocumentManager.getCurrentDocument();
if (!_isSupportedExtension(document)) {
console.log("lint-disabled");
StatusBar.updateIndicator(id, true, "lint-disabled", Strings.JSLINT_DISABLED);
return;
}
var errors = lintDocument(document);
_displayLintErrors(errors);
}
@@ -196,6 +203,7 @@ define(function (require, exports, module) {
$(DocumentManager).on(DOCUMENT_SAVED + " " + CURRENT_DOCUMENT_CHANGED, _onDocumentUpdated);
} else {
$(DocumentManager).off(DOCUMENT_SAVED + " " + CURRENT_DOCUMENT_CHANGED, _onDocumentUpdated);
console.log("lint-disabled");
StatusBar.updateIndicator(id, true, "lint-disabled", Strings.JSLINT_DISABLED);
}
}
@@ -207,17 +215,19 @@ define(function (require, exports, module) {
_initMenu();
_initPrefs();
//todo: need to pull preference on whether linting is enabled, and only
//register for this if it is enabled
//todo: can we do this on a module loaded event? and not on initialization?
//do we know document has loaded yet?
if (enabled) {
$(DocumentManager).on(DOCUMENT_SAVED + " " + CURRENT_DOCUMENT_CHANGED, _onDocumentUpdated);
_lintCurrentDocument();
}
AppInit.htmlReady(function () {
StatusBar.addIndicator(id, $("#gold-star"), false);
ExtensionUtils.loadStyleSheet(module, "linter.css");
StatusBar.addIndicator(id, statusIcon, true);
//todo: need to pull preference on whether linting is enabled, and only
//register for this if it is enabled
//todo: can we do this on a module loaded event? and not on initialization?
//do we know document has loaded yet?
if (enabled) {
$(DocumentManager).on(DOCUMENT_SAVED + " " + CURRENT_DOCUMENT_CHANGED, _onDocumentUpdated);
_lintCurrentDocument();
}
});
exports.lintDocument = lintDocument;
ProTip! Use n and p to navigate between commits in a pull request.