Prevents priority variables to be renamed into non-priority variables.

When applied to a MGU, it is expected to return another "equivalent" MGU.
546656
public <T extends ImmutableTerm> ImmutableSubstitution<T> prioritizeRenaming(
            ImmutableSubstitution<T> substitution, ImmutableSet<Variable> priorityVariables) {

        ImmutableMultimap<Variable, Variable> renamingMultimap = substitution.getImmutableMap().entrySet().stream()
                .filter(e -> priorityVariables.contains(e.getKey())
                        && (e.getValue() instanceof Variable)
                        && (!priorityVariables.contains(e.getValue())))
                .collect(ImmutableCollectors.toMultimap(
                        e -> (Variable) e.getValue(),
                        Map.Entry::getKey));

        if (renamingMultimap.isEmpty())
            return substitution;

        ImmutableMap<Variable, Variable> renamingMap = renamingMultimap.asMap().entrySet().stream()
                .collect(ImmutableCollectors.toMap(
                        Map.Entry::getKey,
                        e -> e.getValue().iterator().next()));
        InjectiveVar2VarSubstitution renamingSubstitution = substitutionFactory.getInjectiveVar2VarSubstitution(renamingMap);

        // TODO: refactor
        return (ImmutableSubstitution<T>) renamingSubstitution.composeWith(substitution);
    }
783126
protected AscendingSubstitutionNormalization normalizeAscendingSubstitution(
            ImmutableSubstitution<ImmutableTerm> ascendingSubstitution, ImmutableSet<Variable> projectedVariables) {

        Var2VarSubstitution downRenamingSubstitution = substitutionFactory.getVar2VarSubstitution(
                ascendingSubstitution.getImmutableMap().entrySet().stream()
                        .filter(e -> e.getValue() instanceof Variable)
                        .map(e -> Maps.immutableEntry(e.getKey(), (Variable) e.getValue()))
                        .filter(e -> !projectedVariables.contains(e.getValue()))
                        .collect(ImmutableCollectors.toMap(
                                Map.Entry::getValue,
                                Map.Entry::getKey,
                                (v1, v2) -> v1)));

        ImmutableSubstitution<ImmutableTerm> newAscendingSubstitution = downRenamingSubstitution
                .composeWith(ascendingSubstitution)
                .reduceDomainToIntersectionWith(projectedVariables)
                .normalizeValues();

        return new AscendingSubstitutionNormalization(newAscendingSubstitution, downRenamingSubstitution,
                projectedVariables);
    }
637456
def after_masgn
      variables = variable_stack.pop
      values    = value_stack.pop.first
      values    = values && values.value ? values.value : []

      variables.each_with_index do |variable, index|
        variable.value = values[index].value if values[index]

        current_scope.add(variable.type, variable.name, variable)
      end
    end
736414
private Optional<IQ> mergeDefinitions(Collection<IQ> predicateDefinitions,
                                          Optional<ImmutableQueryModifiers> optionalTopModifiers) {
        if (predicateDefinitions.isEmpty())
            return Optional.empty();

        IQ firstDefinition = predicateDefinitions.iterator().next();
        if (predicateDefinitions.size() == 1) {
            return Optional.of(firstDefinition);
        }

        DistinctVariableOnlyDataAtom projectionAtom = firstDefinition.getProjectionAtom();

        VariableGenerator variableGenerator =  coreUtilsFactory.createVariableGenerator(firstDefinition.getTree().getKnownVariables());

        Stream<IQTree> renamedDefinitions = predicateDefinitions.stream()
                .skip(1)
                .map(def -> {
                    // Updates the variable generator
                    InjectiveVar2VarSubstitution disjointVariableSetRenaming = substitutionFactory.generateNotConflictingRenaming(
                            variableGenerator, def.getTree().getKnownVariables());

                    ImmutableSet<Variable> freshVariables = ImmutableSet.copyOf(
                            disjointVariableSetRenaming.getImmutableMap().values());

                    InjectiveVar2VarSubstitution headSubstitution = computeRenamingSubstitution(
                            disjointVariableSetRenaming.applyToDistinctVariableOnlyDataAtom(def.getProjectionAtom()),
                            projectionAtom)
                            .orElseThrow(() -> new IllegalStateException("Bug: unexpected incompatible atoms"));

                    InjectiveVar2VarSubstitution renamingSubstitution =
                            /*
                              fresh variables are excluded from the domain of the renaming substitution
                               since they are in use in the sub-query.

                               NB: this guarantees that the renaming substitution is injective
                             */
                            headSubstitution.composeWithAndPreserveInjectivity(disjointVariableSetRenaming, freshVariables)
                                    .orElseThrow(() -> new IllegalStateException("Bug: the renaming substitution is not injective"));

                    QueryRenamer queryRenamer = transformerFactory.createRenamer(renamingSubstitution);
                    return queryRenamer.transform(def).getTree();
                });

        ImmutableList<IQTree> unionChildren = Stream.concat(Stream.of(firstDefinition.getTree()), renamedDefinitions)
                .collect(ImmutableCollectors.toList());

        IQTree unionTree = iqFactory.createNaryIQTree(iqFactory.createUnionNode(projectionAtom.getVariables()),
                unionChildren);

        IQTree tree = optionalTopModifiers
                .map(m -> m.insertAbove(unionTree, iqFactory))
                .orElse(unionTree);

        return Optional.of(iqFactory.createIQ(projectionAtom, tree));
    }
