浏览代码

HUE-7078 [editor] Don't mark custom variables as missing

Johan Ahlen 8 年之前
父节点
当前提交
df354a2

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

@@ -55,6 +55,22 @@
       });
     });
 
+    it('should report locations for "select * from tbl where col = ${var_name=10}; |"', function() {
+      assertLocations({
+        beforeCursor: 'select * from tbl where col = ${var_name=10}; ',
+        expectedLocations: [
+          { type: 'statement', location: { first_line: 1, last_line: 1, first_column: 1, last_column: 45 } },
+          { type: 'selectList', missing: false, location: { first_line: 1, last_line: 1, first_column: 8, last_column: 9 } },
+          { type: 'asterisk', location: { first_line: 1, last_line: 1, first_column: 8, last_column: 9 }, tables: [{ identifierChain: [{ name: 'tbl' }] }] },
+          { type: 'table', location: { first_line: 1, last_line: 1, first_column: 15, last_column: 18 }, identifierChain: [{ name: 'tbl' }] },
+          { type: 'whereClause', missing: false, location: { first_line: 1, last_line: 1, first_column: 19, last_column: 45 } },
+          { type: 'column', location: { first_line: 1, last_line: 1, first_column: 25, last_column: 28 }, identifierChain: [{ name: 'col' }], tables: [{ identifierChain: [{ name: 'tbl' }] }] },
+          { type: 'column', location: { first_line: 1, last_line: 1, first_column: 31, last_column: 45 }, identifierChain: [{ name: '${var_name=10}' }], tables: [{ identifierChain: [{ name: 'tbl' }] }] },
+          { type: 'limitClause', missing: true, location: { first_line: 1, last_line: 1, first_column: 45, last_column: 45 } }
+        ]
+      });
+    });
+
     it('should report locations for "SELECT * FROM testTable1 JOIN db1.table2; |"', function() {
       assertLocations({
         beforeCursor: 'SELECT * FROM testTable1 JOIN db1.table2; ',

+ 3 - 0
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -3865,6 +3865,9 @@
             // Ace getTokenAt() thinks the first ` is a token, column +1 will include the first and last.
             token = self.editor.session.getTokenAt(location.location.first_line - 1, location.location.first_column + 1);
           }
+          if (token && token.value && /^\s*\$\{\s*$/.test(token.value)) {
+            token = null;
+          }
           if (token !== null) {
             token.parseLocation = location;
             activeTokens.push(token);