cleanup and tweaking...

Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
Alex A. Naanou 2017-06-22 04:58:27 +03:00
parent 941df6ef14
commit 2754cf5457

View File

@ -679,7 +679,11 @@ var FeatureSetProto = {
// - by priority // - by priority
// - by dependency (detect loops/errors) // - by dependency (detect loops/errors)
// //
_buildFeatureListReorder: function(lst, filter){ // XXX differences to .buildFeatureList(..):
// - order is slightly different -- within expectations...
// - this includes meta-features...
// this seems to be more logical and more flexible...
_buildFeatureList: function(lst, filter){
var all = this.features var all = this.features
lst = (lst == null || lst == '*') ? all : lst lst = (lst == null || lst == '*') ? all : lst
lst = lst.constructor !== Array ? [lst] : lst lst = lst.constructor !== Array ? [lst] : lst
@ -822,7 +826,10 @@ var FeatureSetProto = {
// NOTE: this stage does not track suggested feature dependencies... // NOTE: this stage does not track suggested feature dependencies...
// NOTE: we do not need loop detection active here... // NOTE: we do not need loop detection active here...
var s = Object.keys( var s = Object.keys(
expand('suggested', Object.keys(features), {}, { disabled: disabled })) expand('suggested', Object.keys(features), {},
{
disabled: disabled,
}))
.filter(function(f){ return !(f in features) }) .filter(function(f){ return !(f in features) })
// get suggestion dependencies... // get suggestion dependencies...
// NOTE: we do not care bout missing here... // NOTE: we do not care bout missing here...
@ -858,10 +865,10 @@ var FeatureSetProto = {
// user filter... // user filter...
// NOTE: we build this out of the full feature list... // NOTE: we build this out of the full feature list...
var filtered_out = filter ? disabled = disabled
all.filter(function(n){ return !filter.call(that, n) }) .concat(filter ?
: [] all.filter(function(n){ return !filter.call(that, n) })
disabled = disabled.concat(filtered_out) : [])
// build exclusive groups... // build exclusive groups...
var exclusive = {} var exclusive = {}
@ -883,10 +890,11 @@ var FeatureSetProto = {
// Handle exclusive feature groups and aliases... // Handle exclusive feature groups and aliases...
// //
var conflicts = {} var conflicts = {}
var done = []
Object.keys(features) Object.keys(features)
.forEach(function(f){ .forEach(function(f){
// alias... // alias...
while(f in exclusive){ while(f in exclusive && done.indexOf(f) < 0){
var candidates = (exclusive[f] || []) var candidates = (exclusive[f] || [])
.filter(function(c){ return c in features }) .filter(function(c){ return c in features })
@ -903,15 +911,20 @@ var FeatureSetProto = {
} }
// remove the alias... // remove the alias...
delete features[f] // NOTE: exclusive tag can match a feature tag, thus
// we do not want to delete such tags...
if(!(f in that)){
delete features[f]
}
// replace dependencies... // replace dependencies...
Object.keys(features) Object.keys(features)
.forEach(function(e){ .forEach(function(e){
var i = features[e].indexOf(f) var i = features[e] ? features[e].indexOf(f) : -1
i >= 0 i >= 0
&& features[e].splice(i, 1, target) && features[e].splice(i, 1, target)
}) })
f = target f = target
done.push(f)
} }
// exclusive feature... // exclusive feature...
@ -1018,7 +1031,6 @@ var FeatureSetProto = {
var list = Object.keys(features) var list = Object.keys(features)
list.forEach(function(f){ expanddeps(list, f) }) list.forEach(function(f){ expanddeps(list, f) })
// sort by priority... // sort by priority...
// //
// NOTE: this will attempt to only move features with explicitly // NOTE: this will attempt to only move features with explicitly
@ -1102,7 +1114,6 @@ var FeatureSetProto = {
disabled: disabled, disabled: disabled,
excluded: excluded, excluded: excluded,
filtered_out: filtered_out,
// XXX should these be in a error block??? // XXX should these be in a error block???
missing: missing, missing: missing,
@ -1110,8 +1121,9 @@ var FeatureSetProto = {
conflicts: conflicts, conflicts: conflicts,
sort_loop_error: loop_limit <= 0, sort_loop_error: loop_limit <= 0,
//features: features, depends: features,
//rev_features: rev_features, depended: rev_features,
//suggests: suggested,
//exclusive: exclusive, //exclusive: exclusive,
} }
}, },
@ -1126,18 +1138,23 @@ var FeatureSetProto = {
obj = obj || (this.__actions__ || actions.Actions)() obj = obj || (this.__actions__ || actions.Actions)()
lst = lst.constructor !== Array ? [lst] : lst lst = lst.constructor !== Array ? [lst] : lst
var features = this._buildFeatureListReorder(lst, var unapplicable = []
function(f){ var features = this._buildFeatureList(lst,
function(n){
var f = this[n] var f = this[n]
// check applicability... // check applicability if possible...
if(f.isApplicable && !f.isApplicable.call(this, obj)){ if(f && f.isApplicable && !f.isApplicable.call(this, obj)){
//unapplicable.push(n) unapplicable.push(n)
return false return false
} }
return true return true
}) })
lst = features.list lst = features.list
// XXX STUB: adapter code, remove when done...
features.unapplicable = unapplicable
features.features = features.list
// check for conflicts... // check for conflicts...
/*/ XXX need to update this section... /*/ XXX need to update this section...
if(Object.keys(features.conflicts).length != 0 if(Object.keys(features.conflicts).length != 0