41168
function(var_name)
    {
        for (var i=0; i<this._features.length; i++)
        {
             if (this._features[i] == var_name)
                 return false;
        }
        this._features.push(var_name);
        return true;
    }
286977
@Override
  public boolean shouldUseSameVarNameAs(MsgSubstUnitNode other) {
    return (other instanceof MsgPlaceholderNode)
        && this.initialNodeKind == ((MsgPlaceholderNode) other).initialNodeKind
        && this.samenessKey.equals(((MsgPlaceholderNode) other).samenessKey);
  }
572564
def _remove_some_work_units(self, work_spec_name, work_unit_names,
                                suffix='', priority_min='-inf',
                                priority_max='+inf'):
        ''''''
        now = time.time()
        if work_unit_names is None:
            count = 0
            while True:
                with self.registry.lock(identifier=self.worker_id) as session:
                    names = session.filter(
                        WORK_UNITS_ + work_spec_name + suffix,
                        priority_min=priority_min, priority_max=priority_max,
                        limit=1000)
                    if not names: break
                    count += session.popmany(
                        WORK_UNITS_ + work_spec_name + suffix, *names)
        else:
            # TODO: This needs to honor priority_min/priority_max,
            # otherwise it gets the wrong answer for "available"/
            # "pending" (it will get both states).
            with self.registry.lock(identifier=self.worker_id) as session:
                count = session.popmany(WORK_UNITS_ + work_spec_name + suffix,
                                        *work_unit_names)
        return count
320510
def normalize_variables(cls, variables):
        
        # if the version is False, empty string, etc, throw it out
        if variables.get('version', True) in ('', False, '_NO_VERSION', None):
            del variables['version']
        return super(PackageResource, cls).normalize_variables(variables)
750832
def un_set_variable(op, var, val, should_persist)

      result = if op == :set
        Ruote.set(h.variables, var, val)
      else # op == :unset
        Ruote.unset(h.variables, var)
      end

      if should_persist && r = try_persist # persist failed, have to retry

        self.h = r
        un_set_variable(op, var, val, true)

      else # success (even when should_persist == false)

        @context.storage.put_msg("variable_#{op}", 'var' => var, 'fei' => h.fei)
      end

      result
    end
1070305
private static function RemoveUndefinedVars(){
            $oThis = self::CreateInstanceIfNotExists();
            $iOffset = 0;

            while(preg_match('/{\$(.*?)}/i', $oThis->sBuffer, $aMatches, PREG_OFFSET_CAPTURE, $iOffset)){
                $oThis->sBuffer = str_replace($aMatches[0][0], "false", $oThis->sBuffer);
                $iOffset = $aMatches[0][1]+strlen($aMatches[0][0]);
            }
        }
894563
function () {
                        //noinspection JSReferencingMutableVariableFromClosure
                        res.push({
                            combine: 1,
                            path: prefix + currentComboUrls.join(comboSep) + suffix,
                            mods: currentComboMods
                        });
                    }
881350
def _ignore_variable(filename, varname):
    
    return (
        varname in IGNORED_VARIABLE_NAMES or
        (varname.startswith('_') and not varname.startswith('__')) or
        _is_special_name(varname))
1293511
public SDVariable[] updateVariableNamesAndReferences(SDVariable[] variablesToUpdate, String[] newVariableNames) {

        int numVariables = variablesToUpdate.length;
        SDVariable[] updatedVariables = new SDVariable[numVariables];

        for (int i = 0; i < numVariables; i++) {
            SDVariable varToUpdate = variablesToUpdate[i];
            String name = newVariableNames == null ? null : newVariableNames[i];
            updatedVariables[i] = updateVariableNameAndReference(varToUpdate, name);
        }

        return updatedVariables;
    }
1243212
def get_state_variable_from_name(self, variable_name):
        
        return next((v for v in self.state_variables if v.name == variable_name), None)
876599
def fixedvar(self):
        
        possible = [m for m in self.members.values() if not m.is_custom]
        #If any of the possible variables is not allocatable or pointer, it will always
        #have a value and we can just use that.
        sufficient = [m for m in possible if "allocatable" not in m.modifiers
                      and "pointer" not in m.modifiers]
        if len(sufficient) > 0:
            return [sufficient[0].name]
        else:
            return [m.name for m in possible]
1321597
function fixVarNames(varObj = {}) {
    const reLeadingHyphens = /^-{2}/;

    return Object.keys(varObj).reduce((obj, value) => {
        const key = reLeadingHyphens.test(value) ? value : `--${value.replace(/^-+/, '')}`;

        obj[key] = varObj[value];

        return obj;
    }, {});
}
1139544
def avoid_name_collisions(filehandle, meta):
    
    if meta.get('avoid_name_collision', True):
        filename = filehandle.filename
        original, ext = os.path.splitext(filehandle.filename)
        counter = count()
        while os.path.exists(get_save_path(filename)):
            fixer = str(next(counter))
            filename = '{}_{}{}'.format(original, fixer, ext)
        filehandle.filename = filename
    return filehandle