mirror of
https://github.com/cincheo/jsweet.git
synced 2025-12-15 15:29:22 +00:00
Merge pull request #518 from blagae/master
Support Deque:remove() and removeFirst()
This commit is contained in:
commit
2e8800dedb
@ -1153,9 +1153,16 @@ public class RemoveJavaDependenciesAdapter extends Java2TypeScriptAdapter {
|
||||
print(invocation.getTargetExpression(), delegate).print(")");
|
||||
return true;
|
||||
case "remove":
|
||||
case "removeElement":
|
||||
case "removeFirst": // in Deque
|
||||
case "removeElement": // in Vector: functionally equivalent to List.remove(int idx)
|
||||
printMacroName(targetMethodName);
|
||||
if (Util.isNumber(invocation.getArgument(0).getType())
|
||||
/* in Queue: interface contains a no-arg method remove()
|
||||
* which is functionally identical to Deque.removeFirst()
|
||||
*/
|
||||
if (invocation.getArgumentCount() == 0) {
|
||||
print(invocation.getTargetExpression(), delegate)
|
||||
.print(".splice(0, 1)[0]");
|
||||
} else if (Util.isNumber(invocation.getArgument(0).getType())
|
||||
&& types().isSubtype(types().erasure(invocation.getTargetExpression().getType()),
|
||||
types().erasure(util().getType(List.class)))) {
|
||||
print(invocation.getTargetExpression(), delegate).print(".splice(")
|
||||
|
||||
@ -265,6 +265,10 @@ public class Collections implements Cloneable, Serializable {
|
||||
dq.addLast("a");
|
||||
dq.addLast("b");
|
||||
dq.addFirst("c");
|
||||
dq.remove();
|
||||
dq.addFirst("c");
|
||||
dq.removeFirst();
|
||||
dq.addFirst("c");
|
||||
|
||||
trace.push("" + dq.isEmpty());
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user