X-Git-Url: http://source.jalview.org/gitweb/?a=blobdiff_plain;f=src%2Fjalview%2Fbin%2Fargparser%2FArgValuesMap.java;h=8a28b8780927d0cfc10fd764a44a15bf58e9f3ac;hb=ccc53e88e3260886f5d3bdacc619c0f374be9b8f;hp=5d53641eb875275e0af11bc3738a8fd4a56c54ab;hpb=7cef06600140ffeb5a989117113d510742b9aa5e;p=jalview.git diff --git a/src/jalview/bin/argparser/ArgValuesMap.java b/src/jalview/bin/argparser/ArgValuesMap.java index 5d53641..8a28b87 100644 --- a/src/jalview/bin/argparser/ArgValuesMap.java +++ b/src/jalview/bin/argparser/ArgValuesMap.java @@ -22,8 +22,10 @@ package jalview.bin.argparser; 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; @@ -77,9 +79,13 @@ public class ArgValuesMap 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) @@ -105,16 +111,27 @@ public class ArgValuesMap 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 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 types = new HashSet<>(); + if (type == null) + { + types.addAll(Arrays.asList(av.getArg().getTypes())); + } + else + { + types.add(type); + } List avList = new ArrayList<>(); if (sv != null && sv.has(key) && sv.get(key) != null) { @@ -123,7 +140,9 @@ public class ArgValuesMap // 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)) { @@ -163,8 +182,9 @@ public class ArgValuesMap // 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)) { @@ -177,15 +197,17 @@ public class ArgValuesMap } } } - List tmpList = List.copyOf(avList); - for (ArgValue tmpAv : tmpList) + List 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; @@ -521,6 +543,18 @@ public class ArgValuesMap 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) {