فهرست منبع

HUE-3495 [editor] Autocomplete globs the comments

This strips the comments for SQL type editors.
Johan Ahlen 10 سال پیش
والد
کامیت
6498c17

تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/ext-language_tools.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/snippets/actionscript.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/snippets/java.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/snippets/javascript.js


تفاوت فایلی نمایش داده نمی شود زیرا این فایل بسیار بزرگ است
+ 0 - 0
desktop/core/src/desktop/static/desktop/js/ace/snippets/php.js


+ 2 - 1
desktop/core/src/desktop/static/desktop/js/ko.hue-bindings.js

@@ -2500,7 +2500,8 @@
       editor.completer.exactMatch = ! snippet.isSqlDialect();
 
       var langTools = ace.require("ace/ext/language_tools")
-      langTools.addCompleter(snippet.autocompleter);
+      langTools.textCompleter.setSqlMode(snippet.isSqlDialect())
+      langTools.setCompleters([snippet.autocompleter, langTools.snippetCompleter, langTools.textCompleter, langTools.keyWordCompleter])
 
       var placeHolderElement = null;
       var placeHolderVisible = false;

+ 15 - 2
tools/ace-editor/lib/ace/autocomplete/text_completer.js

@@ -33,9 +33,18 @@ define(function(require, exports, module) {
     
     var splitRegex = /[^a-zA-Z_0-9\$\-\u00C0-\u1FFF\u2C00-\uD7FF\w]+/;
 
+    var ignoreSqlCommentLines = false;
+
+    function stripSqlComments(txt) {
+        if (ignoreSqlCommentLines) {
+            return txt.replace(/\*([^*]|[\r\n]|(\*+([^*/]|[\r\n])))*\*+/, '').replace(/--.*/g, '');
+        }
+        return txt;
+    }
+
     function getWordIndex(doc, pos) {
         var textBefore = doc.getTextRange(Range.fromPoints({row: 0, column:0}, pos));
-        return textBefore.split(splitRegex).length - 1;
+        return stripSqlComments(textBefore).split(splitRegex).length - 1;
     }
 
     /**
@@ -44,7 +53,7 @@ define(function(require, exports, module) {
      */
     function wordDistance(doc, pos) {
         var prefixPos = getWordIndex(doc, pos);
-        var words = doc.getValue().split(splitRegex);
+        var words = stripSqlComments(doc.getValue()).split(splitRegex);
         var wordScores = Object.create(null);
         
         var currentWord = words[prefixPos];
@@ -63,6 +72,10 @@ define(function(require, exports, module) {
         return wordScores;
     }
 
+    exports.setSqlMode = function(sqlMode) {
+        ignoreSqlCommentLines = sqlMode;
+    };
+
     exports.getCompletions = function(editor, session, pos, prefix, callback) {
         var wordScore = wordDistance(session, pos, prefix);
         var wordList = Object.keys(wordScore);

برخی فایل ها در این مقایسه diff نمایش داده نمی شوند زیرا تعداد فایل ها بسیار زیاد است