See #282. Fix getLanguages for finding by name and namespace
- Was causing "Duplicate option" warnings
This commit is contained in:
parent
9211a03c16
commit
a30dc62510
|
@ -70,6 +70,7 @@
|
|||
"temp": "^0.8.0",
|
||||
"tidy-markdown": "^0.3.2",
|
||||
"typescript-formatter": "~0.1.4",
|
||||
"underscore-plus": "^1.6.6",
|
||||
"yaml-front-matter": "^3.2.3"
|
||||
},
|
||||
"activationCommands": {
|
||||
|
|
|
@ -84,7 +84,7 @@ module.exports = class Beautifiers
|
|||
langOptions = {}
|
||||
for lang in @languages.languages
|
||||
langOptions[lang.name] ?= {}
|
||||
options = _.cloneDeep(langOptions[lang.name])
|
||||
options = langOptions[lang.name]
|
||||
for field, op of lang.options
|
||||
if not op.title?
|
||||
op.title = _plus.uncamelcase(field).split('.')
|
||||
|
@ -143,6 +143,7 @@ module.exports = class Beautifiers
|
|||
lang = @languages.getLanguages(name:langName)?[0]
|
||||
# Use the namespace from language as key prefix
|
||||
prefix = lang.namespace
|
||||
# console.log(langName, lang, prefix, ops)
|
||||
# Iterate over all language options and rename fields
|
||||
for field, op of ops
|
||||
# Rename field
|
||||
|
@ -159,7 +160,7 @@ module.exports = class Beautifiers
|
|||
# console.log('language options', language, languageOptions, result)
|
||||
return _.reduce(languageOptions, ((result, optionDef, optionName) ->
|
||||
# TODO: Add supported beautifiers to option description
|
||||
# console.log('optionDef', optionDef)
|
||||
# console.log('optionDef', optionDef, optionName)
|
||||
if optionDef.beautifiers.length > 0
|
||||
# optionDef.title = "#{optionDef.title} - Supported by #{optionDef.beautifiers.join(', ')}"
|
||||
optionDef.description = "#{optionDef.description} (Supported by #{optionDef.beautifiers.join(', ')})"
|
||||
|
|
|
@ -77,10 +77,10 @@ module.exports = class Languages
|
|||
Get language for grammar and extension
|
||||
###
|
||||
getLanguages: ({name, namespace, grammar, extension}) ->
|
||||
# console.log(grammar, extension, @languages)
|
||||
# console.log('getLanguages', name, namespace, grammar, extension, @languages)
|
||||
_.union(
|
||||
_.filter(@languages, (language) -> _.contains(language.name, name))
|
||||
_.filter(@languages, (language) -> _.contains(language.namespace, namespace))
|
||||
_.filter(@languages, (language) -> _.isEqual(language.name, name))
|
||||
_.filter(@languages, (language) -> _.isEqual(language.namespace, namespace))
|
||||
_.filter(@languages, (language) -> _.contains(language.grammars, grammar))
|
||||
_.filter(@languages, (language) -> _.contains(language.extensions, extension))
|
||||
)
|
Loading…
Reference in New Issue