فهرست منبع

HUE-4031 [autocomplete] Create a parser dedicated to autocomplete

Johan Ahlen 8 سال پیش
والد
کامیت
84a63a39a8
30فایلهای تغییر یافته به همراه287 افزوده شده و 182 حذف شده
  1. 29 0
      desktop/core/src/desktop/static/desktop/js/autocomplete/jison/autocomplete_header.jison
  2. 83 97
      desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison
  3. 88 0
      desktop/core/src/desktop/static/desktop/js/autocomplete/sqlAutocompleteParser.js
  4. 1 1
      desktop/core/src/desktop/static/desktop/js/sqlAutocompleter2.js
  5. 1 1
      desktop/core/src/desktop/static/desktop/js/sqlAutocompleter3.js
  6. 32 32
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpec.js
  7. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAlter.js
  8. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAnalyze.js
  9. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecCreate.js
  10. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe_hive.js
  11. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe_impala.js
  12. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDrop.js
  13. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecError.js
  14. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecGrant.js
  15. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecInsert.js
  16. 4 4
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecLoad.js
  17. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecLocations.js
  18. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSelect.js
  19. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSet.js
  20. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecShow.js
  21. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecUpdate.js
  22. 2 2
      desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecUse.js
  23. 4 4
      desktop/core/src/desktop/static/desktop/spec/autocompleterTestUtils.js
  24. 2 2
      desktop/core/src/desktop/templates/ace_sql_worker.mako
  25. 1 1
      desktop/core/src/desktop/templates/hue.mako
  26. 1 1
      desktop/core/src/desktop/templates/jasmineRunner.html
  27. 1 1
      desktop/libs/indexer/src/indexer/templates/importer.mako
  28. 1 1
      desktop/libs/notebook/src/notebook/templates/editor_components.mako
  29. 2 1
      desktop/libs/notebook/src/notebook/templates/editor_m.mako
  30. 7 6
      tools/jison/hue-jison.sh

+ 29 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/autocomplete_header.jison

@@ -0,0 +1,29 @@
+// Licensed to Cloudera, Inc. under one
+// or more contributor license agreements.  See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership.  Cloudera, Inc. licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License.  You may obtain a copy of the License at
+//
+//     http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+%left 'AND' 'OR'
+%left 'BETWEEN'
+%left 'NOT' '!' '~'
+%left '=' '<' '>' 'COMPARISON_OPERATOR'
+%left '-' '*' 'ARITHMETIC_OPERATOR'
+
+%left ';' ','
+%nonassoc 'CURSOR' 'PARTIAL_CURSOR'
+%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
+
+%start SqlAutocomplete
+
+%%

+ 83 - 97
desktop/core/src/desktop/static/desktop/js/autocomplete/jison/sql_main.jison

@@ -14,19 +14,92 @@
 // See the License for the specific language governing permissions and
 // limitations under the License.
 
-%left 'AND' 'OR'
-%left 'BETWEEN'
-%left 'NOT' '!' '~'
-%left '=' '<' '>' 'COMPARISON_OPERATOR'
-%left '-' '*' 'ARITHMETIC_OPERATOR'
+SqlAutocomplete
+ : NewStatement SqlStatements EOF
+   {
+     return parser.yy.result;
+   }
+ | NewStatement SqlStatements_EDIT EOF
+   {
+     return parser.yy.result;
+   }
+ ;
+
+NewStatement
+ : /* empty */
+   {
+     parser.prepareNewStatement();
+   }
+ ;
+
+SqlStatements
+ :
+ | SqlStatement
+   {
+     parser.addStatementLocation(@1);
+   }
+ | SqlStatements ';' NewStatement SqlStatements
+ ;
 
-%left ';' ','
-%nonassoc 'CURSOR' 'PARTIAL_CURSOR'
-%nonassoc 'IN' 'IS' 'LIKE' 'RLIKE' 'REGEXP' 'EXISTS' NEGATION
+SqlStatements_EDIT
+ : SqlStatement_EDIT
+   {
+     parser.addStatementLocation(@1);
+   }
+ | SqlStatement_EDIT ';' NewStatement SqlStatements
+   {
+     parser.addStatementLocation(@1);
+   }
+ | SqlStatements ';' NewStatement SqlStatement_EDIT
+   {
+     parser.addStatementLocation(@4);
+   }
+ | SqlStatements ';' NewStatement SqlStatement_EDIT ';' NewStatement SqlStatements
+   {
+     parser.addStatementLocation(@4);
+   }
+ ;
 
