diff --git a/context.go b/context.go index 92a6962..730894a 100644 --- a/context.go +++ b/context.go @@ -939,7 +939,7 @@ func (t *transitionMutatorImpl) bottomUpMutator(mctx BottomUpMutatorContext) { if len(variations) == 1 && variations[0] == "" { // Module is not split, just apply the transition mc.context.convertDepsToVariation(mc.module, 0, - chooseDepByIndexes(mc.name, outgoingTransitionCache)) + chooseDepByIndexes(mc.mutator.name, outgoingTransitionCache)) } else { mc.createVariationsWithTransition(variations, outgoingTransitionCache) } @@ -1751,12 +1751,12 @@ func newVariant(module *moduleInfo, mutatorName string, variationName string, return variant{newVariantName, newVariations, newDependencyVariations} } -func (c *Context) createVariations(origModule *moduleInfo, mutatorName string, +func (c *Context) createVariations(origModule *moduleInfo, mutator *mutatorInfo, depChooser depChooser, variationNames []string, local bool) (modulesOrAliases, []error) { if len(variationNames) == 0 { panic(fmt.Errorf("mutator %q passed zero-length variation list for module %q", - mutatorName, origModule.Name())) + mutator.name, origModule.Name())) } var newModules modulesOrAliases @@ -1782,7 +1782,7 @@ func (c *Context) createVariations(origModule *moduleInfo, mutatorName string, newModule.reverseDeps = nil newModule.forwardDeps = nil newModule.logicModule = newLogicModule - newModule.variant = newVariant(origModule, mutatorName, variationName, local) + newModule.variant = newVariant(origModule, mutator.name, variationName, local) newModule.properties = newProperties newModule.providers = slices.Clone(origModule.providers) newModule.providerInitialValueHashes = slices.Clone(origModule.providerInitialValueHashes) @@ -3114,7 +3114,7 @@ func (c *Context) runMutator(config interface{}, mutator *mutatorInfo, config: config, module: module, }, - name: mutator.name, + mutator: mutator, pauseCh: pause, } diff --git a/module_ctx.go b/module_ctx.go index d71f053..4fc949b 100644 --- a/module_ctx.go +++ b/module_ctx.go @@ -825,7 +825,7 @@ func (m *baseModuleContext) EarlyGetMissingDependencies() []string { type mutatorContext struct { baseModuleContext - name string + mutator *mutatorInfo reverseDeps []reverseDep rename []rename replace []replace @@ -1002,20 +1002,20 @@ func (BaseDependencyTag) dependencyTag(DependencyTag) { var _ DependencyTag = BaseDependencyTag{} func (mctx *mutatorContext) MutatorName() string { - return mctx.name + return mctx.mutator.name } func (mctx *mutatorContext) CreateVariations(variationNames ...string) []Module { - depChooser := chooseDepInherit(mctx.name, mctx.defaultVariation) + depChooser := chooseDepInherit(mctx.mutator.name, mctx.defaultVariation) return mctx.createVariations(variationNames, depChooser, false) } func (mctx *mutatorContext) createVariationsWithTransition(variationNames []string, outgoingTransitions [][]string) []Module { - return mctx.createVariations(variationNames, chooseDepByIndexes(mctx.name, outgoingTransitions), false) + return mctx.createVariations(variationNames, chooseDepByIndexes(mctx.mutator.name, outgoingTransitions), false) } func (mctx *mutatorContext) CreateLocalVariations(variationNames ...string) []Module { - depChooser := chooseDepInherit(mctx.name, mctx.defaultVariation) + depChooser := chooseDepInherit(mctx.mutator.name, mctx.defaultVariation) return mctx.createVariations(variationNames, depChooser, true) } @@ -1031,7 +1031,7 @@ func (mctx *mutatorContext) SetVariationProvider(module Module, provider AnyProv func (mctx *mutatorContext) createVariations(variationNames []string, depChooser depChooser, local bool) []Module { var ret []Module - modules, errs := mctx.context.createVariations(mctx.module, mctx.name, depChooser, variationNames, local) + modules, errs := mctx.context.createVariations(mctx.module, mctx.mutator, depChooser, variationNames, local) if len(errs) > 0 { mctx.errs = append(mctx.errs, errs...) } @@ -1062,7 +1062,7 @@ func (mctx *mutatorContext) AliasVariation(variationName string) { } for _, variant := range mctx.newVariations { - if variant.moduleOrAliasVariant().variations[mctx.name] == variationName { + if variant.moduleOrAliasVariant().variations[mctx.mutator.name] == variationName { alias := &moduleAlias{ variant: mctx.module.variant, target: variant.moduleOrAliasTarget(), @@ -1076,13 +1076,13 @@ func (mctx *mutatorContext) AliasVariation(variationName string) { var foundVariations []string for _, variant := range mctx.newVariations { - foundVariations = append(foundVariations, variant.moduleOrAliasVariant().variations[mctx.name]) + foundVariations = append(foundVariations, variant.moduleOrAliasVariant().variations[mctx.mutator.name]) } panic(fmt.Errorf("no %q variation in module variations %q", variationName, foundVariations)) } func (mctx *mutatorContext) CreateAliasVariation(aliasVariationName, targetVariationName string) { - newVariant := newVariant(mctx.module, mctx.name, aliasVariationName, false) + newVariant := newVariant(mctx.module, mctx.mutator.name, aliasVariationName, false) for _, moduleOrAlias := range mctx.module.splitModules { if moduleOrAlias.moduleOrAliasVariant().variations.equal(newVariant.variations) { @@ -1095,7 +1095,7 @@ func (mctx *mutatorContext) CreateAliasVariation(aliasVariationName, targetVaria } for _, variant := range mctx.newVariations { - if variant.moduleOrAliasVariant().variations[mctx.name] == targetVariationName { + if variant.moduleOrAliasVariant().variations[mctx.mutator.name] == targetVariationName { // Append the alias here so that it comes after any aliases created by AliasVariation. mctx.module.splitModules = append(mctx.module.splitModules, &moduleAlias{ variant: newVariant, @@ -1107,14 +1107,14 @@ func (mctx *mutatorContext) CreateAliasVariation(aliasVariationName, targetVaria var foundVariations []string for _, variant := range mctx.newVariations { - foundVariations = append(foundVariations, variant.moduleOrAliasVariant().variations[mctx.name]) + foundVariations = append(foundVariations, variant.moduleOrAliasVariant().variations[mctx.mutator.name]) } panic(fmt.Errorf("no %q variation in module variations %q", targetVariationName, foundVariations)) } func (mctx *mutatorContext) SetDependencyVariation(variationName string) { mctx.context.convertDepsToVariation(mctx.module, 0, chooseDepExplicit( - mctx.name, variationName, nil)) + mctx.mutator.name, variationName, nil)) } func (mctx *mutatorContext) SetDefaultDependencyVariation(variationName *string) {