Explorar o código

[spark] Ignore case for Hive and Impala autocomplete

This change adds an option to ignore case for an Ace completer in exact match mode, allowing for instance "SE" to match "SELECT". It will ignore the case on match but if all input is upper case then the completion is all upper, for all other combinations the completion will be all lower case.
Johan Ahlen %!s(int64=10) %!d(string=hai) anos
pai
achega
8d35e49

A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/ext-language_tools.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/mode-hive.js


A diferenza do arquivo foi suprimida porque é demasiado grande
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/mode-impala.js


+ 13 - 5
tools/ace-editor/lib/ace/autocomplete.js

@@ -191,10 +191,13 @@ var Autocomplete = function() {
                     this.editor.session.remove(range);
                 }
             }
-            if (data.snippet)
+            if (data.snippet) {
                 snippetManager.insertSnippet(this.editor, data.snippet);
-            else
+            } else if (data.upperCaseMatch) {
+                this.editor.execCommand("insertstring", data.upperCaseValue);
+            } else {
                 this.editor.execCommand("insertstring", data.value || data);
+            }
         }
         this.detach();
     };
@@ -467,10 +470,15 @@ var FilteredList = function(array, filterText) {
             var penalty = 0;
             var index, distance;
 
-            if (this.exactMatch) {
-                if (needle !== caption.substr(0, needle.length))
+            if (this.exactMatch && item.ignoreCase) {
+                if (upper !== item.upperCaseValue.substr(0, needle.length)) {
                     continue loop;
-            }else{
+                }
+                item.upperCaseMatch = needle === upper;
+                item.caption = item.upperCaseMatch ? item.upperCaseValue : item.value;
+            } else if (this.exactMatch && needle !== caption.substr(0, needle.length)) {
+                continue loop;
+            } else {
                 // caption char iteration is faster in Chrome but slower in Firefox, so lets use indexOf
                 for (var j = 0; j < needle.length; j++) {
                     // TODO add penalty on case mismatch

+ 14 - 0
tools/ace-editor/lib/ace/mode/hive.js

@@ -31,6 +31,20 @@ oop.inherits(Mode, TextMode);
 (function() {
     this.lineCommentStart = "--";
     this.$id = "ace/mode/hive"
+
+    this.getCompletions = function(state, session, pos, prefix) {
+        var keywords = this.$keywordList || this.$createKeywordList();
+        return keywords.map(function (word) {
+            return {
+                ignoreCase: true,
+                name: word,
+                value: word,
+                upperCaseValue: word.toUpperCase(),
+                score: 1,
+                meta: "keyword"
+            };
+        });
+    };
 }).call(Mode.prototype);
 
 exports.Mode = Mode;

+ 15 - 1
tools/ace-editor/lib/ace/mode/impala.js

@@ -30,7 +30,21 @@ oop.inherits(Mode, TextMode);
 
 (function() {
     this.lineCommentStart = "--";
-    this.$id = "ace/mode/impala"
+    this.$id = "ace/mode/impala";
+
+    this.getCompletions = function(state, session, pos, prefix) {
+        var keywords = this.$keywordList || this.$createKeywordList();
+        return keywords.map(function (word) {
+            return {
+                ignoreCase: true,
+                name: word,
+                value: word,
+                upperCaseValue: word.toUpperCase(),
+                score: 1,
+                meta: "keyword"
+            };
+        });
+    };
 }).call(Mode.prototype);
 
 exports.Mode = Mode;

Algúns arquivos non se mostraron porque demasiados arquivos cambiaron neste cambio