-%start Sql
+SqlStatement
+ : DataDefinition
+ | DataManipulation
+ | QuerySpecification
+ | SetSpecification
+ | ExplainClause DataDefinition
+ | ExplainClause DataManipulation
+ | ExplainClause QuerySpecification
+ ;
 
-%%
+SqlStatement_EDIT
+ : AnyCursor
+   {
+     if (parser.isHive()) {
+       parser.suggestDdlAndDmlKeywords(['EXPLAIN', 'FROM']);
+     } else if (parser.isImpala()) {
+       parser.suggestDdlAndDmlKeywords(['EXPLAIN']);
+     } else {
+       parser.suggestDdlAndDmlKeywords();
+     }
+   }
+ | CommonTableExpression 'CURSOR'
+   {
+     if (parser.isHive() || parser.isImpala()) {
+       parser.suggestKeywords(['INSERT', 'SELECT']);
+     } else {
+       parser.suggestKeywords(['SELECT']);
+     }
+   }
+ | ExplainClause_EDIT
+ | DataDefinition_EDIT
+ | DataManipulation_EDIT
+ | QuerySpecification_EDIT
+ | ExplainClause DataDefinition_EDIT
+ | ExplainClause DataManipulation_EDIT
+ | ExplainClause QuerySpecification_EDIT
+ | ExplainClause_EDIT DataDefinition
+ | ExplainClause_EDIT DataManipulation
+ | ExplainClause_EDIT QuerySpecification
+ ;
 
 NonReservedKeyword
  : '<hive>ADD'
@@ -180,93 +253,6 @@ RegularIdentifier
  | NonReservedKeyword
  ;
 
-NewStatement
- : /* empty */
-   {
-     parser.prepareNewStatement();
-   }
- ;
-
-Sql
- : NewStatement SqlStatements EOF
-   {
-     return parser.yy.result;
-   }
- | NewStatement SqlStatements_EDIT EOF
-   {
-     return parser.yy.result;
-   }
- ;
-
-SqlStatements
- :
- | SqlStatement
-   {
-     parser.addStatementLocation(@1);
-   }
- | SqlStatements ';' NewStatement SqlStatements
- ;
-
-SqlStatements_EDIT
- : SqlStatement_EDIT
-   {
-     parser.addStatementLocation(@1);
-   }
- | SqlStatement_EDIT ';' NewStatement SqlStatements
-   {
-     parser.addStatementLocation(@1);
-   }
- | SqlStatements ';' NewStatement SqlStatement_EDIT
-   {
-     parser.addStatementLocation(@4);
-   }
- | SqlStatements ';' NewStatement SqlStatement_EDIT ';' NewStatement SqlStatements
-   {
-     parser.addStatementLocation(@4);
-   }
- ;
-
-SqlStatement
- : DataDefinition
- | DataManipulation
- | QuerySpecification
- | SetSpecification
- | ExplainClause DataDefinition
- | ExplainClause DataManipulation
- | ExplainClause QuerySpecification
- ;
-
-SqlStatement_EDIT
- : AnyCursor
-   {
-     if (parser.isHive()) {
-       parser.suggestDdlAndDmlKeywords(['EXPLAIN', 'FROM']);
-     } else if (parser.isImpala()) {
-       parser.suggestDdlAndDmlKeywords(['EXPLAIN']);
-     } else {
-       parser.suggestDdlAndDmlKeywords();
-     }
-   }
- | CommonTableExpression 'CURSOR'
-   {
-     if (parser.isHive() || parser.isImpala()) {
-       parser.suggestKeywords(['INSERT', 'SELECT']);
-     } else {
-       parser.suggestKeywords(['SELECT']);
-     }
-   }
- | ExplainClause_EDIT
- | DataDefinition_EDIT
- | DataManipulation_EDIT
- | QuerySpecification_EDIT
- | ExplainClause DataDefinition_EDIT
- | ExplainClause DataManipulation_EDIT
- | ExplainClause QuerySpecification_EDIT
- | ExplainClause_EDIT DataDefinition
- | ExplainClause_EDIT DataManipulation
- | ExplainClause_EDIT QuerySpecification
- ;
-
 SetSpecification
  : 'SET' SetOption '=' SetValue
  ;

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 88 - 0
desktop/core/src/desktop/static/desktop/js/autocomplete/sqlAutocompleteParser.js


