| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE.md file. | |
| 4 | |
| 5 library fletchc.verbs.run_verb; | |
| 6 | |
| 7 import 'infrastructure.dart'; | |
| 8 | |
| 9 import 'documentation.dart' show | |
| 10 runDocumentation; | |
| 11 | |
| 12 import '../worker/developer.dart' show | |
| 13 compileAndAttachToVmThen; | |
| 14 | |
| 15 import '../worker/developer.dart' as developer; | |
| 16 | |
| 17 const Action runAction = | |
| 18 const Action( | |
| 19 run, runDocumentation, requiresSession: true, | |
| 20 supportedTargets: const <TargetKind>[TargetKind.FILE]); | |
| 21 | |
| 22 Future<int> run(AnalyzedSentence sentence, VerbContext context) { | |
| 23 bool terminateDebugger = sentence.options.terminateDebugger; | |
| 24 List<String> testDebuggerCommands = sentence.options.testDebuggerCommands; | |
| 25 return context.performTaskInWorker( | |
| 26 new RunTask( | |
| 27 sentence.targetUri, sentence.base, terminateDebugger, | |
| 28 testDebuggerCommands)); | |
| 29 } | |
| 30 | |
| 31 class RunTask extends SharedTask { | |
| 32 // Keep this class simple, see note in superclass. | |
| 33 | |
| 34 final Uri script; | |
| 35 | |
| 36 final Uri base; | |
| 37 | |
| 38 /// When true, terminate the debugger session before returning from | |
| 39 /// [runTask]. Otherwise, the debugger session will be available after | |
| 40 /// [runTask] completes. | |
| 41 final bool terminateDebugger; | |
| 42 | |
| 43 final List<String> testDebuggerCommands; | |
| 44 | |
| 45 const RunTask( | |
| 46 this.script, | |
| 47 this.base, | |
| 48 this.terminateDebugger, | |
| 49 this.testDebuggerCommands); | |
| 50 | |
| 51 Future<int> call( | |
| 52 CommandSender commandSender, | |
| 53 StreamIterator<ClientCommand> commandIterator) { | |
| 54 return runTask( | |
| 55 commandSender, commandIterator, SessionState.current, script, base, | |
| 56 terminateDebugger, testDebuggerCommands); | |
| 57 } | |
| 58 } | |
| 59 | |
| 60 Future<int> runTask( | |
| 61 CommandSender commandSender, | |
| 62 StreamIterator<ClientCommand> commandIterator, | |
| 63 SessionState state, | |
| 64 Uri script, | |
| 65 Uri base, | |
| 66 bool terminateDebugger, | |
| 67 List<String> testDebuggerCommands) { | |
| 68 return compileAndAttachToVmThen( | |
| 69 commandSender, | |
| 70 commandIterator, | |
| 71 state, | |
| 72 script, | |
| 73 base, | |
| 74 terminateDebugger, | |
| 75 () => developer.run( | |
| 76 state, testDebuggerCommands: testDebuggerCommands, | |
| 77 terminateDebugger: terminateDebugger)); | |
| 78 } | |
| OLD | NEW |