Commit d5e80e20 authored by Benedikt Engeser's avatar Benedikt Engeser

Defaultclass geändert

parent 4ee1a644
......@@ -23,8 +23,7 @@ public class Debugger {
static HashMap<IResource, Debugger> delayedInstances = new HashMap<IResource, Debugger>();
private static final BreakpointMapper breakpointMapper = new BreakpointMapper();
private static final String DEFAULT_CLASS = "Test";// TODO: auf Parser
// umstellen
private static final String DEFAULT_CLASS = "Parser";
/**
* Add Debug hooks to an editor
......
......@@ -22,30 +22,31 @@ public class ToggleBreakpointsTarget implements IToggleBreakpointsTarget {
/*
* find out where the editor is
*/
if (part instanceof CupTextEditor){
if (part instanceof CupTextEditor) {
textEditor = (CupTextEditor) part;
}
else if (part instanceof MultiPageEditor) {
} else if (part instanceof MultiPageEditor) {
Object editor = ((MultiPageEditor) part).getSelectedPage();
if (editor instanceof CupTextEditor)
textEditor = (CupTextEditor) editor;
}
if (textEditor != null) {
//prepare everything
// prepare everything
IResource resource = (IResource) textEditor.getEditorInput()
.getAdapter(IResource.class);
ITextSelection textSelection = (ITextSelection) selection;
int lineNumber = textSelection.getStartLine();
int nextPossibleLine = (Debugger.getInstance((CupTextEditor)textEditor).getNextCodeBlockForLineBreakpoint(((ITextSelection)selection).getStartLine()));
if( nextPossibleLine != -1){
int nextPossibleLine = (Debugger
.getInstance((CupTextEditor) textEditor)
.getNextCodeBlockForLineBreakpoint(((ITextSelection) selection)
.getStartLine()));
if (nextPossibleLine != -1) {
lineNumber = nextPossibleLine;
}else{
} else {
return;
}
// get doc identifier:
IDocument doc = null;
......@@ -55,18 +56,18 @@ public class ToggleBreakpointsTarget implements IToggleBreakpointsTarget {
if (doc == null) {
return;
}
//create preakpoint and give it to IDE
IBreakpoint[] breakpoints = (IBreakpoint[]) Debugger.getBreakpointManager()
.getBreakpoints();
// create preakpoint and give it to IDE
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);
Debugger.getBreakpointManager().removeBreakpoint(
breakpoint, true);
return;
}
}
......@@ -76,11 +77,11 @@ public class ToggleBreakpointsTarget implements IToggleBreakpointsTarget {
// new breakpoint; create
CupLineBreakpoint lineBreakpoint = new CupLineBreakpoint(resource,
lineNumber + 1);
Debugger.getBreakpointManager()
.addBreakpoint(lineBreakpoint);
/*System.out.println("CREATED! Length: "
+ Debugger.getBreakpointManager()
.getBreakpoints().length);*/// TODO: DELETE
Debugger.getBreakpointManager().addBreakpoint(lineBreakpoint);
/*
* System.out.println("CREATED! Length: " +
* Debugger.getBreakpointManager() .getBreakpoints().length);
*/// TODO: DELETE
}
}
......@@ -89,19 +90,30 @@ public class ToggleBreakpointsTarget implements IToggleBreakpointsTarget {
public boolean canToggleLineBreakpoints(IWorkbenchPart part,
ISelection selection) {
// true, if we have an CupTextEditor
if (part instanceof CupTextEditor)
return true;
if (part instanceof CupTextEditor) {
if (selection instanceof ITextSelection) {
return (Debugger.getInstance((CupTextEditor) part)
.getNextCodeBlockForLineBreakpoint(
((ITextSelection) selection).getStartLine()) != -1);
} else {
return false;
}
}
if (part instanceof MultiPageEditor) {
Object editor = ((MultiPageEditor) part).getSelectedPage();
/*System.out.println("" + editor
+ " is a CupTextEditor(Breakpoints):"
+ (editor instanceof CupTextEditor));*/// TODO: DELETE
if (editor instanceof CupTextEditor){
if(selection instanceof ITextSelection){
return (Debugger.getInstance((CupTextEditor)editor).getNextCodeBlockForLineBreakpoint(((ITextSelection)selection).getStartLine()) != -1);
}
else{
/*
* System.out.println("" + editor +
* " is a CupTextEditor(Breakpoints):" + (editor instanceof
* CupTextEditor));
*/// TODO: DELETE
if (editor instanceof CupTextEditor) {
if (selection instanceof ITextSelection) {
return (Debugger
.getInstance((CupTextEditor) editor)
.getNextCodeBlockForLineBreakpoint(
((ITextSelection) selection).getStartLine()) != -1);
} else {
return false;
}
}
......@@ -112,54 +124,53 @@ 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
// not implemented
// System.out.println("toggle watchpoints called");// TODO: DELETE
}
@Override
public boolean canToggleMethodBreakpoints(IWorkbenchPart part,
ISelection selection) {
//default answer: false
// 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;*/
// 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");
// 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;*/
* 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