+ 1 - 1
desktop/core/src/desktop/static/desktop/js/sqlAutocompleter2.js

@@ -54,7 +54,7 @@ var SqlAutocompleter2 = (function () {
 
   SqlAutocompleter2.prototype.autocomplete = function (beforeCursor, afterCursor, callback, editor) {
     var self = this;
-    var parseResult = sql.parseSql(beforeCursor, afterCursor, self.snippet.type(), false);
+    var parseResult = sqlAutocompleteParser.parseSql(beforeCursor, afterCursor, self.snippet.type(), false);
 
     if (typeof hueDebug !== 'undefined' && hueDebug.showParseResult) {
       console.log(parseResult);

+ 1 - 1
desktop/core/src/desktop/static/desktop/js/sqlAutocompleter3.js

@@ -1771,7 +1771,7 @@ var SqlAutocompleter3 = (function () {
   SqlAutocompleter3.prototype.autocomplete = function () {
     var self = this;
     try {
-      var parseResult = sql.parseSql(self.editor().getTextBeforeCursor(), self.editor().getTextAfterCursor(), self.snippet.type(), false);
+      var parseResult = sqlAutocompleteParser.parseSql(self.editor().getTextBeforeCursor(), self.editor().getTextAfterCursor(), self.snippet.type(), false);
 
       if (typeof hueDebug !== 'undefined' && hueDebug.showParseResult) {
         console.log(parseResult);

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

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js', function() {
+  describe('sqlAutocompleteParser.js', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);
@@ -466,24 +466,24 @@
     describe('partial removal', function () {
       it('should identify part lengths', function () {
         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});
+        expect(sqlAutocompleteParser.identifyPartials('', '')).toEqual({left: 0, right: 0});
+        expect(sqlAutocompleteParser.identifyPartials('foo', '')).toEqual({left: 3, right: 0});
+        expect(sqlAutocompleteParser.identifyPartials(' foo', '')).toEqual({left: 3, right: 0});
+        expect(sqlAutocompleteParser.identifyPartials('asdf 1234', '')).toEqual({left: 4, right: 0});
+        expect(sqlAutocompleteParser.identifyPartials('foo', 'bar')).toEqual({left: 3, right: 3});
+        expect(sqlAutocompleteParser.identifyPartials('fo', 'o()')).toEqual({left: 2, right: 3});
+        expect(sqlAutocompleteParser.identifyPartials('fo', 'o(')).toEqual({left: 2, right: 2});
+        expect(sqlAutocompleteParser.identifyPartials('fo', 'o(bla bla)')).toEqual({left: 2, right: 10});
+        expect(sqlAutocompleteParser.identifyPartials('foo ', '')).toEqual({left: 0, right: 0});
+        expect(sqlAutocompleteParser.identifyPartials('foo \'', '\'')).toEqual({left: 0, right: 0});
+        expect(sqlAutocompleteParser.identifyPartials('foo "', '"')).toEqual({left: 0, right: 0});
         limitChars.forEach(function (char) {
-          expect(sql.identifyPartials('bar foo' + char, '')).toEqual({left: 0, right: 0});
-          expect(sql.identifyPartials('bar foo' + char + 'foofoo', '')).toEqual({left: 6, right: 0});
-          expect(sql.identifyPartials('bar foo' + char + 'foofoo ', '')).toEqual({left: 0, right: 0});
-          expect(sql.identifyPartials('', char + 'foo bar')).toEqual({left: 0, right: 0});
-          expect(sql.identifyPartials('', 'foofoo' + char)).toEqual({left: 0, right: 6});
-          expect(sql.identifyPartials('', ' foofoo' + char)).toEqual({left: 0, right: 0});
+          expect(sqlAutocompleteParser.identifyPartials('bar foo' + char, '')).toEqual({left: 0, right: 0});
+          expect(sqlAutocompleteParser.identifyPartials('bar foo' + char + 'foofoo', '')).toEqual({left: 6, right: 0});
+          expect(sqlAutocompleteParser.identifyPartials('bar foo' + char + 'foofoo ', '')).toEqual({left: 0, right: 0});
+          expect(sqlAutocompleteParser.identifyPartials('', char + 'foo bar')).toEqual({left: 0, right: 0});
+          expect(sqlAutocompleteParser.identifyPartials('', 'foofoo' + char)).toEqual({left: 0, right: 6});
+          expect(sqlAutocompleteParser.identifyPartials('', ' foofoo' + char)).toEqual({left: 0, right: 0});
         });
       });
     });
@@ -500,7 +500,7 @@
         }];
 
         var identifierChain = [{ name: 'testItem' }];
-        var result = sql.expandLateralViews(lateralViews, identifierChain);
+        var result = sqlAutocompleteParser.expandLateralViews(lateralViews, identifierChain);
         expect(result).toEqual([{ name: 'testArray' }, { name: 'item' }]);
       });
 
@@ -516,13 +516,13 @@
 
         var identifierChain = [{ name: 'explodedMap' }, { name: 'testMapValue' }];
 
-        var result = sql.expandLateralViews(lateralViews, identifierChain);
+        var result = sqlAutocompleteParser.expandLateralViews(lateralViews, identifierChain);
         expect(result).toEqual([{ name: 'testMap' }, { name: 'value' }]);
       });
 
       it('should expand 03', function () {
         var identifierChain = [{ name: 'testMap', keySet: true }];
-        var result = sql.expandLateralViews([], identifierChain);
+        var result = sqlAutocompleteParser.expandLateralViews([], identifierChain);
         expect(result).toEqual([{ name: 'testMap', keySet: true }]);
       });
 
@@ -537,7 +537,7 @@
         }];
 
         var identifierChain = [{ name: 'testItem' }];
