mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
get completionSupport from interpreter (backend)
Change-Id: Id03ba92143dfe4743e7c7b66c92ef4263df4d569
This commit is contained in:
parent
adaabcbf92
commit
d2f70ae7d1
18 changed files with 136 additions and 64 deletions
|
|
@ -20,7 +20,8 @@
|
|||
}
|
||||
},
|
||||
"editor": {
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -6,7 +6,8 @@
|
|||
"properties": {
|
||||
},
|
||||
"editor": {
|
||||
"editOnDblClick": true
|
||||
"editOnDblClick": true,
|
||||
"completionSupport": false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -34,7 +34,8 @@
|
|||
},
|
||||
"editor": {
|
||||
"language": "sql",
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -55,7 +55,8 @@
|
|||
}
|
||||
},
|
||||
"editor": {
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@
|
|||
}
|
||||
},
|
||||
"editor": {
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -11,6 +11,10 @@
|
|||
"description": "The path for custom groovy classes location. If empty `./interpreter/groovy/classes`",
|
||||
"type": "textarea"
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
@ -25,7 +25,8 @@
|
|||
}
|
||||
},
|
||||
"editor": {
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -32,6 +32,10 @@
|
|||
"description": "Peer class loading enabled. True or false",
|
||||
"type": "checkbox"
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -46,6 +50,10 @@
|
|||
"description": "Ignite JDBC connection URL.",
|
||||
"type": "string"
|
||||
}
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -105,7 +105,8 @@
|
|||
},
|
||||
"editor": {
|
||||
"language": "sql",
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -56,7 +56,8 @@
|
|||
},
|
||||
"editor": {
|
||||
"language": "sql",
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -53,6 +53,10 @@
|
|||
"description": "Hadoop cluster username",
|
||||
"type": "string"
|
||||
}
|
||||
},
|
||||
"editor": {
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -128,7 +128,8 @@
|
|||
"editor": {
|
||||
"language": "scala",
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -168,7 +169,8 @@
|
|||
"editor": {
|
||||
"language": "sql",
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -189,7 +191,8 @@
|
|||
"editor": {
|
||||
"language": "python",
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -210,7 +213,8 @@
|
|||
"editor": {
|
||||
"language": "python",
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -231,7 +235,8 @@
|
|||
"editor": {
|
||||
"language": "r",
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
|||
|
|
@ -14,7 +14,8 @@
|
|||
},
|
||||
"editor": {
|
||||
"language": "markdown",
|
||||
"editOnDblClick": true
|
||||
"editOnDblClick": true,
|
||||
"completionSupport": false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -27,7 +27,8 @@
|
|||
},
|
||||
"editor": {
|
||||
"language": "python",
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -51,7 +52,8 @@
|
|||
"editor": {
|
||||
"language": "python",
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -63,7 +65,8 @@
|
|||
"editor":{
|
||||
"language": "sql",
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -74,7 +77,8 @@
|
|||
},
|
||||
"editor": {
|
||||
"language": "sh",
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": false
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -85,7 +89,8 @@
|
|||
},
|
||||
"editor":{
|
||||
"language": "sh",
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -36,7 +36,8 @@
|
|||
},
|
||||
"editor": {
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -42,7 +42,8 @@
|
|||
},
|
||||
"editor": {
|
||||
"language": "sh",
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": false
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -86,7 +86,8 @@
|
|||
"editor": {
|
||||
"language": "scala",
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -126,7 +127,8 @@
|
|||
"editor": {
|
||||
"language": "sql",
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -152,7 +154,8 @@
|
|||
"editor": {
|
||||
"language": "scala",
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -178,7 +181,8 @@
|
|||
"editor": {
|
||||
"language": "python",
|
||||
"editOnDblClick": false,
|
||||
"completionKey": "TAB"
|
||||
"completionKey": "TAB",
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -188,7 +192,8 @@
|
|||
"properties": {},
|
||||
"editor": {
|
||||
"language": "python",
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": true
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
@ -227,7 +232,8 @@
|
|||
},
|
||||
"editor": {
|
||||
"language": "r",
|
||||
"editOnDblClick": false
|
||||
"editOnDblClick": false,
|
||||
"completionSupport": true
|
||||
}
|
||||
}
|
||||
]
|
||||
|
|
|
|||
|
|
@ -709,42 +709,6 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
|
|||
$scope.aceLoaded = function(_editor) {
|
||||
let langTools = ace.require('ace/ext/language_tools');
|
||||
let Range = ace.require('ace/range').Range;
|
||||
let filteredList = ace.require('ace/autocomplete').FilteredList;
|
||||
|
||||
// ref: https://github.com/ajaxorg/ace/blob/5021d0193d9f2bba5a978d0b1d7a4f73d18ce713/lib/ace/autocomplete.js#L454
|
||||
filteredList.prototype.setFilter = function(str) {
|
||||
let matches;
|
||||
if (str.length > this.filterText && str.lastIndexOf(this.filterText, 0) === 0) {
|
||||
matches = this.filtered;
|
||||
} else {
|
||||
matches = this.all;
|
||||
}
|
||||
|
||||
this.filterText = str;
|
||||
matches = this.filterCompletions(matches, this.filterText);
|
||||
matches = matches.sort(function(a, b) {
|
||||
return b.exactMatch - a.exactMatch || b.score - a.score;
|
||||
});
|
||||
let prev = null;
|
||||
|
||||
// Meta empty means item is supplied from backend
|
||||
let isMetaEmpty = false;
|
||||
if (matches[0] !== undefined && matches[0]['meta'] === '') {
|
||||
isMetaEmpty = true;
|
||||
}
|
||||
matches = matches.filter(function(item) {
|
||||
if (isMetaEmpty && item.meta !== '') {
|
||||
return false;
|
||||
}
|
||||
let caption = item.snippet || item.caption || item.value;
|
||||
if (caption === prev) {
|
||||
return false;
|
||||
}
|
||||
prev = caption;
|
||||
return true;
|
||||
});
|
||||
this.filtered = matches;
|
||||
};
|
||||
|
||||
_editor.$blockScrolling = Infinity;
|
||||
$scope.editor = _editor;
|
||||
|
|
@ -999,8 +963,73 @@ function ParagraphCtrl($scope, $rootScope, $route, $window, $routeParams, $locat
|
|||
}
|
||||
};
|
||||
|
||||
// ref: https://github.com/ajaxorg/ace/blob/5021d0193d9f2bba5a978d0b1d7a4f73d18ce713/lib/ace/autocomplete.js#L454
|
||||
const completionSupportWithoutBackend = function(str) {
|
||||
let matches;
|
||||
if (str.length > this.filterText && str.lastIndexOf(
|
||||
this.filterText, 0) === 0) {
|
||||
matches = this.filtered;
|
||||
} else {
|
||||
matches = this.all;
|
||||
}
|
||||
|
||||
this.filterText = str;
|
||||
matches = this.filterCompletions(matches, this.filterText);
|
||||
matches = matches.sort(function(a, b) {
|
||||
return b.exactMatch - a.exactMatch || b.score - a.score;
|
||||
});
|
||||
let prev = null;
|
||||
|
||||
matches = matches.filter(function(item) {
|
||||
let caption = item.snippet || item.caption || item.value;
|
||||
if (caption === prev) {
|
||||
return false;
|
||||
}
|
||||
prev = caption;
|
||||
return true;
|
||||
});
|
||||
this.filtered = matches;
|
||||
};
|
||||
|
||||
const completionSupportWithBackend = function(str) {
|
||||
let matches;
|
||||
if (str.length > this.filterText && str.lastIndexOf(
|
||||
this.filterText, 0) === 0) {
|
||||
matches = this.filtered;
|
||||
} else {
|
||||
matches = this.all;
|
||||
}
|
||||
this.filterText = str;
|
||||
matches = this.filterCompletions(matches, this.filterText);
|
||||
matches = matches.sort(function(a, b) {
|
||||
return b.exactMatch - a.exactMatch || b.score - a.score;
|
||||
});
|
||||
let prev = null;
|
||||
|
||||
matches = matches.filter(function(item) {
|
||||
if (item.meta !== '') {
|
||||
return false;
|
||||
}
|
||||
let caption = item.snippet || item.caption || item.value;
|
||||
if (caption === prev) {
|
||||
return false;
|
||||
}
|
||||
prev = caption;
|
||||
return true;
|
||||
});
|
||||
this.filtered = matches;
|
||||
};
|
||||
|
||||
const handleFocus = function(focused, isDigestPass) {
|
||||
$scope.paragraphFocused = focused;
|
||||
if (focused) {
|
||||
let filteredList = ace.require('ace/autocomplete').FilteredList;
|
||||
if ($scope.paragraph.config.editorSetting.completionSupport) {
|
||||
filteredList.prototype.setFilter = completionSupportWithBackend;
|
||||
} else {
|
||||
filteredList.prototype.setFilter = completionSupportWithoutBackend;
|
||||
}
|
||||
}
|
||||
|
||||
if ($scope.editor) {
|
||||
$scope.editor.setHighlightActiveLine(focused);
|
||||
|
|
|
|||
Loading…
Reference in a new issue