Mercurial > hg > RemoteEditor > REPSessionManager
comparison rep/translater/TranslaterImp1.java @ 313:0585fd2410b8 single-insert-command
Single Insert Command worked.
author | kono |
---|---|
date | Sun, 05 Oct 2008 22:36:24 +0900 |
parents | c35f01b5060f |
children | 20fb70068089 |
comparison
equal
deleted
inserted
replaced
312:f39a8045175d | 313:0585fd2410b8 |
---|---|
51 } | 51 } |
52 /** | 52 /** |
53 * Dequeue command cmd that was returned. | 53 * Dequeue command cmd that was returned. |
54 * @param cmd | 54 * @param cmd |
55 */ | 55 */ |
56 public ArrayList<REPCommand> catchOwnCommand(REPCommand cmd){ | 56 public ArrayList<REPCommand> catchOwnCommand(){ |
57 ArrayList<REPCommand> returnCmds = new ArrayList<REPCommand>(); | 57 ArrayList<REPCommand> returnCmds = new ArrayList<REPCommand>(); |
58 ArrayList<REPCommand> cmds = new ArrayList<REPCommand>(); | 58 ArrayList<REPCommand> cmds = new ArrayList<REPCommand>(); |
59 // ringである以上、戻ってきたコマンドは確実にキューsentCmdsの先頭にある事を期待している | 59 prev(); |
60 REPCommand tmp = sentCmds.poll(); | |
61 assert tmp.seq==cmd.seq; | |
62 assert cmd.eid==eid; | |
63 | |
64 //スタック上にあるコマンドを全部undoコマンドにする | 60 //スタック上にあるコマンドを全部undoコマンドにする |
65 while ( !unMergedCmds.isEmpty() ){ | 61 while ( !unMergedCmds.isEmpty() ){ |
66 REPCommand cmd0 = unMergedCmds.pop(); | 62 REPCommand cmd0 = unMergedCmds.pop(); |
67 returnCmds.add( createUndo(cmd0) ); | 63 returnCmds.add( createUndo(cmd0) ); |
68 cmds.add(cmd0); | 64 cmds.add(cmd0); |
77 returnCmds.add( cmds.get(i)); | 73 returnCmds.add( cmds.get(i)); |
78 unMergedCmds.push( cmds.get(i)); | 74 unMergedCmds.push( cmds.get(i)); |
79 } | 75 } |
80 | 76 |
81 return returnCmds; | 77 return returnCmds; |
78 } | |
79 | |
80 public REPCommand prev() { | |
81 return sentCmds.poll(); | |
82 } | 82 } |
83 | 83 |
84 private REPCommand createUndo(REPCommand cmd){ | 84 private REPCommand createUndo(REPCommand cmd){ |
85 String str = new String(cmd.string); | 85 String str = new String(cmd.string); |
86 REPCommand retCmd = new REPCommand(cmd.cmd, cmd.sid, cmd.eid, cmd.seq, cmd.lineno, str); | 86 REPCommand retCmd = new REPCommand(cmd.cmd, cmd.sid, cmd.eid, cmd.seq, cmd.lineno, str); |