-        var result = sql.expandLateralViews(lateralViews, identifierChain);
+        var result = sqlAutocompleteParser.expandLateralViews(lateralViews, identifierChain);
         expect(result).toEqual([{ name: 'testArray' }, { name: 'item' }]);
       });
 
@@ -559,7 +559,7 @@
         }];
 
         var identifierChain = [{ name: 'testItemA' }];
-        var result = sql.expandLateralViews(lateralViews, identifierChain);
+        var result = sqlAutocompleteParser.expandLateralViews(lateralViews, identifierChain);
         expect(result).toEqual([{ name: 'testArrayA' }, { name: 'item' }]);
       });
 
@@ -580,7 +580,7 @@
           }
         }];
         var identifierChain = [{ name: 'testItemB' }];
-        var result = sql.expandLateralViews(lateralViews, identifierChain);
+        var result = sqlAutocompleteParser.expandLateralViews(lateralViews, identifierChain);
         expect(result).toEqual([{ name: 'tt2' }, { name: 'testArrayB' }, { name: 'item' }]);
       });
 
@@ -602,7 +602,7 @@
         }];
 
         var identifierChain = [{ name: 'ta2_exp' }];
-        var result = sql.expandLateralViews(lateralViews, identifierChain);
+        var result = sqlAutocompleteParser.expandLateralViews(lateralViews, identifierChain);
         expect(result).toEqual([{ name: 'tt' }, { name: 'testArray1' }, { name: 'item' }, { name: 'testArray2' }, { name: 'item' }]);
       });
 
@@ -617,7 +617,7 @@
         }];
 
         var identifierChain = [{ name: 'testValue' }];
-        var result = sql.expandLateralViews(lateralViews, identifierChain);
+        var result = sqlAutocompleteParser.expandLateralViews(lateralViews, identifierChain);
         expect(result).toEqual([{ name: 'testArray' }, { name: 'item' }]);
       });
 
@@ -632,7 +632,7 @@
         }];
 
         var identifierChain = [{ name: 'testMapValue' }];
-        var result = sql.expandLateralViews(lateralViews, identifierChain);
+        var result = sqlAutocompleteParser.expandLateralViews(lateralViews, identifierChain);
         expect(result).toEqual([{ name: 'testMap' }, { name: 'value' }]);
       });
 
@@ -648,7 +648,7 @@
         }];
 
         var identifierChain = [{ name: 'testItem' }];
-        var result = sql.expandLateralViews(lateralViews, identifierChain);
+        var result = sqlAutocompleteParser.expandLateralViews(lateralViews, identifierChain);
         expect(result).toEqual([{ name: 'testArray' }, { name: 'item' }]);
       });
 
@@ -660,7 +660,7 @@
 
         var identifierChain = [{ name: 'm', keySet: true }, { name: 'bar' }];
 
