-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathjavascript.js
More file actions
1 lines (1 loc) · 1.44 KB
/
javascript.js
File metadata and controls
1 lines (1 loc) · 1.44 KB
1
define(function(require,exports,module){const QuickOpen=require("search/QuickOpen"),QuickOpenHelper=require("search/QuickOpenHelper"),JSUtils=require("language/JSUtils"),DocumentManager=require("document/DocumentManager"),StringMatch=require("utils/StringMatch");function FileLocation(fullPath,line,chFrom,chTo,functionName){this.fullPath=fullPath,this.line=line,this.chFrom=chFrom,this.chTo=chTo,this.functionName=functionName}function createFunctionList(){var doc=DocumentManager.getCurrentDocument();if(doc){var functionList=[],docText=doc.getText(),functions;return JSUtils.findAllMatchingFunctionsInText(docText,"*").forEach(function(funcEntry){functionList.push(new FileLocation(null,funcEntry.nameLineStart,funcEntry.columnStart,funcEntry.columnEnd,funcEntry.label||funcEntry.name))}),functionList}}function search(query,matcher){var functionList=matcher.functionList;functionList||(functionList=createFunctionList(),matcher.functionList=functionList),query=query.slice(query.indexOf("@")+1,query.length);var filteredList=$.map(functionList,function(fileLocation){var searchResult=matcher.match(fileLocation.functionName,query);return searchResult&&(searchResult.fileLocation=fileLocation),searchResult});return StringMatch.basicMatchSort(filteredList),filteredList}QuickOpen.addQuickOpenPlugin({name:"JavaScript functions",languageIds:["javascript"],search:search,match:QuickOpenHelper.match,itemFocus:QuickOpenHelper.itemFocus,itemSelect:QuickOpenHelper.itemSelect})});