@@ -48,6 +48,7 @@ define(function (require, exports, module) {
4848 StringUtils = require ( "utils/StringUtils" ) ,
4949 Commands = require ( "command/Commands" ) ,
5050 ProjectManager = require ( "project/ProjectManager" ) ,
51+ LanguageManager = require ( "language/LanguageManager" ) ,
5152 KeyEvent = require ( "utils/KeyEvent" ) ,
5253 ModalBar = require ( "widgets/ModalBar" ) . ModalBar ,
5354 StringMatch = require ( "utils/StringMatch" ) ;
@@ -97,9 +98,9 @@ define(function (require, exports, module) {
9798 /**
9899 * Defines API for new QuickOpen plug-ins
99100 */
100- function QuickOpenPlugin ( name , fileTypes , done , search , match , itemFocus , itemSelect , resultsFormatter ) {
101+ function QuickOpenPlugin ( name , languageIds , done , search , match , itemFocus , itemSelect , resultsFormatter ) {
101102 this . name = name ;
102- this . fileTypes = fileTypes ;
103+ this . languageIds = languageIds ;
103104 this . done = done ;
104105 this . search = search ;
105106 this . match = match ;
@@ -112,7 +113,7 @@ define(function (require, exports, module) {
112113 * Creates and registers a new QuickOpenPlugin
113114 *
114115 * @param { name: string,
115- * fileTypes :Array.<string>,
116+ * languageIds :Array.<string>,
116117 * done: function(),
117118 * search: function(string, !StringMatch.StringMatcher):Array.<SearchResult|string>,
118119 * match: function(string):boolean,
@@ -124,8 +125,8 @@ define(function (require, exports, module) {
124125 * Parameter Documentation:
125126 *
126127 * name - plug-in name, **must be unique**
127- * fileTypes - file types array. Example: ["js ", "css", "txt "]. An empty array
128- * indicates all file types .
128+ * languageIds - language Ids array. Example: ["javascript ", "css", "html "]. An empty array
129+ * indicates all language IDs .
129130 * done - called when quick open is complete. Plug-in should clear its internal state.
130131 * search - takes a query string and a StringMatcher (the use of which is optional but can speed up your searches) and returns an array of strings that match the query.
131132 * match - takes a query string and returns true if this plug-in wants to provide
@@ -141,9 +142,17 @@ define(function (require, exports, module) {
141142 * cancels Quick Open (via Esc), those changes are automatically reverted.
142143 */
143144 function addQuickOpenPlugin ( pluginDef ) {
145+ if ( pluginDef . fileTypes ) {
146+ console . warn ( "Using fileTypes for QuickOpen plugins is deprecated. Use languageIds instead." ) ;
147+ pluginDef . languageIds = pluginDef . fileTypes . map ( function ( extension ) {
148+ return LanguageManager . getLanguageForPath ( "file." + extension ) . getId ( ) ;
149+ } ) ;
150+ delete pluginDef . fileTypes ;
151+ }
152+
144153 plugins . push ( new QuickOpenPlugin (
145154 pluginDef . name ,
146- pluginDef . fileTypes ,
155+ pluginDef . languageIds ,
147156 pluginDef . done ,
148157 pluginDef . search ,
149158 pluginDef . match ,
@@ -529,14 +538,13 @@ define(function (require, exports, module) {
529538 // Try to invoke a search plugin
530539 var curDoc = DocumentManager . getCurrentDocument ( ) ;
531540 if ( curDoc ) {
532- var filename = _filenameFromPath ( curDoc . file . fullPath , true ) ;
533- var extension = filename . slice ( filename . lastIndexOf ( "." ) + 1 , filename . length ) ;
541+ var languageId = curDoc . getLanguage ( ) . getId ( ) ;
534542
535543 var i ;
536544 for ( i = 0 ; i < plugins . length ; i ++ ) {
537545 var plugin = plugins [ i ] ;
538- var extensionMatch = plugin . fileTypes . indexOf ( extension ) !== - 1 || plugin . fileTypes . length === 0 ;
539- if ( extensionMatch && plugin . match && plugin . match ( query ) ) {
546+ var LanguageIdMatch = plugin . languageIds . indexOf ( languageId ) !== - 1 || plugin . languageIds . length === 0 ;
547+ if ( LanguageIdMatch && plugin . match && plugin . match ( query ) ) {
540548 currentPlugin = plugin ;
541549
542550 // Look up the StringMatcher for this plugin.
0 commit comments