Эх сурвалжийг харах

HUE-5475 [editor] Add autocomplete support for partial UDFs

Johan Ahlen 9 жил өмнө
parent
commit
0134659a6d

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/sql.js

@@ -4757,7 +4757,7 @@ parser.expandImpalaIdentifierChain = function (tablePrimaries, identifierChain)
 
 parser.identifyPartials = function (beforeCursor, afterCursor) {
   var beforeMatch = beforeCursor.match(/[0-9a-zA-Z_]*$/);
-  var afterMatch = afterCursor.match(/^[0-9a-zA-Z_]*/);
+  var afterMatch = afterCursor.match(/^[0-9a-zA-Z_]*(?:\((?:[^)]*\))?)?/);
   return {left: beforeMatch ? beforeMatch[0].length : 0, right: afterMatch ? afterMatch[0].length : 0};
 };
 

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/autocomplete/sql_support.js

@@ -529,7 +529,7 @@ parser.expandImpalaIdentifierChain = function (tablePrimaries, identifierChain)
 
 parser.identifyPartials = function (beforeCursor, afterCursor) {
   var beforeMatch = beforeCursor.match(/[0-9a-zA-Z_]*$/);
-  var afterMatch = afterCursor.match(/^[0-9a-zA-Z_]*/);
+  var afterMatch = afterCursor.match(/^[0-9a-zA-Z_]*(?:\((?:[^)]*\))?)?/);
   return {left: beforeMatch ? beforeMatch[0].length : 0, right: afterMatch ? afterMatch[0].length : 0};
 };
 

+ 4 - 1
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpec.js

@@ -465,12 +465,15 @@
 
     describe('partial removal', function () {
       it('should identify part lengths', function () {
-        var limitChars = [' ', '\n', '\t', '&', '~', '%', '!', '.', ',', '+', '-', '*', '/', '=', '<', '>', '(', ')', '[', ']', ';'];
+        var limitChars = [' ', '\n', '\t', '&', '~', '%', '!', '.', ',', '+', '-', '*', '/', '=', '<', '>', ')', '[', ']', ';'];
         expect(sql.identifyPartials('', '')).toEqual({left: 0, right: 0});
         expect(sql.identifyPartials('foo', '')).toEqual({left: 3, right: 0});
         expect(sql.identifyPartials(' foo', '')).toEqual({left: 3, right: 0});
         expect(sql.identifyPartials('asdf 1234', '')).toEqual({left: 4, right: 0});
         expect(sql.identifyPartials('foo', 'bar')).toEqual({left: 3, right: 3});
+        expect(sql.identifyPartials('fo', 'o()')).toEqual({left: 2, right: 3});
+        expect(sql.identifyPartials('fo', 'o(')).toEqual({left: 2, right: 2});
+        expect(sql.identifyPartials('fo', 'o(bla bla)')).toEqual({left: 2, right: 10});
         expect(sql.identifyPartials('foo ', '')).toEqual({left: 0, right: 0});
         expect(sql.identifyPartials('foo \'', '\'')).toEqual({left: 0, right: 0});
         expect(sql.identifyPartials('foo "', '"')).toEqual({left: 0, right: 0});