Commit b87d3a92 authored by Benedikt Engeser's avatar Benedikt Engeser

Breakpoint zum naechsten javablock mappen pt1

parent 12d31b4d
......@@ -2,7 +2,7 @@ package de.in.tum.www2.cup.analysis;
import de.in.tum.www2.cup.ast.*;
public class FindNextCodeBlockLine extends Visitor<Object>
public class FindNextCodeBlockLineVisitor extends Visitor<Object>
{
private int line;
private int result;
......@@ -11,7 +11,7 @@ public class FindNextCodeBlockLine extends Visitor<Object>
return result;
}
public FindNextCodeBlockLine(int line) {
public FindNextCodeBlockLineVisitor(int line) {
this.line = line;
this.result = -1;
}
......
......@@ -9,8 +9,12 @@ import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.IBreakpointListener;
import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.model.IBreakpoint;
import de.tum.in.www2.cupplugin.controller.DocumentDidChangeJob;
import de.tum.in.www2.cupplugin.editors.CupTextEditor;
import de.tum.in.www2.cupplugin.model.Model;
import de.in.tum.www2.cup.analysis.FindNextCodeBlockLineVisitor;
import de.in.tum.www2.cup.ast.ParserResult;
public class Debugger implements IBreakpointListener{
......@@ -106,4 +110,16 @@ public class Debugger implements IBreakpointListener{
}
public int getNextCodeBlockForLineBreakpoint(int line){
Model m = Model.getInstanceForDocument(myEditor.getDocumentProvider().getDocument(myEditor.getEditorInput()));
ParserResult astModel = m.getAstModel();
//create Visitor
FindNextCodeBlockLineVisitor v = new FindNextCodeBlockLineVisitor(line);
astModel.accept(v, null);
return v.getResult();
}
}
\ No newline at end of file
......@@ -7,8 +7,10 @@ import org.eclipse.debug.core.model.ILineBreakpoint;
import org.eclipse.debug.ui.actions.IToggleBreakpointsTarget;
import org.eclipse.jface.text.IDocument;
import org.eclipse.jface.text.ITextSelection;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.ui.IWorkbenchPart;
import de.tum.in.www2.cupplugin.editors.CupTextEditor;
import de.tum.in.www2.cupplugin.editors.MultiPageEditor;
......@@ -38,6 +40,13 @@ public class ToggleBreakpointsTarget implements IToggleBreakpointsTarget {
ITextSelection textSelection = (ITextSelection) selection;
int lineNumber = textSelection.getStartLine();
int nextPossibleLine = (Debugger.getInstance((CupTextEditor)textEditor).getNextCodeBlockForLineBreakpoint(((ITextSelection)selection).getStartLine()));
if( nextPossibleLine != -1){
lineNumber = nextPossibleLine;
}else{
return;
}
// get doc identifier:
IDocument doc = null;
......@@ -91,7 +100,14 @@ public class ToggleBreakpointsTarget implements IToggleBreakpointsTarget {
/*System.out.println("" + editor
+ " is a CupTextEditor(Breakpoints):"
+ (editor instanceof CupTextEditor));*/// TODO: DELETE
return (editor instanceof CupTextEditor);
if (editor instanceof CupTextEditor){
if(selection instanceof ITextSelection){
return (Debugger.getInstance((CupTextEditor)editor).getNextCodeBlockForLineBreakpoint(((ITextSelection)selection).getStartLine()) != -1);
}
else{
return false;
}
}
}
return false;
}
......
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