[Pydev-cvs] org.python.pydev/src/org/python/pydev/editor/actions PyMethodNavigation.java,NONE,1.1 Py
Brought to you by:
fabioz
From: Aleksandar T. <at...@us...> - 2004-05-07 02:07:27
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14127/src/org/python/pydev/editor/actions Added Files: PyMethodNavigation.java PyNextMethod.java PyPreviousMethod.java Log Message: Breakpoints, first cut --- NEW FILE: PyPreviousMethod.java --- /* * @author: fabioz * Created: February 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.actions; import org.python.pydev.editor.model.*; /** * @author Fabio Zadrozny */ public class PyPreviousMethod extends PyMethodNavigation { // me is the last node w public AbstractNode getSelect(AbstractNode me) { AbstractNode current = ModelUtils.getPreviousNode(me); while (current != null && !(current instanceof FunctionNode) && !(current instanceof ClassNode)) current = ModelUtils.getPreviousNode(current); return current; } } --- NEW FILE: PyNextMethod.java --- /* * @author: fabioz * Created: February 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.actions; import org.python.pydev.editor.model.*; /** * One-trick pony, finds the next method. */ public class PyNextMethod extends PyMethodNavigation{ /** * Gets the next method/class definition */ public AbstractNode getSelect(AbstractNode me ) { AbstractNode current = ModelUtils.getNextNode(me); while (current != null && !(current instanceof FunctionNode) && !(current instanceof ClassNode)) current = ModelUtils.getNextNode(current); return current; } } --- NEW FILE: PyMethodNavigation.java --- /* * @author: fabioz * Created: February 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.actions; import org.eclipse.jface.action.IAction; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextSelection; import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.model.*; /** * The trick here is getting the outline... To do that, some refactorings had * to be done to the PyOutlinePage, to get the parsed items and the ParsedItem, * so that it is now public. * * @author Fabio Zadrozny */ public abstract class PyMethodNavigation extends PyAction { /** * This method gets the parsed model, discovers where we are in the * document (through the visitor), and asks the implementing class * to where we should go... */ public void run(IAction action) { PyEdit pyEdit = getPyEdit(); IDocument doc = pyEdit.getDocumentProvider().getDocument(pyEdit.getEditorInput()); ITextSelection selection = (ITextSelection) pyEdit.getSelectionProvider().getSelection(); Location loc = Location.offsetToLocation(doc, selection.getOffset()); AbstractNode closest = ModelUtils.getLessOrEqualNode(pyEdit.getPythonModel(),loc); AbstractNode goHere = getSelect(closest); pyEdit.revealModelNode(goHere); } /** * This method should return to where we should go, depending on * the visitor passed as a parameter (it contains the node where we * are, the next node and the previous node). * * @param v * @return where we should go depending on visitor */ public abstract AbstractNode getSelect(AbstractNode v); } |