use of org.intellij.plugins.xsltDebugger.rt.engine.Debugger in project intellij-community by JetBrains.
the class DebuggerConnector method connect.
@Nullable
private Debugger connect() {
Throwable lastException = null;
for (int i = 0; i < 10; i++) {
if (myProcess.isProcessTerminated())
return null;
try {
final Debugger realClient = EDTGuard.create(new RemoteDebuggerClient(myPort), myProcess);
myProcess.notifyTextAvailable("Connected to XSLT debugger on port " + myPort + "\n", ProcessOutputTypes.SYSTEM);
return realClient;
} catch (ConnectException e) {
lastException = e;
try {
Thread.sleep(500);
} catch (InterruptedException e1) {
break;
}
} catch (NotBoundException e) {
lastException = e;
try {
Thread.sleep(200);
} catch (InterruptedException e1) {
break;
}
} catch (IOException e) {
lastException = e;
break;
}
}
if (lastException != null) {
Logger.getInstance(getClass().getName()).info("Could not connect to debugger", lastException);
if (lastException.getMessage() != null) {
myProcess.notifyTextAvailable("Connection error: " + lastException.getMessage() + "\n", ProcessOutputTypes.SYSTEM);
}
}
return null;
}
use of org.intellij.plugins.xsltDebugger.rt.engine.Debugger in project intellij-community by JetBrains.
the class DebuggerConnector method run.
public void run() {
final Debugger client = connect();
if (client == null) {
// client will be null if the process terminated prematurely for some reason. no need for an error message
if (!myProcess.isProcessTerminated()) {
myProcess.notifyTextAvailable("Failed to connect to debugged process. Terminating.\n", ProcessOutputTypes.SYSTEM);
myProcess.destroyProcess();
}
return;
}
final XsltDebuggerSession session = XsltDebuggerSession.create(myProject, myProcess, client);
final XsltDebugProcess dbgp = XsltDebugProcess.getInstance(myProcess);
assert dbgp != null;
dbgp.init(client);
session.addListener(new XsltDebuggerSession.Listener() {
@Override
public void debuggerSuspended() {
final OutputEventQueue queue = client.getEventQueue();
StructureTabComponent.getInstance(myProcess).getEventModel().update(queue.getEvents());
}
@Override
public void debuggerResumed() {
}
@Override
public void debuggerStopped() {
try {
final OutputEventQueue queue = client.getEventQueue();
StructureTabComponent.getInstance(myProcess).getEventModel().finalUpdate(queue.getEvents());
} catch (Exception e) {
// can fail when debugger is manually terminated
}
}
});
session.start();
}
use of org.intellij.plugins.xsltDebugger.rt.engine.Debugger in project intellij-community by JetBrains.
the class XsltDebugProcess method init.
public void init(Debugger client) {
myDebuggerSession = XsltDebuggerSession.getInstance(myProcessHandler);
myDebuggerSession.addListener(new XsltDebuggerSession.Listener() {
@Override
public void debuggerSuspended() {
final Debugger c = myDebuggerSession.getClient();
getSession().positionReached(new MySuspendContext(myDebuggerSession, c.getCurrentFrame(), c.getSourceFrame()));
}
@Override
public void debuggerResumed() {
}
@Override
public void debuggerStopped() {
myBreakpointManager = new BreakpointManagerImpl();
}
});
final BreakpointManager mgr = client.getBreakpointManager();
if (myBreakpointManager != mgr) {
final List<Breakpoint> breakpoints = myBreakpointManager.getBreakpoints();
for (Breakpoint breakpoint : breakpoints) {
final Breakpoint bp = mgr.setBreakpoint(breakpoint.getUri(), breakpoint.getLine());
bp.setEnabled(breakpoint.isEnabled());
bp.setLogMessage(breakpoint.getLogMessage());
bp.setTraceMessage(breakpoint.getTraceMessage());
bp.setCondition(breakpoint.getCondition());
bp.setSuspend(breakpoint.isSuspend());
}
myBreakpointManager = mgr;
}
}
use of org.intellij.plugins.xsltDebugger.rt.engine.Debugger in project intellij-community by JetBrains.
the class XsltDebugProcess method runToPosition.
@Override
public void runToPosition(@NotNull XSourcePosition position, @Nullable XSuspendContext context) {
final PsiFile psiFile = PsiManager.getInstance(getSession().getProject()).findFile(position.getFile());
assert psiFile != null;
if (myDebuggerSession.canRunTo(position)) {
myDebuggerSession.runTo(psiFile, position);
} else {
StatusBar.Info.set("Not a valid position in file '" + psiFile.getName() + "'", psiFile.getProject());
final Debugger c = myDebuggerSession.getClient();
getSession().positionReached(new MySuspendContext(myDebuggerSession, c.getCurrentFrame(), c.getSourceFrame()));
}
}
Aggregations