From 123940e25acae8827155f48977a4d9cad4ceebcd Mon Sep 17 00:00:00 2001 From: Antonin Hildebrand Date: Sun, 5 Jun 2016 22:12:53 +0200 Subject: [PATCH] devtools: include repl specials into code completion --- .../devtools/front_end/console/DiracPrompt.js | 9 +++++++++ resources/unpacked/devtools/front_end/externs.js | 15 ++++++++++----- .../unpacked/devtools/front_end/ui/suggestBox.css | 8 ++++++++ 3 files changed, 27 insertions(+), 5 deletions(-) diff --git a/resources/unpacked/devtools/front_end/console/DiracPrompt.js b/resources/unpacked/devtools/front_end/console/DiracPrompt.js index 6a7d539ee7..a1ef3bd326 100644 --- a/resources/unpacked/devtools/front_end/console/DiracPrompt.js +++ b/resources/unpacked/devtools/front_end/console/DiracPrompt.js @@ -549,6 +549,13 @@ WebInspector.DiracPromptWithHistory.prototype = { }); }; + const annotateReplSpecials = symbols => { + return symbols.filter(symbol => symbol.startsWith(input)).map(symbol => ({ + title: symbol || "?", + className: suggestStyle("suggest-cljs-repl suggest-cljs-special") + })); + }; + const localsPromise = dirac.extractScopeInfoFromScopeChainAsync(debuggerModel.selectedCallFrame()).then(extractAndAnnotateLocals); const currentNamespaceSymbolsPromise = dirac.extractNamespaceSymbolsAsync(this._currentClojureScriptNamespace).then(annotateSymbols.bind(this, "suggest-cljs-in-ns")); const namespaceNamesPromise = dirac.extractNamespacesAsync().then(extractNamespaceNames).then(annotateNamespaceNames.bind(this, "suggest-cljs-ns")); @@ -559,9 +566,11 @@ WebInspector.DiracPromptWithHistory.prototype = { const macroNamespaceAliasesPromise = currentNamespaceDescriptor.then(annotateAliasesOrRefers.bind(this, "macroNamespaceAliases", "as ", "suggest-ns-alias suggest-cljs-macro")); const namespaceRefersPromise = currentNamespaceDescriptor.then(annotateAliasesOrRefers.bind(this, "namespaceRefers", "in ", "suggest-refer")); const macroRefersPromise = currentNamespaceDescriptor.then(annotateAliasesOrRefers.bind(this, "macroRefers", "in ", "suggest-refer suggest-cljs-macro")); + const replSpecialsPromise = dirac.getReplSpecialsAsync().then(annotateReplSpecials); // order matters here, see _markAliasedCompletions below const jobs = [ + replSpecialsPromise, localsPromise, currentNamespaceSymbolsPromise, namespaceRefersPromise, diff --git a/resources/unpacked/devtools/front_end/externs.js b/resources/unpacked/devtools/front_end/externs.js index 2738cfa9aa..7c3aa3bbca 100644 --- a/resources/unpacked/devtools/front_end/externs.js +++ b/resources/unpacked/devtools/front_end/externs.js @@ -450,7 +450,7 @@ var dirac = { /** * @param {Element} textAreaElement * @param {boolean} useParinfer - * @returns {!CodeMirror} + * @return {!CodeMirror} */ adoptPrompt: function(textAreaElement, useParinfer) {}, /** @@ -462,25 +462,30 @@ var dirac = { /** * @param {string} ns * @param {string} ext - * @returns {string} + * @return {string} */ nsToRelpath: function(ns, ext) {}, /** * @param {string} name - * @returns {string} + * @return {string} */ getFunctionName: function(name) {}, /** * @param {string} name - * @returns {string} + * @return {string} */ getFullFunctionName: function(name) {}, + /** + * @return {!Promise.>} + */ + getReplSpecialsAsync: function() {}, + /** * @param {string} source - * @returns {?dirac.NamespaceDescriptor} + * @return {?dirac.NamespaceDescriptor} */ parseNsFromSource: function(source) {}, diff --git a/resources/unpacked/devtools/front_end/ui/suggestBox.css b/resources/unpacked/devtools/front_end/ui/suggestBox.css index 01ce43ee1f..961b92f58b 100644 --- a/resources/unpacked/devtools/front_end/ui/suggestBox.css +++ b/resources/unpacked/devtools/front_end/ui/suggestBox.css @@ -145,6 +145,10 @@ border-left: 3px solid #aed17d; } +.suggest-box .suggest-box-content-item.suggest-cljs-special .prologue { + border-left: 3px solid #e6bf73; +} + .suggest-box .suggest-box-content-item.suggest-cljs-ns .prologue::after { content: "ns"; } @@ -173,6 +177,10 @@ content: "refer"; } +.suggest-box .suggest-box-content-item.suggest-cljs-repl .prologue::after { + content: "repl"; +} + .suggest-box .suggest-box-content-item.suggest-cljs-aliased .prefix { color: #ccc; }