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

[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 10 жил өмнө
parent
commit
8d35e4974f

Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/ext-language_tools.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/mode-hive.js


Файлын зөрүү хэтэрхий том тул дарагдсан байна
+ 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);
                     this.editor.session.remove(range);
                 }
                 }
             }
             }
-            if (data.snippet)
+            if (data.snippet) {
                 snippetManager.insertSnippet(this.editor, 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.editor.execCommand("insertstring", data.value || data);
+            }
         }
         }
         this.detach();
         this.detach();
     };
     };
@@ -467,10 +470,15 @@ var FilteredList = function(array, filterText) {
             var penalty = 0;
             var penalty = 0;
             var index, distance;
             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;
                     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
                 // caption char iteration is faster in Chrome but slower in Firefox, so lets use indexOf
                 for (var j = 0; j < needle.length; j++) {
                 for (var j = 0; j < needle.length; j++) {
                     // TODO add penalty on case mismatch
                     // 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() {
 (function() {
     this.lineCommentStart = "--";
     this.lineCommentStart = "--";
     this.$id = "ace/mode/hive"
     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);
 }).call(Mode.prototype);
 
 
 exports.Mode = Mode;
 exports.Mode = Mode;

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

@@ -30,7 +30,21 @@ oop.inherits(Mode, TextMode);
 
 
 (function() {
 (function() {
     this.lineCommentStart = "--";
     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);
 }).call(Mode.prototype);
 
 
 exports.Mode = Mode;
 exports.Mode = Mode;

Энэ ялгаанд хэт олон файл өөрчлөгдсөн тул зарим файлыг харуулаагүй болно