use of org.develnext.jphp.debug.impl.Debugger in project jphp by jphp-compiler.
the class DebugExtension method onRegister.
@Override
public void onRegister(final CompileScope scope) {
if (scope.isDebugMode()) {
String debugIdeKey = "JPHP_DEBUGGER";
if (scope.configuration.containsKey("debug.ideKey")) {
debugIdeKey = scope.configuration.get("debug.ideKey").toString();
}
String debugRootPath = "./src/";
if (scope.configuration.containsKey("debug.rootPath")) {
debugRootPath = scope.configuration.get("debug.rootPath").toString();
}
int debugPort = 9000;
if (scope.configuration.containsKey("debug.port")) {
debugPort = scope.configuration.get("debug.port").toInteger();
}
String debugHost = "127.0.0.1";
if (scope.configuration.containsKey("debug.host")) {
debugHost = scope.configuration.get("debug.host").toString();
}
final String finalDebugIdeKey = debugIdeKey;
final String finalDebugRootPath = debugRootPath;
final int finalDebugPort = debugPort;
final DebugTickHandler tickHandler = new DebugTickHandler();
scope.setTickHandler(tickHandler);
final String finalDebugHost = debugHost;
Thread debuggerThread = new Thread(new Runnable() {
@Override
public void run() {
try {
final Debugger debugger = new Debugger(finalDebugPort, finalDebugHost);
scope.registerProgramShutdownHandler(new ProgramShutdownHandler() {
@Override
public void onShutdown(CompileScope scope, Environment env) {
debugger.shutdown();
}
});
if (debugger.isWorking()) {
debugger.setIdeKey(finalDebugIdeKey);
debugger.setRootPath(finalDebugRootPath);
debugger.run();
}
tickHandler.setDebugger(debugger);
} catch (IOException e) {
throw new DebuggerException(e);
}
}
});
debuggerThread.setName("jphpDebuggerThread");
debuggerThread.start();
}
}
Aggregations