import java.io.File;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
+import java.util.HashSet;
import java.util.List;
import java.util.Locale;
import java.util.Map;
private void newArg(Arg a)
{
if (m == null)
+ {
newMap();
+ }
if (!containsArg(a))
- m.put(a, new ArgValues(a));
+ {
+ m.put(a, new ArgValues(a, this));
+ }
}
public ArgValues getArgValues(Arg a)
SubVals sv)
{
return getArgValueListFromSubValArgOrPrefWithSubstitutionsWithinTypes(
- null, a, Position.AFTER, av, sv, null, null, null, true);
+ null, a, Position.AFTER, av, sv, null, null, null, true, null);
}
public List<ArgValue> getArgValueListFromSubValArgOrPrefWithSubstitutionsWithinTypes(
ArgParser ap, Arg a, ArgValuesMap.Position pos, ArgValue av,
SubVals sv, String key, String pref, String def,
- boolean withinTypes)
+ boolean withinTypes, Type type)
{
if (key == null)
+ {
key = a.getName();
+ }
+ Set<Type> types = new HashSet<>();
+ if (type == null)
+ {
+ types.addAll(Arrays.asList(av.getArg().getTypes()));
+ }
+ else
+ {
+ types.add(type);
+ }
List<ArgValue> avList = new ArrayList<>();
if (sv != null && sv.has(key) && sv.get(key) != null)
{
// protected ArgValue(Arg a, SubVals sv, Type type, String content, int
// argIndex)
- avList.add(new ArgValue(a, null, null, value, av.getArgIndex()));
+ ArgValue svav = new ArgValue(a, null, null, value, av.getArgIndex(),
+ false, null, this.getLinkedId());
+ avList.add(svav);
}
else if (containsArg(a))
{
// run through every Arg used in this ArgValuesMap
for (Arg tmpA : this.getArgKeys())
{
- // only interested in Opt.PRIMARY args of the same type
- if (tmpA.sharesType(a) && tmpA.hasOption(Opt.PRIMARY))
+ // only interested in looking up to next Opt.PRIMARY args of the same
+ // type as av (or provided type)
+ if (tmpA.hasType(types) && tmpA.hasOption(Opt.PRIMARY))
{
for (ArgValue tmpAv : getArgValueList(tmpA))
{
}
}
}
- List<ArgValue> tmpList = List.copyOf(avList);
- for (ArgValue tmpAv : tmpList)
+ List<ArgValue> tmpList = new ArrayList<>();
+ for (ArgValue tmpAv : avList)
{
- if (nextPrimaryArgOfSameTypeIndex < tmpAv.getArgIndex())
+ int tmpAvIndex = tmpAv.getArgIndex();
+ if (av.getArgIndex() < tmpAvIndex
+ && tmpAvIndex < nextPrimaryArgOfSameTypeIndex)
{
- // looks like this tmpAv actually belongs to a different primary Arg
- avList.remove(tmpAv);
+ tmpList.add(tmpAv);
}
}
+ avList = tmpList;
}
return avList;
value = av2.getValue();
}
}
+
+ if (value == null)
+ {
+ // look for --all --a occurrences
+ for (ArgValue tmpAv : this.getArgValueList(a))
+ {
+ if (tmpAv.setByWildcardLinkedId())
+ {
+ value = tmpAv.getValue();
+ }
+ }
+ }
}
if (value == null)
{