@@ -38,11 +38,24 @@ define(function (require, exports, module) {
3838 JSONUtils = brackets . getModule ( "language/JSONUtils" ) ,
3939 Strings = brackets . getModule ( "strings" ) ,
4040 ThemeManager = brackets . getModule ( "view/ThemeManager" ) ,
41+ CodeInspection = brackets . getModule ( "language/CodeInspection" ) ,
4142 _ = brackets . getModule ( "thirdparty/lodash" ) ,
42- data = JSON . parse ( require ( "text!data.json" ) ) ,
43+ languages = LanguageManager . getLanguages ( ) ,
4344 isPrefDocument = false ,
4445 isPrefHintsEnabled = false ;
4546
47+ // Stores data of preferences used by Brackets and its core/thirdparty extensions.
48+ var data = {
49+ language : {
50+ type : "object" ,
51+ description : Strings . DESCRIPTION_LANGUAGE
52+ } ,
53+ path : {
54+ type : "object" ,
55+ description : Strings . DESCRIPTION_PATH
56+ }
57+ } ;
58+
4659 var stringMatcherOptions = {
4760 preferPrefixMatches : true
4861 } ;
@@ -85,7 +98,7 @@ define(function (require, exports, module) {
8598 return ( / ^ \. ? b r a c k e t s \. j s o n $ / ) . test ( document . file . _name ) ;
8699 }
87100
88- // Set listeners on preference and editor changes.
101+ // Set listeners on preference, editor and language changes.
89102 PreferencesManager . on ( "change" , "showCodeHints" , function ( ) {
90103 isPrefHintsEnabled = _isPrefHintsEnabled ( ) ;
91104 } ) ;
@@ -98,6 +111,9 @@ define(function (require, exports, module) {
98111 }
99112 isPrefHintsEnabled = _isPrefHintsEnabled ( ) ;
100113 } ) ;
114+ LanguageManager . on ( "languageAdded" , function ( ) {
115+ languages = LanguageManager . getLanguages ( ) ;
116+ } ) ;
101117
102118 /*
103119 * Returns a sorted and formatted list of hints with the query substring
@@ -169,11 +185,6 @@ define(function (require, exports, module) {
169185 data [ pref ] . keys = _ . clone ( preference . keys ) ;
170186 }
171187 } ) ;
172-
173- // Add installed themes to code hints.
174- data [ "themes.theme" ] . values = ThemeManager . getAllThemes ( ) . map ( function ( theme ) {
175- return theme . name ;
176- } ) ;
177188 }
178189
179190 /**
@@ -224,7 +235,7 @@ define(function (require, exports, module) {
224235 if ( data [ ctxInfo . parentKeyName ] && data [ ctxInfo . parentKeyName ] . keys ) {
225236 keys = data [ ctxInfo . parentKeyName ] . keys ;
226237 } else if ( ctxInfo . parentKeyName === "language" ) {
227- keys = LanguageManager . getLanguages ( ) ;
238+ keys = languages ;
228239 option . type = "object" ;
229240 } else {
230241 keys = data ;
@@ -235,7 +246,7 @@ define(function (require, exports, module) {
235246 var match = StringMatch . stringMatch ( key , query , stringMatcherOptions ) ;
236247 if ( match ) {
237248 match . type = keys [ key ] . type || option . type ;
238- match . description = keys [ key ] . description || Strings [ keys [ key ] . string ] || null ;
249+ match . description = keys [ key ] . description || null ;
239250 return match ;
240251 }
241252 }
@@ -257,9 +268,15 @@ define(function (require, exports, module) {
257268 } else if ( option && option . values && ( [ "number" , "string" ] . indexOf ( option . type ) !== - 1 ||
258269 ( option . type === "array" && ctxInfo . isArray ) ) ) {
259270 values = option . values ;
271+ } else if ( ctxInfo . isArray && ctxInfo . keyName === "linting.prefer" && languages [ ctxInfo . parentKeyName ] ) {
272+ values = CodeInspection . getProviderIDsForLanguage ( ctxInfo . parentKeyName ) ;
273+ } else if ( ctxInfo . keyName === "themes.theme" ) {
274+ values = ThemeManager . getAllThemes ( ) . map ( function ( theme ) {
275+ return theme . name ;
276+ } ) ;
260277 } else if ( ctxInfo . parentKeyName === "language.fileExtensions" ||
261278 ctxInfo . parentKeyName === "language.fileNames" ) {
262- values = Object . keys ( LanguageManager . getLanguages ( ) ) ;
279+ values = Object . keys ( languages ) ;
263280 } else {
264281 return null ;
265282 }
@@ -269,7 +286,7 @@ define(function (require, exports, module) {
269286 var match = StringMatch . stringMatch ( value , query , stringMatcherOptions ) ;
270287 if ( match ) {
271288 match . type = option . valueType || option . type ;
272- match . description = Strings [ option . string ] || option . description || null ;
289+ match . description = option . description || null ;
273290 return match ;
274291 }
275292 } ) ;
0 commit comments