瀏覽代碼

HUE-5379 [editor] Add autocompletion of Hue variables

Johan Ahlen 9 年之前
父節點
當前提交
8eacce4
共有 1 個文件被更改,包括 4 次插入0 次删除
  1. 4 0
      desktop/core/src/desktop/static/desktop/js/sqlAutocompleter2.js

+ 4 - 0
desktop/core/src/desktop/static/desktop/js/sqlAutocompleter2.js

@@ -47,6 +47,7 @@ var SqlAutocompleter2 = (function () {
     HDFS: 300,
     VIRTUAL_COLUMN: 200,
     COLREF_KEYWORD: 100,
+    VARIABLE: 50,
     JOIN: -1
   };
 
@@ -246,6 +247,9 @@ var SqlAutocompleter2 = (function () {
 
     if (parseResult.suggestValues) {
       var suggestValuesDeferral = $.Deferred();
+      if (parseResult.colRef && parseResult.colRef.identifierChain) {
+        completions.push({ value: '${' + parseResult.colRef.identifierChain[parseResult.colRef.identifierChain.length - 1].name + '}', meta: 'variable', weight: DEFAULT_WEIGHTS.VARIABLE });
+      }
       colRefDeferral.done(function () {
         if (colRef !== null) {
           self.addValues(parseResult, colRef, completions);