-        var actual = sql.expandImpalaIdentifierChain(tablePrimaries, identifierChain);
+        var actual = sqlAutocompleteParser.expandImpalaIdentifierChain(tablePrimaries, identifierChain);
 
         expect(actual).toEqual([{ name: 't' }, { name: 'someMap', keySet: true }, { name: 'bar' }]);
       });
@@ -673,7 +673,7 @@
 
         var identifierChain = [{ name: 'tm' }];
 
-        var actual = sql.expandImpalaIdentifierChain(tablePrimaries, identifierChain);
+        var actual = sqlAutocompleteParser.expandImpalaIdentifierChain(tablePrimaries, identifierChain);
 
         expect(actual).toEqual([{ name: 't' }, { name: 'testMap' }]);
       });
@@ -686,7 +686,7 @@
 
         var identifierChain = [{ name: 't1' }];
 
-        var actual = sql.expandImpalaIdentifierChain(tablePrimaries, identifierChain);
+        var actual = sqlAutocompleteParser.expandImpalaIdentifierChain(tablePrimaries, identifierChain);
 
         expect(actual).toEqual([{ name: 't1' }]);
       });

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAlter.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js ALTER statements', function() {
+  describe('sqlAutocompleteParser.js ALTER statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecAnalyze.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js ANALYZE statements', function() {
+  describe('sqlAutocompleteParser.js ANALYZE statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecCreate.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js CREATE statements', function() {
+  describe('sqlAutocompleteParser.js CREATE statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe_hive.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js Hive DESCRIBE statements', function() {
+  describe('sqlAutocompleteParser.js Hive DESCRIBE statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDescribe_impala.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js Impala DESCRIBE statements', function() {
+  describe('sqlAutocompleteParser.js Impala DESCRIBE statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecDrop.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js DROP statements', function() {
+  describe('sqlAutocompleteParser.js DROP statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecError.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js Error statements', function() {
+  describe('sqlAutocompleteParser.js Error statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecGrant.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js GRANT statements', function() {
+  describe('sqlAutocompleteParser.js GRANT statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecInsert.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js INSERT statements', function() {
+  describe('sqlAutocompleteParser.js INSERT statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

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

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js LOAD statements', function() {
+  describe('sqlAutocompleteParser.js LOAD statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);
@@ -310,10 +310,10 @@
     });
   });
 
-  describe('sql.js IMPORT and EXPORT statements', function() {
+  describe('sqlAutocompleteParser.js IMPORT and EXPORT statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecLocations.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js locations', function() {
+  describe('sqlAutocompleteParser.js locations', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSelect.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js SELECT statements', function() {
+  describe('sqlAutocompleteParser.js SELECT statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecSet.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js SET statements', function() {
+  describe('sqlAutocompleteParser.js SET statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecShow.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js SHOW statements', function() {
+  describe('sqlAutocompleteParser.js SHOW statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecUpdate.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js UPDATE statements', function() {
+  describe('sqlAutocompleteParser.js UPDATE statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 2 - 2
desktop/core/src/desktop/static/desktop/spec/autocomplete/sqlSpecUse.js

@@ -15,10 +15,10 @@
 // limitations under the License.
 
 (function () {
-  describe('sql.js USE statements', function() {
+  describe('sqlAutocompleteParser.js USE statements', function() {
 
     beforeAll(function () {
-      sql.yy.parseError = function (msg) {
+      sqlAutocompleteParser.yy.parseError = function (msg) {
         throw Error(msg);
       };
       jasmine.addMatchers(SqlTestUtils.testDefinitionMatcher);

+ 4 - 4
desktop/core/src/desktop/static/desktop/spec/autocompleterTestUtils.js

@@ -547,13 +547,13 @@ var SqlTestUtils = (function() {
     assertAutocomplete: function(testDefinition) {
       var debug = false;
       if (typeof testDefinition.dialect === 'undefined') {
-        expect(sql.parseSql(testDefinition.beforeCursor, testDefinition.afterCursor, testDefinition.dialect, debug)).toEqualDefinition(testDefinition);
+        expect(sqlAutocompleteParser.parseSql(testDefinition.beforeCursor, testDefinition.afterCursor, testDefinition.dialect, debug)).toEqualDefinition(testDefinition);
         testDefinition.dialect = 'hive';
-        expect(sql.parseSql(testDefinition.beforeCursor, testDefinition.afterCursor,  testDefinition.dialect, debug)).toEqualDefinition(testDefinition);
+        expect(sqlAutocompleteParser.parseSql(testDefinition.beforeCursor, testDefinition.afterCursor,  testDefinition.dialect, debug)).toEqualDefinition(testDefinition);
         testDefinition.dialect = 'impala';
-        expect(sql.parseSql(testDefinition.beforeCursor, testDefinition.afterCursor,  testDefinition.dialect, debug)).toEqualDefinition(testDefinition);
+        expect(sqlAutocompleteParser.parseSql(testDefinition.beforeCursor, testDefinition.afterCursor,  testDefinition.dialect, debug)).toEqualDefinition(testDefinition);
       } else {
-        expect(sql.parseSql(testDefinition.beforeCursor, testDefinition.afterCursor, testDefinition.dialect, debug)).toEqualDefinition(testDefinition);
+        expect(sqlAutocompleteParser.parseSql(testDefinition.beforeCursor, testDefinition.afterCursor, testDefinition.dialect, debug)).toEqualDefinition(testDefinition);
       }
     },
     LOTS_OF_PARSE_RESULTS: LOTS_OF_PARSE_RESULTS

+ 2 - 2
desktop/core/src/desktop/templates/ace_sql_worker.mako

@@ -16,7 +16,7 @@
 
 var version = 20;
 importScripts('${ static('desktop/js/autocomplete/sqlParseSupport.js') }' + '?version=' + version);
-importScripts('${ static('desktop/js/autocomplete/sql.js') }' + '?version=' + version);
+importScripts('${ static('desktop/js/autocomplete/sqlAutocompleteParser.js') }' + '?version=' + version);
 importScripts('${ static('desktop/js/sqlFunctions.js') }' + '?version=' + version);
 
 (function () {
@@ -27,7 +27,7 @@ importScripts('${ static('desktop/js/sqlFunctions.js') }' + '?version=' + versio
     // Statement locations come in the message to the worker and are generally more accurate
     locations.push(statement);
     try {
-      var sqlParseResult = sql.parseSql(statement.statement + ' ', '', type, false);
+      var sqlParseResult = sqlAutocompleteParser.parseSql(statement.statement + ' ', '', type, false);
       if (sqlParseResult.locations) {
         sqlParseResult.locations.forEach(function (location) {
           // Skip statement locations from the sql parser

+ 1 - 1
desktop/core/src/desktop/templates/hue.mako

@@ -506,7 +506,7 @@ ${ hueIcons.symbols() }
 <script src="${ static('desktop/ext/js/dropzone.min.js') }"></script>
 
 <script src="${ static('desktop/js/autocomplete/sqlParseSupport.js') }"></script>
-<script src="${ static('desktop/js/autocomplete/sql.js') }"></script>
+<script src="${ static('desktop/js/autocomplete/sqlAutocompleteParser.js') }"></script>
 <script src="${ static('desktop/js/sqlAutocompleter.js') }"></script>
 <script src="${ static('desktop/js/sqlAutocompleter2.js') }"></script>
 <script src="${ static('desktop/js/hdfsAutocompleter.js') }"></script>

+ 1 - 1
desktop/core/src/desktop/templates/jasmineRunner.html

@@ -103,7 +103,7 @@
   <script type="text/javascript" src="../static/desktop/spec/hdfsAutocompleterSpec.js"></script>
 
   <script type="text/javascript" src="../static/desktop/js/autocomplete/sqlParseSupport.js"></script>
-  <script type="text/javascript" src="../static/desktop/js/autocomplete/sql.js"></script>
+  <script type="text/javascript" src="../static/desktop/js/autocomplete/sqlAutocompleteParser.js"></script>
   <script type="text/javascript" src="../static/desktop/spec/autocomplete/sqlSpec.js"></script>
 
   <script type="text/javascript" src="../static/desktop/spec/autocomplete/sqlSpecAlter.js"></script>

+ 1 - 1
desktop/libs/indexer/src/indexer/templates/importer.mako

@@ -31,7 +31,7 @@ ${ commonheader(_("Importer"), "indexer", user, request, "60px") | n,unicode }
 
 ## TODO lot of those re-imported
 <script src="${ static('desktop/js/autocomplete/sqlParseSupport.js') }"></script>
-<script src="${ static('desktop/js/autocomplete/sql.js') }"></script>
+<script src="${ static('desktop/js/autocomplete/sqlAutocompleteParser.js') }"></script>
 <script src="${ static('desktop/js/sqlAutocompleter.js') }"></script>
 <script src="${ static('desktop/js/sqlAutocompleter2.js') }"></script>
 <script src="${ static('desktop/js/hdfsAutocompleter.js') }"></script>

+ 1 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -63,7 +63,7 @@ from notebook.conf import ENABLE_QUERY_BUILDER, ENABLE_QUERY_SCHEDULING, ENABLE_
 <script src="${ static('desktop/js/sqlFunctions.js') }"></script>
 <script src="${ static('desktop/js/autocomplete/sqlParseSupport.js') }"></script>
 <script src="${ static('desktop/js/autocomplete/sqlStatementsParser.js') }"></script>
-<script src="${ static('desktop/js/autocomplete/sql.js') }"></script>
+<script src="${ static('desktop/js/autocomplete/sqlAutocompleteParser.js') }"></script>
 <script src="${ static('desktop/js/sqlAutocompleter.js') }"></script>
 <script src="${ static('desktop/js/sqlAutocompleter2.js') }"></script>
 <script src="${ static('desktop/js/sqlAutocompleter3.js') }"></script>

+ 2 - 1
desktop/libs/notebook/src/notebook/templates/editor_m.mako

@@ -168,9 +168,10 @@ ${ commonheader_m(editor_type, editor_type, user, request, "68px") | n,unicode }
 <script src="${ static('desktop/js/ko.switch-case.js') }"></script>
 <script src="${ static('desktop/js/sqlFunctions.js') }"></script>
 <script src="${ static('desktop/js/autocomplete/sqlParseSupport.js') }"></script>
-<script src="${ static('desktop/js/autocomplete/sql.js') }"></script>
+<script src="${ static('desktop/js/autocomplete/sqlAutocompleteParser.js') }"></script>
 <script src="${ static('desktop/js/sqlAutocompleter.js') }"></script>
 <script src="${ static('desktop/js/sqlAutocompleter2.js') }"></script>
+<script src="${ static('desktop/js/sqlAutocompleter3.js') }"></script>
 <script src="${ static('desktop/js/hdfsAutocompleter.js') }"></script>
 <script src="${ static('desktop/js/autocompleter.js') }"></script>
 <script src="${ static('desktop/js/hue.json.js') }"></script>

+ 7 - 6
tools/jison/hue-jison.sh

@@ -30,17 +30,18 @@ pushd ../../desktop/core/src/desktop/static/desktop/js/autocomplete/jison
 # For quick version of select with create only and no support for value expressions (i.e. a = b or a IN (1, 2, 3))
 # cat sql_main.jison sql_create.jison sql_end.jison > sql.jison
 
-cat sql_main.jison sql_valueExpression.jison sql_error.jison sql_alter.jison sql_analyze.jison sql_create.jison sql_drop.jison sql_grant.jison sql_insert.jison sql_load.jison sql_set.jison sql_show.jison sql_update.jison sql_use.jison ../sql_end.jison > sql.jison
+cat autocomplete_header.jison sql_main.jison sql_valueExpression.jison sql_error.jison sql_alter.jison sql_analyze.jison sql_create.jison sql_drop.jison sql_grant.jison sql_insert.jison sql_load.jison sql_set.jison sql_show.jison sql_update.jison sql_use.jison ../sql_end.jison > sqlAutocompleteParser.jison
+
+echo "Creating SQL autocomplete parser..."
+jison sqlAutocompleteParser.jison sql.jisonlex
+cat license.txt sqlAutocompleteParser.js > ../sqlAutocompleteParser.js
+rm sqlAutocompleteParser.jison
+rm sqlAutocompleteParser.js
 
 echo "Creating SQL statements parser..."
 jison sqlStatementsParser.jison
 cat license.txt sqlStatementsParser.js > ../sqlStatementsParser.js
 rm sqlStatementsParser.js
 
-echo "Creating SQL parser..."
-jison sql.jison sql.jisonlex
-cat license.txt sql.js > ../sql.js
-rm sql.jison
-rm sql.js
 popd
 echo "Done!"

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است