@@ -48,6 +48,7 @@ define(function (require, exports, module) {
48
48
StringUtils = require ( "utils/StringUtils" ) ,
49
49
Commands = require ( "command/Commands" ) ,
50
50
ProjectManager = require ( "project/ProjectManager" ) ,
51
+ LanguageManager = require ( "language/LanguageManager" ) ,
51
52
KeyEvent = require ( "utils/KeyEvent" ) ,
52
53
ModalBar = require ( "widgets/ModalBar" ) . ModalBar ,
53
54
StringMatch = require ( "utils/StringMatch" ) ;
@@ -97,9 +98,9 @@ define(function (require, exports, module) {
97
98
/**
98
99
* Defines API for new QuickOpen plug-ins
99
100
*/
100
- function QuickOpenPlugin ( name , fileTypes , done , search , match , itemFocus , itemSelect , resultsFormatter ) {
101
+ function QuickOpenPlugin ( name , languageIds , done , search , match , itemFocus , itemSelect , resultsFormatter ) {
101
102
this . name = name ;
102
- this . fileTypes = fileTypes ;
103
+ this . languageIds = languageIds ;
103
104
this . done = done ;
104
105
this . search = search ;
105
106
this . match = match ;
@@ -112,7 +113,7 @@ define(function (require, exports, module) {
112
113
* Creates and registers a new QuickOpenPlugin
113
114
*
114
115
* @param { name: string,
115
- * fileTypes :Array.<string>,
116
+ * languageIds :Array.<string>,
116
117
* done: function(),
117
118
* search: function(string, !StringMatch.StringMatcher):Array.<SearchResult|string>,
118
119
* match: function(string):boolean,
@@ -124,8 +125,8 @@ define(function (require, exports, module) {
124
125
* Parameter Documentation:
125
126
*
126
127
* 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 .
129
130
* done - called when quick open is complete. Plug-in should clear its internal state.
130
131
* 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.
131
132
* match - takes a query string and returns true if this plug-in wants to provide
@@ -141,9 +142,17 @@ define(function (require, exports, module) {
141
142
* cancels Quick Open (via Esc), those changes are automatically reverted.
142
143
*/
143
144
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
+
144
153
plugins . push ( new QuickOpenPlugin (
145
154
pluginDef . name ,
146
- pluginDef . fileTypes ,
155
+ pluginDef . languageIds ,
147
156
pluginDef . done ,
148
157
pluginDef . search ,
149
158
pluginDef . match ,
@@ -529,14 +538,13 @@ define(function (require, exports, module) {
529
538
// Try to invoke a search plugin
530
539
var curDoc = DocumentManager . getCurrentDocument ( ) ;
531
540
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 ( ) ;
534
542
535
543
var i ;
536
544
for ( i = 0 ; i < plugins . length ; i ++ ) {
537
545
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 ) ) {
540
548
currentPlugin = plugin ;
541
549
542
550
// Look up the StringMatcher for this plugin.
0 commit comments