소스 검색

[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 년 전
부모
커밋
8d35e49

파일 크기가 너무 크기때문에 변경 상태를 표시하지 않습니다.
+ 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);
                 }
             }
-            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;

이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.