ソースを参照

HUE-7290 [editor] Make it possible to clear ignored syntax errors

Johan Ahlen 8 年 前
コミット
023abb2

+ 9 - 1
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -3636,7 +3636,7 @@
         self.aceSqlSyntaxWorker.onmessage = function(e) {
           var suppressedRules = ApiHelper.getInstance().getFromTotalStorage('hue.syntax.checker', 'suppressedRules', {});
 
-          if (e.data.syntaxError && !suppressedRules[self.snippet.id() + e.data.syntaxError.ruleId]) {
+          if (e.data.syntaxError && e.data.syntaxError.ruleId && !suppressedRules[e.data.syntaxError.ruleId.toString() + e.data.syntaxError.text.toLowerCase()]) {
             if (self.snippet.positionStatement() && SqlUtils.locationEquals(e.data.statementLocation, self.snippet.positionStatement().location)) {
               self.snippet.positionStatement().syntaxError = true;
             }
@@ -4109,6 +4109,14 @@
         editor.customMenuOptions.getErrorHighlighting = function () {
           return errorHighlightingEnabled;
         };
+        editor.customMenuOptions.setClearIgnoredSyntaxChecks = function (flag) {
+          ApiHelper.getInstance().setInTotalStorage('hue.syntax.checker', 'suppressedRules', {});
+          $('#setClearIgnoredSyntaxChecks').hide();
+          $('#setClearIgnoredSyntaxChecks').before('<div style="margin-top:5px;float:right;">done</div>');
+        };
+        editor.customMenuOptions.getClearIgnoredSyntaxChecks = function () {
+          return false;
+        }
       }
 
       $.extend(editorOptions, aceOptions);

+ 11 - 8
desktop/core/src/desktop/templates/sql_syntax_dropdown.mako

@@ -49,22 +49,25 @@ from django.utils.translation import ugettext as _
         var expected = $.map(params.data.expected, function (expected) {
           return expected.text;
         });
-        if (expected.length > 0) {
+
+        // TODO: Allow suppression of unknown columns etc.
+        if (params.data.ruleId) {
+          if (expected.length > 0) {
+            expected.push({
+              divider: true
+            });
+          }
           expected.push({
-            divider: true
+            label: SyntaxCheckerGlobals.i18n.suppressError,
+            suppressRule: params.data.ruleId.toString() + params.data.text.toLowerCase()
           });
         }
-        expected.push({
-          label: SyntaxCheckerGlobals.i18n.suppressError,
-          suppressRule: params.data.ruleId
-        });
         self.expected = ko.observableArray(expected);
 
         var selectedSub = self.selected.subscribe(function (newValue) {
           if (typeof newValue.suppressRule !== 'undefined') {
             var suppressedRules = ApiHelper.getInstance().getFromTotalStorage('hue.syntax.checker', 'suppressedRules', {});
-            // TODO: Suppress on statement level instead of snippet once we have statement awareness in the snippet
-            suppressedRules[params.snippet.id() + newValue.suppressRule] = true;
+            suppressedRules[newValue.suppressRule] = true;
             ApiHelper.getInstance().setInTotalStorage('hue.syntax.checker', 'suppressedRules', suppressedRules);
             huePubSub.publish('editor.refresh.statement.locations', params.snippet);
           } else {