Skip to content
This repository has been archived by the owner on Mar 31, 2024. It is now read-only.

Commit

Permalink
Move request body autocomplete to new engine
Browse files Browse the repository at this point in the history
This commit moves the logic of the request body autocomplet to use the new engine current used by url and url param suggestions.

Also change $FIELD$ & friends notation to {field}, {index} etc.

Closes elastic#168
  • Loading branch information
bleskes committed Apr 23, 2014
1 parent d00f476 commit 498272d
Show file tree
Hide file tree
Showing 27 changed files with 847 additions and 552 deletions.
47 changes: 29 additions & 18 deletions sense/app/autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
define([
'history',
'kb',
'mappings',
'ace',
'jquery',
'utils',
'autocomplete/json_body_autocomplete',
'autocomplete/engine',
'autocomplete/url_pattern_matcher',
'_',
'jquery-ui',
'ace_ext_language_tools'
], function (history, kb, mappings, ace, $, utils, json_body_autocomplete, autocomplete_engine, url_pattern_matcher, _) {
'history',
'kb',
'mappings',
'ace',
'jquery',
'utils',
'autocomplete/engine',
'autocomplete/url_pattern_matcher',
'_',
'jquery-ui',
'ace_ext_language_tools'
], function (history, kb, mappings, ace, $, utils, autocomplete_engine, url_pattern_matcher, _) {
'use strict';

var AceRange = ace.require('ace/range').Range;
Expand Down Expand Up @@ -119,7 +118,7 @@ define([

var valueToInsert = termAsString;
var templateInserted = false;
if (context.addTemplate && typeof term.template != "undefined") {
if (context.addTemplate && !_.isUndefined(term.template) && !_.isNull(term.template)) {
var indentedTemplateLines = utils.jsonToString(term.template, true).split("\n");
var currentIndentation = session.getLine(context.rangeToReplace.start.row);
currentIndentation = currentIndentation.match(/^\s*/)[0];
Expand Down Expand Up @@ -349,7 +348,7 @@ define([
insertingRelativeToToken = 0;
context.rangeToReplace = new AceRange(
pos.row, context.updatedForToken.start, pos.row,
context.updatedForToken.start + context.updatedForToken.value.length
context.updatedForToken.start + context.updatedForToken.value.length
);
context.replacingToken = true;
break;
Expand All @@ -358,7 +357,7 @@ define([
insertingRelativeToToken = 0;
context.rangeToReplace = new AceRange(
pos.row, context.updatedForToken.start, pos.row,
context.updatedForToken.start + context.updatedForToken.value.length
context.updatedForToken.start + context.updatedForToken.value.length
);
context.replacingToken = true;
}
Expand Down Expand Up @@ -579,7 +578,20 @@ define([
console.log("Can't extract a valid body token path.");
return context;
}
json_body_autocomplete.populateContext(ret.bodyTokenPath, context);


// needed for scope linking + global term resolving
context.endpointComponentResolver = kb.getEndpointBodyCompleteComponents;
context.globalComponentResolver = kb.getGlobalAutocompleteComponents;
var components;
if (context.endpoint) {
components = context.endpoint.bodyAutocompleteRootComponents;
}
else {
components = kb.getUnmatchedEndpointComponents();
}
autocomplete_engine.populateContext(ret.bodyTokenPath, context, editor, true, components);

return context;
}

Expand Down Expand Up @@ -1003,6 +1015,5 @@ define([

return Autocomplete;
}

)
;
Loading

0 comments on commit 498272d

Please sign in to comment.