فهرست منبع

HUE-4031 [editor] Make sure repeated errors are marked

Johan Ahlen 8 سال پیش
والد
کامیت
c281b31

+ 6 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/spec/sqlSyntaxParserSpec.js

@@ -76,11 +76,16 @@
       expect(result.loc.last_column).toEqual(14);
     });
 
-    fit('should find errors for "select * from customers c cultster by awasd asd afd;"', function () {
+    it('should find errors for "select * from customers c cultster by awasd asd afd;"', function () {
       var result = sqlSyntaxParser.parseSyntax('select * from customers c cultster by awasd asd afd;', '');
       expect(result).toBeTruthy();
     });
 
+    it('should find errors for "select asdf wer qwer qewr   qwer"', function () {
+      var result = sqlSyntaxParser.parseSyntax('select asdf wer qwer qewr   qwer', '');
+      expect(result).toBeTruthy();
+    });
+
     it('should suggest expected words for "SLELECT "', function() {
       var result = sqlSyntaxParser.parseSyntax('SLELECT ', '');
       expect(result).toBeTruthy();

+ 5 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlParseSupport.js

@@ -1564,6 +1564,8 @@ var SqlParseSupport = (function () {
       parser[noopFn] = SYNTAX_PARSER_NOOP
     });
 
+    parser.yy.locations = [{}];
+
     parser.determineCase = function (text) {
       if (!parser.yy.caseDetermined) {
         parser.yy.lowerCase = text.toLowerCase() === text;
@@ -1610,9 +1612,11 @@ var SqlParseSupport = (function () {
         if (debug) {
           console.log(err);
           console.error(err.stack);
+          console.log(parser.yy.error);
         }
       }
-      if (parser.yy.error && !beforeCursor.endsWith(parser.yy.error.text)) {
+
+      if (parser.yy.error && (parser.yy.error.loc.last_column < beforeCursor.length || !beforeCursor.endsWith(parser.yy.error.text))) {
         var weightedExpected = [];
 
         var isLowerCase = parser.yy.caseDetermined && parser.yy.lowerCase || parser.yy.error.text.toLowerCase() === parser.yy.error.text;