Commit 774700de authored by Johannes Roith's avatar Johannes Roith

Mixed debugger changes.

parent d5875247
......@@ -27,13 +27,12 @@ public class BreakpointListener implements IBreakpointListener {
@Override
public void breakpointAdded(IBreakpoint breakpoint) {
// TODO Auto-generated method stub
System.out.println("ADD: " + breakpoint);
// System.err.println("ADD: " + breakpoint);
if (breakpoint.getMarker().getResource() != null) {
System.out.println("AT: "
+ breakpoint.getMarker().getResource()
.getProjectRelativePath().toString()+" LINE: "+breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, 0));
// System.err.println("AT: "
// + breakpoint.getMarker().getResource()
// .getProjectRelativePath().toString()+" LINE: "+breakpoint.getMarker().getAttribute(IMarker.LINE_NUMBER, 0));
PluginUtility.findGenerated((IFile) breakpoint.getMarker().getResource());
}
......@@ -47,7 +46,7 @@ public class BreakpointListener implements IBreakpointListener {
@Override
public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
System.out.println("DELETE: " + breakpoint + " \n DELTA: " + delta);
// System.err.println("DELETE: " + breakpoint + " \n DELTA: " + delta);
if(breakpoint instanceof CupLineBreakpoint){
mapper.remove((CupLineBreakpoint) breakpoint);
}
......
......@@ -46,8 +46,8 @@ public class BreakpointMapper {
private void addRemoteBreakpoint(CupLineBreakpoint origin) {
IResource originResource = origin.getMarker().getResource();
System.err.println(">>>>> CALLING FOR " + origin.getResource());
System.err.println(">>>>> CALLING FOR getResource " + originResource);
if(originResource == null)
return;
IDocument document = null;
if (originResource instanceof IDocument) {
......@@ -67,22 +67,17 @@ public class BreakpointMapper {
}
Debugger dbg = Debugger.getInstance(document);
System.out.println(">>>>>>>>> originResource: " + originResource);
if(originResource == null)
return;
ParserResult astModel = dbg.getParserResult();
if(astModel == null)
if(astModel == null) {
// TODO: warn
return;
}
System.out.println("-------- begin locator");
IFile resource = locator.find((IFile) originResource, astModel);
System.out.println("-------- end locator");
if(resource == null)
if(resource == null) {
// TODO: warn
return;
}
BufferedReader reader;
try {
......@@ -99,8 +94,10 @@ public class BreakpointMapper {
return;
Mapping debugId = dbg.getDebugId(originLineNumber);
if(debugId == null)
if(debugId == null) {
// TODO: warn
return;
}
debugIds.add(debugId.getDebugId());
......@@ -112,21 +109,12 @@ public class BreakpointMapper {
private void doCreateTargetBreakpoint(CupLineBreakpoint origin, IDocument doc, IFile remoteFile, int remoteLineNumber) {
if(remoteLineNumber == -1)
return;
System.err.println("CREATING REMOTE BREAKPOINT for " +
origin.getResource() + " at remote file " +
remoteFile + " line : " + remoteLineNumber);
Map<String, Object> attributes = new HashMap<String, Object>();
attributes.put(IBreakpoint.PERSISTED, false);
IJavaLineBreakpoint remote = null;
if (remoteFile != null) {
try {
// targetClass
String targetClass = Debugger.getInstance(doc).getGeneratedTargetClass(origin);
System.out.println("targetClass: " + targetClass);
remote = JDIDebugModel.createLineBreakpoint(remoteFile,
targetClass, remoteLineNumber, -1, -1, 0,
true, attributes);
......
......@@ -54,12 +54,9 @@ public class Debugger {
// the document, the instance is managing
// private CupTextEditor myEditor = null;
private IDocument document = null;
private static IBreakpointManager DefaultBreakPointManager = null;
private static IBreakpointManager defaultBreakPointManager = null;
public static Debugger getInstance(IDocument document) {
System.out.println("GETTING DEBUGGER INSTANCE FOR: " + document);
Debugger instance = instances.get(document);
if (instance != null) {
/*
......@@ -124,18 +121,18 @@ public class Debugger {
*/
public Debugger(IDocument document) {
this.document = document;
DefaultBreakPointManager = DebugPlugin.getDefault()
defaultBreakPointManager = DebugPlugin.getDefault()
.getBreakpointManager();
BreakpointListener.getInstance();
}
public static IBreakpointManager getBreakpointManager() {
if (DefaultBreakPointManager == null) {
DefaultBreakPointManager = DebugPlugin.getDefault()
if (defaultBreakPointManager == null) {
defaultBreakPointManager = DebugPlugin.getDefault()
.getBreakpointManager();
}
return DefaultBreakPointManager;
return defaultBreakPointManager;
}
/**
......
......@@ -30,9 +30,6 @@ public class ToggleBreakpointsTarget implements IToggleBreakpointsTarget {
textEditor = (CupTextEditor) editor;
}
if (textEditor != null) {
// prepare everything
IResource resource = (IResource) textEditor.getEditorInput()
.getAdapter(IResource.class);
......@@ -53,27 +50,35 @@ public class ToggleBreakpointsTarget implements IToggleBreakpointsTarget {
doc = textEditor.getDocumentProvider().getDocument(
textEditor.getEditorInput());
if (doc == null) {
if (doc == null)
return;
}
// create breakpoint and give it to IDE
boolean didRemove = false;
IBreakpoint[] breakpoints = (IBreakpoint[]) Debugger
.getBreakpointManager().getBreakpoints();
if (breakpoints != null) {
for (int i = 0; i < breakpoints.length; i++) {
IBreakpoint breakpoint = breakpoints[i];
if (resource.equals(breakpoint.getMarker().getResource())) {
if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
// existing breakpoint; delete
Debugger.getBreakpointManager().removeBreakpoint(
breakpoint, true);
return;
if (breakpoint instanceof CupLineBreakpoint) {
if (resource.equals(breakpoint.getMarker().getResource())) {
int lnum = ((ILineBreakpoint) breakpoint).getLineNumber();
if (lnum == lineNumber + 1) {
// existing breakpoint; delete
Debugger.getBreakpointManager().removeBreakpoint(
breakpoint, true);
didRemove = true;
}
}
}
}
}
if (didRemove)
return;
// new breakpoint; create
CupLineBreakpoint lineBreakpoint = new CupLineBreakpoint(resource,
lineNumber + 1);
......@@ -124,53 +129,23 @@ public class ToggleBreakpointsTarget implements IToggleBreakpointsTarget {
@Override
public void toggleMethodBreakpoints(IWorkbenchPart part,
ISelection selection) throws CoreException {
// not implemented
// System.out.println("toggle watchpoints called");// TODO: DELETE
}
@Override
public boolean canToggleMethodBreakpoints(IWorkbenchPart part,
ISelection selection) {
// default answer: false
return false;
// do this, if you want to toggle method bps
/*
* if (part instanceof CupTextEditor) return true; if (part instanceof
* MultiPageEditor) { Object editor = ((MultiPageEditor)
* part).getSelectedPage(); /*System.out.println("" + editor +
* " is a CupTextEditor(MethodBreakpoints):" + (editor instanceof
* CupTextEditor));
*/// TODO: DELETE
/*
* return (editor instanceof CupTextEditor); } return false;
*/
}
@Override
public void toggleWatchpoints(IWorkbenchPart part, ISelection selection)
throws CoreException {
// System.out.println("toggleWatchpoints called");
}
@Override
public boolean canToggleWatchpoints(IWorkbenchPart part,
ISelection selection) {
return false;
/*
* if (part instanceof CupTextEditor) return true; if (part instanceof
* MultiPageEditor) { Object editor = ((MultiPageEditor)
* part).getSelectedPage(); /*System.out.println("" + editor +
* " is a CupTextEditor(Watchpoints):" + (editor instanceof
* CupTextEditor));
*/// TODO: DELETE
/*
* return (editor instanceof CupTextEditor); } return false;
*/
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment