Sfoglia il codice sorgente

HUE-6050 [autocomplete] Fix issue where autocompletion might fail because of parser exception

Johan Ahlen 8 anni fa
parent
commit
552951f

+ 11 - 4
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js

@@ -6063,11 +6063,18 @@ parser.parseSql = function (beforeCursor, afterCursor, dialect, debug) {
       console.log(parser.yy.errors);
     }
   }
-  linkTablePrimaries();
-  commitLocations();
+  try {
+    linkTablePrimaries();
+    commitLocations();
+    // Clean up and prioritize
+    prioritizeSuggestions();
+  } catch (err) {
+    if (debug) {
+      console.log(err);
+      console.error(err.stack);
+    }
+  }
 
-  // Clean up and prioritize
-  prioritizeSuggestions();
 
   parser.yy.allLocations.sort(function (a, b) {
     if (a.location.first_line !== b.location.first_line) {

+ 11 - 4
desktop/core/src/desktop/static/desktop/js/autocomplete/sql_support.js

@@ -1367,11 +1367,18 @@ parser.parseSql = function (beforeCursor, afterCursor, dialect, debug) {
       console.log(parser.yy.errors);
     }
   }
-  linkTablePrimaries();
-  commitLocations();
+  try {
+    linkTablePrimaries();
+    commitLocations();
+    // Clean up and prioritize
+    prioritizeSuggestions();
+  } catch (err) {
+    if (debug) {
+      console.log(err);
+      console.error(err.stack);
+    }
+  }
 
-  // Clean up and prioritize
-  prioritizeSuggestions();
 
   parser.yy.allLocations.sort(function (a, b) {
     if (a.location.first_line !== b.location.first_line) {