pydev-cvs Mailing List for PyDev for Eclipse (Page 317)
Brought to you by:
fabioz
You can subscribe to this list here.
2004 |
Jan
|
Feb
(4) |
Mar
(48) |
Apr
(56) |
May
(64) |
Jun
(27) |
Jul
(66) |
Aug
(81) |
Sep
(148) |
Oct
(194) |
Nov
(78) |
Dec
(46) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(125) |
Feb
(126) |
Mar
(163) |
Apr
(133) |
May
(115) |
Jun
(307) |
Jul
(387) |
Aug
(417) |
Sep
(283) |
Oct
(148) |
Nov
(45) |
Dec
(53) |
2006 |
Jan
(240) |
Feb
(200) |
Mar
(267) |
Apr
(231) |
May
(245) |
Jun
(361) |
Jul
(142) |
Aug
(12) |
Sep
(210) |
Oct
(99) |
Nov
(7) |
Dec
(30) |
2007 |
Jan
(161) |
Feb
(511) |
Mar
(265) |
Apr
(74) |
May
(147) |
Jun
(151) |
Jul
(94) |
Aug
(68) |
Sep
(98) |
Oct
(144) |
Nov
(26) |
Dec
(36) |
2008 |
Jan
(98) |
Feb
(107) |
Mar
(199) |
Apr
(113) |
May
(119) |
Jun
(112) |
Jul
(92) |
Aug
(71) |
Sep
(101) |
Oct
(16) |
Nov
|
Dec
|
From: Aleksandar T. <at...@us...> - 2004-04-10 02:01:20
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv571/src/org/python/pydev/editor/model Log Message: Directory /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model added to the repository |
From: Dana M. <dan...@us...> - 2004-04-02 18:37:07
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11701/src/org/python/pydev Added Files: PyDevPluginResources.properties Log Message: required for any content completion worker. Not clear that contents of this particular file are particularly important at this juncture --- NEW FILE: PyDevPluginResources.properties --- ContentAssistProposal=Proposal |
From: Dana M. <dan...@us...> - 2004-04-02 18:32:55
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10990/src/org/python/pydev/editor Added Files: PythonCompletionProcessor.java Log Message: Innocuous Completion Processor. Awaits a better strategy for analysing classes and variables --- NEW FILE: PythonCompletionProcessor.java --- /* * Created on Mar 29, 2004 * * To change the template for this generated file go to * Window>Preferences>Java>Code Generation>Code and Comments */ package org.python.pydev.editor; import java.util.ArrayList; import java.util.List; import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.CompletionProposal; import org.eclipse.jface.text.contentassist.ContextInformation; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.eclipse.swt.graphics.Point; /** * @author Dmoore * * To change the template for this generated type comment go to * Window>Preferences>Java>Code Generation>Code and Comments */ public class PythonCompletionProcessor implements IContentAssistProcessor { /* (non-Javadoc) * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeCompletionProposals(org.eclipse.jface.text.ITextViewer, int) */ public ICompletionProposal[] computeCompletionProposals( ITextViewer viewer, int documentOffset) { // get the document to be inspected... IDocument doc = viewer.getDocument(); // get the current selection range... Point selectedRange = viewer.getSelectedRange(); List propList = new ArrayList(); if (selectedRange.y > 0) { try { String text = doc.get(selectedRange.x, selectedRange.y); System.out.println("Document text:"+text); computeStyleProposals(text, selectedRange, propList); } catch (BadLocationException e) { // ??? return null; } } else{ //try to retrv a 'qualifier' from the doc. // for example, a partial python statement. This might be used to restrict the set of possible proposals String qualifier = getQualifier(doc, documentOffset); System.out.println("Document qualifier:"+qualifier); computeStructureProposals(qualifier, documentOffset, propList); } // create an array of completion proposals ICompletionProposal [] proposals = new ICompletionProposal[propList.size()]; propList.toArray(proposals); return proposals; } /** * @param qualifier * @param documentOffset * @param proposals */ private void computeStructureProposals(String qualifier, int documentOffset, List propList) { // Not sure how to adapt this one either. // The HTML example computes a part 'before the planned cursor' and a part 'after the planned cursor' // I think that here is where we want to somehow latch the pointer from the current parse tree. // we want to look at the text before the '.', and see what from the parse tree completes it... int qlen = qualifier.length(); for (int i = 0; i < STRUCTTAGS1.length; i++) { String startTag = STRUCTTAGS1[i]; // Check if proposal matches qualifier if (startTag.startsWith(qualifier)){ // Yes.. compute entire proposal text String text = startTag + STRUCTTAGS2[i]; int cursor = startTag.length(); // construct proposal CompletionProposal proposal = new CompletionProposal(text, documentOffset - qlen, qlen, cursor); // add to results propList.add(proposal); } } } /** * @param doc * @param documentOffset * @return */ private String getQualifier(IDocument doc, int documentOffset) { // use a StringBuffer to collect the bunch of proposals // StringBuffer sB = new StringBuffer(); // while (true) { // try { // char c = doc.getChar(--documentOffset); // do something here to test if this was the start of a python statement // TODO: Figure this out. For sonmething like HTML, the test might be: // if (c == '>' || Character.isWhitespace(c) or something like that // Not really sure what our equivaent is? // for now.. // return ""; // } catch (BadLocationException e) { // return ""; // } // } return ""; } // Proposal part before cursor... // Let's stub in some static ones for the moment... private final static String[] STRUCTTAGS1 = {"Dana", "Bill", "Aleks", "Fabio"}; private final static String[] STRUCTTAGS2 = {"Moore", "Wright", "Totic", "Zadrozny"}; private final static String[] STYLETAGS = {"dana", "bill", "aleks", "fabio"}; private final static String[] STYLELABELS = {"DANA", "BILL", "ALEKS", "FABIO"}; /** * @param text * @param selectedRange * @param proposals */ private void computeStyleProposals(String selectedText, Point selectedRange, List propList) { // loop thru the styles.. what does this have to do with completion??? for (int i = 0; i < STYLETAGS.length; i++) { String tag = STYLETAGS[i]; // compute replacement text String replacement = "<"+tag+">"+ selectedText +"</"+tag+">"; int cursor = tag.length()+2; // ?? why plus 2 IContextInformation contextInfo = new ContextInformation(null, STYLELABELS[i]+" Style"); CompletionProposal proposal = new CompletionProposal(replacement, selectedRange.x, selectedRange.y, cursor, null, STYLELABELS[i], contextInfo, replacement); // add that to the list of proposals propList.add(proposal); } } /* (non-Javadoc) * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int) */ public IContextInformation[] computeContextInformation( ITextViewer viewer, int documentOffset) { // TODO Auto-generated method stub return null; } /* (non-Javadoc) * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() */ public char[] getCompletionProposalAutoActivationCharacters() { return new char[] {'.'}; } /* (non-Javadoc) * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters() */ public char[] getContextInformationAutoActivationCharacters() { // is this _really_ what we want to use?? return new char[] {'.'}; } /* (non-Javadoc) * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getErrorMessage() */ public String getErrorMessage() { // TODO Auto-generated method stub return null; } /* (non-Javadoc) * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationValidator() */ public IContextInformationValidator getContextInformationValidator() { // TODO Auto-generated method stub return null; } } |
From: Dana M. <dan...@us...> - 2004-04-02 18:29:56
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10493/src/org/python/pydev/editor Modified Files: PyEdit.java Log Message: added createActions for content assist proposals. (NOte: Merged With Aleks' PyDictionary checkin) Index: PyEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEdit.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PyEdit.java 30 Mar 2004 01:03:37 -0000 1.9 --- PyEdit.java 2 Apr 2004 18:17:44 -0000 1.10 *************** *** 16,19 **** --- 16,21 ---- import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.source.ISourceViewer; + import org.eclipse.jface.text.source.SourceViewer; + import org.eclipse.swt.SWT; import org.eclipse.ui.IEditorInput; import org.eclipse.ui.IEditorSite; *************** *** 25,28 **** --- 27,31 ---- import org.eclipse.ui.texteditor.IEditorStatusLine; import org.eclipse.ui.texteditor.MarkerUtilities; + import org.eclipse.ui.texteditor.TextOperationAction; import org.eclipse.ui.views.contentoutline.IContentOutlinePage; import org.python.parser.ParseException; *************** *** 38,41 **** --- 41,45 ---- import org.python.pydev.parser.PyParser; import org.python.pydev.ui.ColorCache; + import org.eclipse.jface.action.IAction; *************** *** 171,174 **** --- 175,198 ---- super.dispose(); } + private static final String CONTENTASSIST_PROPOSAL_ID = + "org.python.pydev.editors.PyEdit.ContentAssistProposal"; + + /* (non-Javadoc) + * @see org.eclipse.ui.texteditor.AbstractTextEditor#createActions() + */ + protected void createActions() { + super.createActions(); + // This action will fire a CONTENTASSIST_PROPOSALS operation + // when executed + + IAction action= new TextOperationAction(PydevPlugin.getDefault().getResourceBundle(), + "ContentAssistProposal",this,SourceViewer.CONTENTASSIST_PROPOSALS); + action.setActionDefinitionId(CONTENTASSIST_PROPOSAL_ID); + // Tell the editor about this new action + setAction(CONTENTASSIST_PROPOSAL_ID, action); + // Tell the editor to execute this action + // when Ctrl+Spacebar is pressed + setActionActivationCode(CONTENTASSIST_PROPOSAL_ID,' ', -1, SWT.CTRL); + } |
From: Dana M. <dan...@us...> - 2004-04-02 18:20:02
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8716/src/org/python/pydev/editor Modified Files: PyEditConfiguration.java Log Message: filled in IContentAssist with some temporary code Index: PyEditConfiguration.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditConfiguration.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyEditConfiguration.java 30 Mar 2004 01:03:37 -0000 1.6 --- PyEditConfiguration.java 2 Apr 2004 18:07:50 -0000 1.7 *************** *** 11,18 **** --- 11,24 ---- import org.eclipse.core.runtime.Preferences; + import org.eclipse.jface.text.DefaultInformationControl; import org.eclipse.jface.text.IAutoIndentStrategy; import org.eclipse.jface.text.IDocument; + import org.eclipse.jface.text.IInformationControl; + import org.eclipse.jface.text.IInformationControlCreator; import org.eclipse.jface.text.ITextDoubleClickStrategy; import org.eclipse.jface.text.TextAttribute; + import org.eclipse.jface.text.TextPresentation; + import org.eclipse.jface.text.contentassist.ContentAssistant; + import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContentAssistant; import org.eclipse.jface.text.presentation.IPresentationReconciler; *************** *** 29,33 **** --- 35,44 ---- import org.eclipse.jface.text.source.ISourceViewer; import org.eclipse.jface.text.source.SourceViewerConfiguration; + import org.eclipse.swt.SWT; + import org.eclipse.swt.custom.StyleRange; import org.eclipse.swt.graphics.Color; + import org.eclipse.swt.graphics.RGB; + import org.eclipse.swt.widgets.Display; + import org.eclipse.swt.widgets.Shell; import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.plugin.PydevPrefs; *************** *** 46,49 **** --- 57,61 ---- private ColorCache colorCache; private PyAutoIndentStrategy autoIndentStrategy; + // private ColorManager colorManager; private String[] indentPrefixes = { " ", "\t", ""}; *************** *** 255,261 **** } public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ! return new PyContentAssistant(); } } \ No newline at end of file --- 267,349 ---- } + + /* (non-Javadoc) + * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getContentAssistant(org.eclipse.jface.text.source.ISourceViewer) + */ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { ! // public final static String PY_SINGLELINE_STRING = "__python_singleline_string"; ! // public final static String PY_MULTILINE_STRING = "__python_multiline_string";); ! // create a content assistant: ! ContentAssistant assistant = new ContentAssistant(); ! // next create a content assistant processor to populate the completions window ! IContentAssistProcessor processor = new PythonCompletionProcessor(); ! assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_SINGLELINE_STRING ); ! assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_MULTILINE_STRING ); ! assistant.setContentAssistProcessor(processor,IDocument.DEFAULT_CONTENT_TYPE ); ! assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); ! // Allow automatic activation after 500 msec ! assistant.enableAutoActivation(true); ! assistant.setAutoActivationDelay(500); ! Color bgColor = colorCache.getColor(new RGB(230,255,230)); ! assistant.setProposalSelectorBackground(bgColor); ! return assistant; ! ! } ! ! ! // The presenter instance for the information window ! private static final DefaultInformationControl.IInformationPresenter presenter = ! new DefaultInformationControl.IInformationPresenter() { ! public String updatePresentation( ! Display display, ! String infoText, ! TextPresentation presentation, ! int maxWidth, ! int maxHeight) { ! int start = -1; ! // Loop over all characters of information text ! //These will have to be tailored for the appropriate Python ! for (int i = 0; i < infoText.length(); i++) { ! switch (infoText.charAt(i)) { ! case '<' : ! // Remember start of tag ! start = i; ! break; ! case '>' : ! if (start >= 0) { ! // We have found a tag and create a new style range ! StyleRange range = ! new StyleRange( ! start, ! i - start + 1, ! null, ! null, ! SWT.BOLD); ! // Add this style range to the presentation ! presentation.addStyleRange(range); ! // Reset tag start indicator ! start = -1; ! } ! break; ! } ! } ! // Return the information text ! return infoText; ! } ! }; ! ! /* (non-Javadoc) ! * @see org.eclipse.jface.text.source.SourceViewerConfiguration#getInformationControlCreator(org.eclipse.jface.text.source.ISourceViewer) ! */ ! public IInformationControlCreator getInformationControlCreator(ISourceViewer sourceViewer) { ! return new IInformationControlCreator() { ! public IInformationControl createInformationControl(Shell parent) { ! return new DefaultInformationControl(parent, presenter); ! } ! }; } + + + } \ No newline at end of file |
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/dictionary In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17511/src/org/python/pydev/editor/dictionary Modified Files: PyDClassItem.java PyDFunctionItem.java PopulateDictionary.java PyDictionary.java PyDLocalItem.java PyDEditorItem.java Log Message: Lots of improvement in detecting local variables Index: PyDFunctionItem.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/dictionary/PyDFunctionItem.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyDFunctionItem.java 30 Mar 2004 01:03:37 -0000 1.1 --- PyDFunctionItem.java 31 Mar 2004 02:28:42 -0000 1.2 *************** *** 23,27 **** PopulateDictionary populator = new PopulateDictionary(this, subItems); try { ! node.traverse(populator); } catch (Exception e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error populating ClassDef", e); --- 23,28 ---- PopulateDictionary populator = new PopulateDictionary(this, subItems); try { ! PopulateDictionary.FunctionDefTraverse(populator, node); ! //node.traverse(populator); } catch (Exception e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error populating ClassDef", e); *************** *** 31,35 **** public String toString() { ! return "Function " + node.name + "\n" + subItems.toString(); } --- 32,38 ---- public String toString() { ! String dic = subItems.toString(); ! String dicString = dic.length() == 0 ? " []" : "\n[ "+dic+" ]\n"; ! return node.name + " FUNCTION DICTIONARY" + dicString; } Index: PopulateDictionary.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/dictionary/PopulateDictionary.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PopulateDictionary.java 30 Mar 2004 01:03:37 -0000 1.1 --- PopulateDictionary.java 31 Mar 2004 02:28:42 -0000 1.2 *************** *** 9,12 **** --- 9,57 ---- import org.python.parser.ast.*; + /** + * PopulateDictionary creates a hierarchy of dictionaries. + * + * Every dictionary includes: classes, methods, and local variables. + * Each class/method have their own dictionaries. + * + * The whole tree except for classes and nodes is traversed recursively by this visitor. + * Classes and function definitions create their own dictionaries and traverse + * their own portions of the tree. + * + * TODO + * Detecting locals inside the AST is problematic. There is no clear way to detect them, + * in Python locals need not be declared, so they appear automatically when used. This means + * that detecting locals will be a perpetual hack. I'll mark the local detection code inside + * this file "LOCALS" so that you can grep for it. + * + * My current strategy is to trap visits to Name token. All locals manifestations have to involve + * this token. But some Name's are not locals. The only way to trap this occurence is + * higher up in the visitor pattern: + * + * For example: + * TryExcept::exceptTypeHandler::node.type is a Name. + * To intercept this, I need to override: + * exceptHandlerType::traverse so that it does not visit node.type + * TryExcept::traverse to trap exceptHandlerType::traverse + * + * Current list of overrides: + * TryExcept: for exceptHandlerType::node + * FunctionDef + * Grepping through org.python.parser.TreeBuilder.java is useful. Here you can see how Name + * is created and used. + * TreeBuilder name usage: + * JJTDOT_OP: creates an Attribute with embedded name + * JJTFUNCDEF: Name is functon name + * JJTEXTRAARGLIST: Part of ExtraArg + * JJTEXTRAKEYWORDLIST: Part of ExtraArg + * JJTCLASSDEF: Part of ClassDef + * JJTGLOBAL: Part of Global + * JJTKEYWORD: Part of keywordType + * JJTIMPORTFROM: Part of ImportFrom + * JJTDOTTED_NAME: creates the whole dotted name with Name.Load opearator? + * JJTDOTTED_AS_NAME, JJTIMPORT_AS_NAME: aliasType... + * + */ + class PopulateDictionary extends VisitorBase { *************** *** 24,36 **** public void traverse(SimpleNode node) throws Exception { ! System.out.println("Traverse?"); } ! ! public Object visitAssign(Assign node) throws Exception { ! dict.addLocal(new PyDLocalItem(parent, node)); return null; } - public Object visitClassDef(ClassDef node) throws Exception { dict.addClass(new PyDClassItem(parent, node)); --- 69,80 ---- public void traverse(SimpleNode node) throws Exception { ! node.traverse(this); } ! ! public Object visitAttribute(Attribute node) throws Exception { ! System.out.println("visitAttribute " + node.attr); return null; } public Object visitClassDef(ClassDef node) throws Exception { dict.addClass(new PyDClassItem(parent, node)); *************** *** 42,44 **** --- 86,194 ---- return null; } + + /* Locals muck */ + + /* Every name we reach is a local */ + public Object visitName(Name node) throws Exception { + dict.addLocal(new PyDLocalItem(parent, node)); + node.traverse(this); + return null; + } + + /** + * Calls have function as a Name. + * do not traverse. + * Note: we might have to traverse Call's keywords and starargs + * Python example: + * printSomething() # printSomething is not a local + */ + public Object visitCall(Call node) throws Exception { + return null; + } + + /** + * ExceptHandler name declaration avoidance. + * To avoid: + try: + import readline + except ImportError: + * ImportError being declared in a dictionary, we need to not + * traverse TODO + */ + public Object visitTryExcept(TryExcept node) throws Exception { + tryExceptTraverse(node, this); + return null; + } + + /** + * ExceptHandler name declaration avoidance. + * Only difference is lines commented out + * @see visitTryExcept + */ + public void excepthandlerTypeTraverse(excepthandlerType node, VisitorIF visitor) throws Exception{ + // if (node.type != null) + // node.type.accept(visitor); + if (node.name != null) + node.name.accept(visitor); + if (node.body != null) { + for (int i = 0; i < node.body.length; i++) { + if (node.body[i] != null) + node.body[i].accept(visitor); + } + } + } + + /** + * Copy of TryExcept::traverse. + * The only difference is that I call excepthandlerTypeTraverse + * @see visitTryExcept + */ + public void tryExceptTraverse(TryExcept node, VisitorIF visitor) throws Exception { + if (node.body != null) { + for (int i = 0; i < node.body.length; i++) { + if (node.body[i] != null) + node.body[i].accept(visitor); + } + } + if (node.handlers != null) { + for (int i = 0; i < node.handlers.length; i++) { + if (node.handlers[i] != null) + excepthandlerTypeTraverse(node.handlers[i],this); // modified + } + } + if (node.orelse != null) { + for (int i = 0; i < node.orelse.length; i++) { + if (node.orelse[i] != null) + node.orelse[i].accept(visitor); + } + } + } + + static void argumentsTypeTraverse(PopulateDictionary visitor, argumentsType node) throws Exception { + if (node.args != null) { + for (int i = 0; i < node.args.length; i++) { + if (node.args[i] != null) + node.args[i].accept(visitor); + } + } + // if (defaults != null) { + // for (int i = 0; i < defaults.length; i++) { + // if (defaults[i] != null) + // defaults[i].accept(visitor); + // } + // } + + } + + static void FunctionDefTraverse(PopulateDictionary visitor, FunctionDef node) throws Exception { + if (node.args != null) + argumentsTypeTraverse(visitor, node.args); + // node.args.traverse(visitor); + if (node.body != null) { + for (int i = 0; i < node.body.length; i++) { + if (node.body[i] != null) + node.body[i].accept(visitor); + } + } + } } \ No newline at end of file Index: PyDLocalItem.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/dictionary/PyDLocalItem.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyDLocalItem.java 30 Mar 2004 01:03:37 -0000 1.1 --- PyDLocalItem.java 31 Mar 2004 02:28:42 -0000 1.2 *************** *** 6,10 **** package org.python.pydev.editor.dictionary; ! import org.python.parser.ast.Assign; import org.eclipse.core.runtime.IStatus; import org.python.pydev.plugin.PydevPlugin; --- 6,10 ---- package org.python.pydev.editor.dictionary; ! import org.python.parser.ast.Name; import org.eclipse.core.runtime.IStatus; import org.python.pydev.plugin.PydevPlugin; *************** *** 16,22 **** public class PyDLocalItem extends PyDictionaryItem { ! Assign node; ! public PyDLocalItem(PyDictionaryItem parent, Assign node) { super(parent); this.node = node; --- 16,22 ---- public class PyDLocalItem extends PyDictionaryItem { ! Name node; ! public PyDLocalItem(PyDictionaryItem parent, Name node) { super(parent); this.node = node; *************** *** 31,38 **** public String toString() { ! String locals = ""; ! for (int i=0;i<node.targets.length; i++) ! locals += node.targets[i].toString(); ! return "Local " + locals + "\n" + subItems.toString(); } } --- 31,42 ---- public String toString() { ! return node.id; ! } ! ! /** ! * get the name of the local variable ! */ ! public String getName() { ! return node.id; } } Index: PyDEditorItem.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/dictionary/PyDEditorItem.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyDEditorItem.java 30 Mar 2004 01:03:37 -0000 1.1 --- PyDEditorItem.java 31 Mar 2004 02:28:42 -0000 1.2 *************** *** 56,60 **** public String toString() { ! return "Top node\n" + subItems.toString(); } } --- 56,60 ---- public String toString() { ! return "##### TOP NODE #########\n" + subItems.toString(); } } Index: PyDictionary.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/dictionary/PyDictionary.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyDictionary.java 30 Mar 2004 01:03:37 -0000 1.1 --- PyDictionary.java 31 Mar 2004 02:28:42 -0000 1.2 *************** *** 36,42 **** public void addLocal(PyDLocalItem newLocal) { ! locals.add(newLocal); } /** * For debugging, pretty print the dictionary --- 36,50 ---- public void addLocal(PyDLocalItem newLocal) { ! // eliminate dupes ! if (!hasLocal(newLocal)) ! locals.add(newLocal); } + boolean hasLocal(PyDLocalItem local) { + for (Iterator i = locals.iterator();i.hasNext();) + if (local.getName().equals(((PyDLocalItem)i.next()).getName())) + return true; + return false; + } /** * For debugging, pretty print the dictionary *************** *** 49,53 **** while (i.hasNext()) buf.append(i.next().toString()); ! buf.append("\n"); } if (!functions.isEmpty()) { --- 57,61 ---- while (i.hasNext()) buf.append(i.next().toString()); ! // buf.append("\n"); } if (!functions.isEmpty()) { *************** *** 56,67 **** while (i.hasNext()) buf.append(i.next().toString()); ! buf.append("\n"); } if (!locals.isEmpty()) { buf.append("Locals: "); Iterator i = locals.iterator(); ! while (i.hasNext()) buf.append(i.next().toString()); ! buf.append("\n"); } return buf.toString(); --- 64,77 ---- while (i.hasNext()) buf.append(i.next().toString()); ! // buf.append("\n"); } if (!locals.isEmpty()) { buf.append("Locals: "); Iterator i = locals.iterator(); ! while (i.hasNext()) { buf.append(i.next().toString()); ! buf.append(","); ! } ! // buf.append("\n"); } return buf.toString(); Index: PyDClassItem.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/dictionary/PyDClassItem.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyDClassItem.java 30 Mar 2004 01:03:37 -0000 1.1 --- PyDClassItem.java 31 Mar 2004 02:28:42 -0000 1.2 *************** *** 31,35 **** public String toString() { ! return "Class " + node.name + "\n" + subItems.toString(); } } --- 31,35 ---- public String toString() { ! return node.name + " CLASS & ITS DICTIONARY\n" + "[" + subItems.toString() + "]"; } } |
From: William W. <wrw...@us...> - 2004-03-30 20:14:40
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14862/src/org/python/pydev/debug/ui/launching Added Files: PythonDebugTabGroup.java PythonTab.java Log Message: Add extensions to run from the Run menu. Need to unify this with the context menu Run action. --- NEW FILE: PythonTab.java --- /* * Author: wrwright * Created on Feb 7, 2004 * License: Common Public License v1.0 */ package org.python.pydev.debug.ui.launching; import java.io.*; import java.net.MalformedURLException; import java.net.URL; import org.eclipse.core.runtime.CoreException; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.jface.resource.ImageDescriptor; import org.eclipse.swt.SWT; import org.eclipse.swt.events.ModifyEvent; import org.eclipse.swt.events.ModifyListener; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; import org.eclipse.swt.graphics.FontMetrics; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.layout.GridData; import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.FileDialog; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Text; import org.eclipse.swt.widgets.DirectoryDialog; import org.eclipse.ui.help.WorkbenchHelp; import org.eclipse.ui.externaltools.internal.model.*; import org.python.pydev.debug.core.Constants; import org.python.pydev.debug.core.PydevDebugPlugin; /** * @author wwright * * Configuration data for python launch. */ public class PythonTab implements ILaunchConfigurationTab { protected static final String interpreterAttribute = IExternalToolConstants.ATTR_LOCATION; protected static final String workingDirectoryAttribute = IExternalToolConstants.ATTR_WORKING_DIRECTORY; protected static final String argumentsAttribute = "python.arguments"; protected static final String mainScriptAttribute = "python.mainScript"; protected static final String stopInMainAttribute = "python.stopInMain"; private String interpreter = ""; private String mainScript = ""; private String workingDir = ""; private String arguments = ""; private Text fMainText; private Text fWorkingDirText; private Text fInterpreterText; private Text fArgumentsText; private ILaunchConfigurationDialog myLaunchDialog; private Image tabImage; /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#createControl(org.eclipse.swt.widgets.Composite) */ public void createControl(Composite parent) { Button fStopInMainCheckButton; Button fSearchExternalJarsCheckButton; Button fSearchButton; Label fMainLabel; Button fInterpreterButton; Label fInterpreterLabel; Composite comp = new Composite(parent, SWT.NONE); setControl(comp); WorkbenchHelp.setHelp(getControl(), "SomeContext"); GridLayout topLayout = new GridLayout(); comp.setLayout(topLayout); GridData gd; // --------- Interpreter ------------- String buttonText = "Browse..."; String labelText = "Interpreter"; SelectionAdapter listener = new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { handleInterpreterButtonSelected(); }}; fInterpreterText = makeEntryField(comp, buttonText, labelText, listener); // --------- Main Script ------------- buttonText = "Browse..."; labelText = "Main Script"; listener = new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { handleMainButtonSelected(); }}; fMainText = makeEntryField(comp, buttonText, labelText, listener); // --------- Arguments ------------- labelText = "Program Arguments"; fArgumentsText = makeEntryField(comp, null, labelText, null); // --------- Working Directory ------------- buttonText = "Browse..."; labelText = "Working Directory"; listener = new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { handleWorkingDirButtonSelected(); }}; fWorkingDirText = makeEntryField(comp, buttonText, labelText, listener); fStopInMainCheckButton = new Button(comp, SWT.CHECK); fStopInMainCheckButton.setText("Stop in Main Script"); //$NON-NLS-1$ fStopInMainCheckButton.setFont(comp.getParent().getFont()); fStopInMainCheckButton.addSelectionListener(new SelectionAdapter() { public void widgetSelected(SelectionEvent evt) { updateLaunchConfigurationDialog(); } }); } private Text makeEntryField( Composite parent, String buttonText, String labelText, SelectionAdapter listener) { Button fSearchExternalJarsCheckButton; Button fSearchButton; Label fMainLabel; GridData gd; createVerticalSpacer(parent); Composite mainComp = new Composite(parent, SWT.NONE); GridLayout mainLayout = new GridLayout(); mainLayout.numColumns = 2; mainLayout.marginHeight = 0; mainLayout.marginWidth = 0; mainComp.setLayout(mainLayout); gd = new GridData(GridData.FILL_HORIZONTAL); mainComp.setLayoutData(gd); mainComp.setFont(parent.getParent().getFont()); fMainLabel = new Label(mainComp, SWT.NONE); fMainLabel.setText(labelText); gd = new GridData(); gd.horizontalSpan = 2; fMainLabel.setLayoutData(gd); fMainLabel.setFont(parent.getParent().getFont()); Text retText = new Text(mainComp, SWT.SINGLE | SWT.BORDER); gd = new GridData(GridData.FILL_HORIZONTAL|GridData.HORIZONTAL_ALIGN_BEGINNING); retText.setLayoutData(gd); retText.setFont(parent.getParent().getFont()); retText.addModifyListener(new ModifyListener() { public void modifyText(ModifyEvent evt) { updateLaunchConfigurationDialog(); } }); if (buttonText != null) { fSearchButton = createPushButton(mainComp,buttonText, null); fSearchButton.addSelectionListener(listener); } return retText; } /** * Raise a file dialog to look for an interpreter */ private void handleInterpreterButtonSelected() { FileDialog dialog = new FileDialog(getControl().getShell()); String interp = dialog.open(); if (interp != null) fInterpreterText.setText(interp); } /** * Raise a file dialog to look for the main script */ private void handleMainButtonSelected() { FileDialog dialog = new FileDialog(getControl().getShell()); String [] exts = {"*.py"}; dialog.setFilterExtensions(exts); String main = dialog.open(); if (main != null) fMainText.setText(main); } /** * Raise a directory dialog to look for a CWD to run in */ private void handleWorkingDirButtonSelected() { DirectoryDialog dialog = new DirectoryDialog(getControl().getShell()); String dir = dialog.open(); if (dir != null) fWorkingDirText.setText(dir); } /** * sync the instance data with the widgets */ private void updateLaunchConfigurationDialog() { interpreter = fInterpreterText.getText(); mainScript = fMainText.getText(); workingDir = fWorkingDirText.getText(); arguments = fArgumentsText.getText(); validCheck(interpreter, mainScript, workingDir); myLaunchDialog.updateButtons(); myLaunchDialog.updateMessage(); } /** * Create some empty space */ private Label createVerticalSpacer(Composite comp) { return new Label(comp, SWT.NONE); } Control myControl; /** * @param comp */ private void setControl(Composite comp) { myControl = comp; } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getControl() */ public Control getControl() { return myControl; } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setDefaults(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ public void setDefaults(ILaunchConfigurationWorkingCopy configuration) { try { interpreter = configuration.getAttribute(interpreterAttribute, interpreter); mainScript = configuration.getAttribute(mainScriptAttribute, mainScript); workingDir = configuration.getAttribute(workingDirectoryAttribute, workingDir); arguments = configuration.getAttribute(argumentsAttribute, arguments); configuration.getAttribute(stopInMainAttribute, false); } catch (CoreException e) { e.printStackTrace(); } } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#initializeFrom(org.eclipse.debug.core.ILaunchConfiguration) */ public void initializeFrom(ILaunchConfiguration configuration) { try { fInterpreterText.setText(configuration.getAttribute(interpreterAttribute, interpreter)); fMainText.setText(configuration.getAttribute(mainScriptAttribute, mainScript)); fWorkingDirText.setText(configuration.getAttribute(workingDirectoryAttribute, workingDir)); fArgumentsText.setText(configuration.getAttribute(argumentsAttribute, arguments)); configuration.getAttribute(stopInMainAttribute, false); } catch (CoreException e) { e.printStackTrace(); } } protected Button createPushButton(Composite parent, String label, FontMetrics fontMetrics) { Button button = new Button(parent, SWT.PUSH); button.setFont(parent.getFont()); button.setText(label); GridData gd= getButtonGridData(button, fontMetrics); button.setLayoutData(gd); return button; } private GridData getButtonGridData(Button button, FontMetrics fontMetrics) { GridData gd= new GridData( GridData.VERTICAL_ALIGN_BEGINNING); int widthHint= 0;//Dialog.convertHorizontalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_WIDTH); gd.widthHint= Math.max(widthHint, button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).x); gd.heightHint= button.computeSize(SWT.DEFAULT, SWT.DEFAULT, true).y;//Dialog.convertVerticalDLUsToPixels(fontMetrics, IDialogConstants.BUTTON_HEIGHT); return gd; } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#dispose() */ public void dispose() { if (tabImage != null) { tabImage.dispose(); tabImage = null; } } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#performApply(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) */ public void performApply(ILaunchConfigurationWorkingCopy configuration) { configuration.setAttribute(interpreterAttribute, interpreter); configuration.setAttribute(mainScriptAttribute, mainScript); configuration.setAttribute(workingDirectoryAttribute, workingDir); configuration.setAttribute(argumentsAttribute, arguments); configuration.setAttribute(stopInMainAttribute, false); // real arguments are main script name + arguments configuration.setAttribute(IExternalToolConstants.ATTR_TOOL_ARGUMENTS, "-u " + mainScript + " " + arguments); } private String error_msg; /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getErrorMessage() */ public String getErrorMessage() { return error_msg; } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getMessage() */ public String getMessage() { return null; } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#isValid(org.eclipse.debug.core.ILaunchConfiguration) */ public boolean isValid(ILaunchConfiguration launchConfig) { boolean ret = false; try { String interpName = launchConfig.getAttribute(interpreterAttribute, ""); String scriptName = launchConfig.getAttribute(mainScriptAttribute, ""); String workingDirName = launchConfig.getAttribute(workingDirectoryAttribute, ""); ret = validCheck(interpName, scriptName, workingDirName); } catch (CoreException e) { e.printStackTrace(); } return ret; } /* * Check for invalid entry field data and set the error_msg string accordingly. */ private boolean validCheck(String interpName, String scriptName, String workingDirName) { boolean ret; error_msg = null; File executable = new File(interpName); File script = new File(scriptName); File dir = new File(workingDirName); ret = executable.exists() && script.exists() && dir.isDirectory(); if (!executable.exists()) { error_msg = "Interpreter '"+interpName+"' does not exist."; } else if(!script.exists()) { error_msg = "Main script '"+scriptName+"' does not exist."; } else if(!dir.isDirectory()) { error_msg = "Working directory '"+workingDirName+"' does not exist."; } return ret; } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#canSave() */ public boolean canSave() { return true; } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#setLaunchConfigurationDialog(org.eclipse.debug.ui.ILaunchConfigurationDialog) */ public void setLaunchConfigurationDialog(ILaunchConfigurationDialog dialog) { myLaunchDialog = dialog; } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#launched(org.eclipse.debug.core.ILaunch) */ public void launched(ILaunch launch) { // TODO: do I care that this was launched? } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getName() */ public String getName() { return "Python"; } /* (non-Javadoc) * @see org.eclipse.debug.ui.ILaunchConfigurationTab#getImage() */ public Image getImage() { if (tabImage == null) { ImageDescriptor desc; try { URL url = new URL( PydevDebugPlugin .getDefault() .getDescriptor() .getInstallURL(), Constants.MAIN_ICON); desc = ImageDescriptor.createFromURL(url); } catch (MalformedURLException e) { desc = ImageDescriptor.getMissingImageDescriptor(); e.printStackTrace(); } tabImage = desc.createImage(); } return tabImage; } } --- NEW FILE: PythonDebugTabGroup.java --- /* * Author: wrwright * Created on Feb 7, 2004 * License: Common Public License v1.0 */ package org.python.pydev.debug.ui.launching; import org.eclipse.debug.ui.CommonTab; import org.eclipse.debug.ui.ILaunchConfigurationDialog; import org.eclipse.debug.ui.ILaunchConfigurationTab; import org.eclipse.debug.ui.AbstractLaunchConfigurationTabGroup; /** * Defines tab set for python launcher. */ public class PythonDebugTabGroup extends AbstractLaunchConfigurationTabGroup { /** * @see AbstractLaunchConfigurationTabGroup#createTabs */ public void createTabs(ILaunchConfigurationDialog dialog, String mode) { ILaunchConfigurationTab[] tabs = new ILaunchConfigurationTab[] { new PythonTab(), new CommonTab() }; setTabs(tabs); } } |
From: William W. <wrw...@us...> - 2004-03-30 20:14:39
|
Update of /cvsroot/pydev/org.python.pydev.debug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14862 Modified Files: plugin.xml Log Message: Add extensions to run from the Run menu. Need to unify this with the context menu Run action. Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/plugin.xml,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** plugin.xml 29 Mar 2004 17:02:26 -0000 1.4 --- plugin.xml 30 Mar 2004 20:02:58 -0000 1.5 *************** *** 167,169 **** --- 167,217 ---- </extension> + <!-- Begin Run->Run... extensions --> + <extension + point="org.eclipse.debug.core.launchConfigurationTypes"> + <launchConfigurationType + name="Python" + delegate="org.eclipse.ui.externaltools.internal.program.launchConfigurations.ProgramLaunchDelegate" + modes="run" + id="org.python.pydev.debug.ui.launching.launchConfigurationType1"> + <fileExtension + extension="py"> + </fileExtension> + <fileExtension + extension="pyc"> + </fileExtension> + </launchConfigurationType> + </extension> + <extension + point="org.eclipse.debug.ui.launchConfigurationTabGroups"> + <launchConfigurationTabGroup + type="org.python.pydev.debug.ui.launching.launchConfigurationType1" + helpContextId="foo" + class="org.python.pydev.debug.ui.launching.PythonDebugTabGroup" + id="org.python.pydev.debug.ui.launching.PythonDebugTabGroup"> + </launchConfigurationTabGroup> + </extension> + <extension + id="org.python.debug.ui.image" + point="org.eclipse.debug.ui.launchConfigurationTypeImages"> + <launchConfigurationTypeImage + icon="icons/python.gif" + configTypeID="org.python.pydev.debug.ui.launching.launchConfigurationType1" + id="org.python.pydev.debug.ui.launching.launchConfigurationTypeImage1"> + </launchConfigurationTypeImage> + </extension> + <extension + id="org.python.debug.ui.lineTracker" + point="org.eclipse.debug.ui.consoleLineTrackers"> + <consoleLineTracker + class="org.python.pydev.debug.ui.PythonConsoleLineTracker" + processType="python" + id="org.python.pydev.debug.ui.PythonConsoleLineTracker"> + </consoleLineTracker> + </extension> + <!-- End Run->Run... extensions --> + + + + </plugin> |
From: Aleksandar T. <at...@us...> - 2004-03-30 01:15:12
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3679/src/org/python/pydev/outline Added Files: package.html Log Message: Started imoplementation of the PyDictionary --- NEW FILE: package.html --- <body> Outliner. <p>The Raw* classes are obsolete. PyOutlinePage creates ParsedModel. ParsedModel registers as a listener with PyParser. PyParser gives ParsedModel a parse tree, which get converted into ParsedItems that are suitable to display in the outline. </body> |
From: Aleksandar T. <at...@us...> - 2004-03-30 01:15:10
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/dictionary In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3679/src/org/python/pydev/editor/dictionary Added Files: PyDClassItem.java PyDFunctionItem.java DebugVisitor.java PyDictionaryItem.java PyDLocalItem.java PyDEditorItem.java PopulateDictionary.java PyDictionary.java Log Message: Started imoplementation of the PyDictionary --- NEW FILE: DebugVisitor.java --- /* * Author: atotic * Created on Mar 29, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.dictionary; import org.python.parser.SimpleNode; import org.python.parser.ast.*; /** * For debugging only. Prints out all the results of a visitor pattern. * This is a org.python.parser visitor. */ class DebugVisitor extends VisitorBase { DebugVisitor() { } protected Object unhandled_node(SimpleNode node) throws Exception { System.out.println("unhandled_node"); return null; } public void traverse(SimpleNode node) throws Exception { System.out.println("traverse"); } public Object visitAttribute(Attribute node) throws Exception { System.out.println("visitAttribute " + node.attr); return null; } public Object visitClassDef(ClassDef node) throws Exception { System.out.println("visitClassDef:" + node.name); return null; } public Object visitExpr(Expr node) throws Exception { System.out.println("visitExpr:" + node.toString("")); return null; } public Object visitExpression(Expression node) throws Exception { System.out.println("visitExpression:" + node.toString("")); return null; } public Object visitFunctionDef(FunctionDef node) throws Exception { System.out.println("visitFunctionDef:" + node.toString("")); return null; } public Object visitGlobal(Global node) throws Exception { System.out.println("visitGlobal:" + node.toString("")); return null; } public Object visitName(Name node) throws Exception { System.out.println("visitName:" + node.toString("")); return null; } public Object visitAssert(Assert node) throws Exception { System.out.println("visitAssert:" + node.toString("")); return null; } public Object visitAssign(Assign node) throws Exception { System.out.println("visitAssign:" + node.toString("")); return null; } public Object visitAugAssign(AugAssign node) throws Exception { System.out.println("visitAugAssign:" + node.toString("")); return null; } public Object visitBinOp(BinOp node) throws Exception { System.out.println("visitBinOp:" + node.toString("")); return null; } public Object visitBoolOp(BoolOp node) throws Exception { System.out.println("visitBoolOp:" + node.toString("")); return null; } public Object visitBreak(Break node) throws Exception { System.out.println("visitBreak:" + node.toString("")); return null; } public Object visitCall(Call node) throws Exception { System.out.println("visitCall:" + node.toString("")); return null; } public Object visitCompare(Compare node) throws Exception { System.out.println("visitCompare:" + node.toString("")); return null; } public Object visitContinue(Continue node) throws Exception { System.out.println("visitContinue:" + node.toString("")); return null; } public Object visitDelete(Delete node) throws Exception { System.out.println("visitDelete:" + node.toString("")); return null; } public Object visitDict(Dict node) throws Exception { System.out.println("visitDict:" + node.toString("")); return null; } public Object visitEllipsis(Ellipsis node) throws Exception { System.out.println("visitEllipsis:" + node.toString("")); return null; } public Object visitExec(Exec node) throws Exception { System.out.println("visitExec:" + node.toString("")); return null; } public Object visitExtSlice(ExtSlice node) throws Exception { System.out.println("visitExtSlice:" + node.toString("")); return null; } public Object visitFor(For node) throws Exception { System.out.println("visitFor:" + node.toString("")); return null; } public Object visitIf(If node) throws Exception { System.out.println("visitIf:" + node.toString("")); return null; } public Object visitImport(Import node) throws Exception { System.out.println("visitImport:" + node.toString("")); return null; } public Object visitImportFrom(ImportFrom node) throws Exception { System.out.println("visitImportFrom:" + node.toString("")); return null; } public Object visitIndex(Index node) throws Exception { System.out.println("visitIndex:" + node.toString("")); return null; } public Object visitInteractive(Interactive node) throws Exception { System.out.println("visitInteractive:" + node.toString("")); return null; } public Object visitLambda(Lambda node) throws Exception { System.out.println("visitLambda:" + node.toString("")); return null; } public Object visitList(List node) throws Exception { System.out.println("visitList:" + node.toString("")); return null; } public Object visitListComp(ListComp node) throws Exception { System.out.println("visitListComp:" + node.toString("")); return null; } public Object visitModule(Module node) throws Exception { System.out.println("visitModule:" + node.toString("")); return null; } public Object visitNum(Num node) throws Exception { System.out.println("visitNum:" + node.toString("")); return null; } public Object visitPass(Pass node) throws Exception { System.out.println("visitPass:" + node.toString("")); return null; } public Object visitPrint(Print node) throws Exception { System.out.println("visitPrint:" + node.toString("")); return null; } public Object visitRaise(Raise node) throws Exception { System.out.println("visitRaise:" + node.toString("")); return null; } public Object visitRepr(Repr node) throws Exception { System.out.println("visitRepr:" + node.toString("")); return null; } public Object visitReturn(Return node) throws Exception { System.out.println("visitReturn:" + node.toString("")); return null; } public Object visitSlice(Slice node) throws Exception { System.out.println("visitSlice:" + node.toString("")); return null; } public Object visitStr(Str node) throws Exception { System.out.println("visitStr:" + node.toString("")); return null; } public Object visitSubscript(Subscript node) throws Exception { System.out.println("visitSubscript:" + node.toString("")); return null; } public Object visitSuite(Suite node) throws Exception { System.out.println("visitSuite:" + node.toString("")); return null; } public Object visitTryExcept(TryExcept node) throws Exception { System.out.println("visitTryExcept:" + node.toString("")); return null; } public Object visitTryFinally(TryFinally node) throws Exception { System.out.println("visitTryFinally:" + node.toString("")); return null; } public Object visitTuple(Tuple node) throws Exception { System.out.println("visitTuple:" + node.toString("")); return null; } public Object visitUnaryOp(UnaryOp node) throws Exception { System.out.println("visitUnaryOp:" + node.toString("")); return null; } public Object visitWhile(While node) throws Exception { System.out.println("visitWhile:" + node.toString("")); return null; } public Object visitYield(Yield node) throws Exception { System.out.println("visitYield:" + node.toString("")); return null; } } --- NEW FILE: PyDFunctionItem.java --- /* * Author: atotic * Created on Mar 29, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.dictionary; import org.python.parser.ast.FunctionDef; import org.eclipse.core.runtime.IStatus; import org.python.pydev.plugin.PydevPlugin; /** * * TODO Comment this class */ public class PyDFunctionItem extends PyDictionaryItem { FunctionDef node; public PyDFunctionItem(PyDictionaryItem parent, FunctionDef node) { super(parent); this.node = node; PopulateDictionary populator = new PopulateDictionary(this, subItems); try { node.traverse(populator); } catch (Exception e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error populating ClassDef", e); e.printStackTrace(); } } public String toString() { return "Function " + node.name + "\n" + subItems.toString(); } } --- NEW FILE: PopulateDictionary.java --- /* * Author: atotic * Created on Mar 29, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.dictionary; import org.python.parser.SimpleNode; import org.python.parser.ast.*; class PopulateDictionary extends VisitorBase { PyDictionary dict; PyDictionaryItem parent; PopulateDictionary(PyDictionaryItem parent, PyDictionary dict) { this.parent = parent; this.dict = dict; } protected Object unhandled_node(SimpleNode node) throws Exception { return null; } public void traverse(SimpleNode node) throws Exception { System.out.println("Traverse?"); } public Object visitAssign(Assign node) throws Exception { dict.addLocal(new PyDLocalItem(parent, node)); return null; } public Object visitClassDef(ClassDef node) throws Exception { dict.addClass(new PyDClassItem(parent, node)); return null; } public Object visitFunctionDef(FunctionDef node) throws Exception { dict.addFunction(new PyDFunctionItem(parent, node)); return null; } } --- NEW FILE: PyDictionaryItem.java --- /* * Author: atotic * Created on Mar 29, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.dictionary; import org.eclipse.jface.text.IRegion; /** * A generic dictionary item. * * Subclasses hold additional information, such as class name/file position/etc. */ public class PyDictionaryItem { protected IRegion position; protected PyDictionaryItem parent; protected PyDictionary subItems; public PyDictionaryItem(PyDictionaryItem parent) { this.parent = parent; this.subItems = new PyDictionary(); } public PyDictionaryItem getParent() { return parent; } public void setPosition(IRegion position) { this.position = position; } public IRegion getPosition() { return position; } } --- NEW FILE: PyDLocalItem.java --- /* * Author: atotic * Created on Mar 29, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.dictionary; import org.python.parser.ast.Assign; import org.eclipse.core.runtime.IStatus; import org.python.pydev.plugin.PydevPlugin; /** * * TODO Comment this class */ public class PyDLocalItem extends PyDictionaryItem { Assign node; public PyDLocalItem(PyDictionaryItem parent, Assign node) { super(parent); this.node = node; PopulateDictionary populator = new PopulateDictionary(this, subItems); try { node.traverse(populator); } catch (Exception e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error populating ClassDef", e); e.printStackTrace(); } } public String toString() { String locals = ""; for (int i=0;i<node.targets.length; i++) locals += node.targets[i].toString(); return "Local " + locals + "\n" + subItems.toString(); } } --- NEW FILE: PyDEditorItem.java --- /* * Author: atotic * Created on Mar 29, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.dictionary; import org.eclipse.core.runtime.IStatus; import org.python.parser.SimpleNode; import org.python.pydev.editor.PyEdit; import org.python.pydev.parser.IParserListener; import org.python.pydev.parser.PyParser; import org.python.pydev.plugin.PydevPlugin; /** * Represents a PyEdit item. * I wanted to name this one PyDFileItem, but the file item can represent any * file, and this class really represents a live editor. */ public class PyDEditorItem extends PyDictionaryItem implements IParserListener{ PyEdit editor; public PyDEditorItem(PyParser parser) { super(null); parser.addParseListener(this); // TODO Auto-generated constructor stub } public void createDictionary(SimpleNode topNode) { subItems = new PyDictionary(); PopulateDictionary v = new PopulateDictionary(this, subItems); try {// traversal fills in the children topNode.traverse(v); } catch (Exception e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error creating dictionary", e); e.printStackTrace(); } } /* * Callback from PyParser */ public void parserChanged(SimpleNode root) { createDictionary(root); System.out.println(toString()); } /* * Callback from PyParser */ public void parserError(Throwable error) { // we'll ignore errors } public String toString() { return "Top node\n" + subItems.toString(); } } --- NEW FILE: PyDictionary.java --- /* * Author: atotic * Created on Mar 26, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.dictionary; import java.util.ArrayList; import java.util.Iterator; /** * * TODO Comment this class */ public class PyDictionary { ArrayList classes; ArrayList functions; ArrayList locals; ArrayList methods; public PyDictionary() { classes = new ArrayList(); functions = new ArrayList(); locals = new ArrayList(); } public void addClass(PyDClassItem newClass) { classes.add(newClass); } public void addFunction(PyDFunctionItem newFunction) { functions.add(newFunction); } public void addLocal(PyDLocalItem newLocal) { locals.add(newLocal); } /** * For debugging, pretty print the dictionary */ public String toString() { StringBuffer buf = new StringBuffer(); if (!classes.isEmpty()) { buf.append("Classes: "); Iterator i = classes.iterator(); while (i.hasNext()) buf.append(i.next().toString()); buf.append("\n"); } if (!functions.isEmpty()) { buf.append("Functions: "); Iterator i = functions.iterator(); while (i.hasNext()) buf.append(i.next().toString()); buf.append("\n"); } if (!locals.isEmpty()) { buf.append("Locals: "); Iterator i = locals.iterator(); while (i.hasNext()) buf.append(i.next().toString()); buf.append("\n"); } return buf.toString(); } } --- NEW FILE: PyDClassItem.java --- /* * Author: atotic * Created on Mar 29, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor.dictionary; import org.eclipse.core.runtime.IStatus; import org.python.parser.ast.ClassDef; import org.python.pydev.plugin.PydevPlugin; /** * * TODO Comment this class */ public class PyDClassItem extends PyDictionaryItem { ClassDef node; public PyDClassItem(PyDictionaryItem parent, ClassDef node) { super(parent); this.node = node; PopulateDictionary populator = new PopulateDictionary(this, subItems); try { node.traverse(populator); } catch (Exception e) { PydevPlugin.log(IStatus.ERROR, "Unexpected error populating ClassDef", e); e.printStackTrace(); } } public String toString() { return "Class " + node.name + "\n" + subItems.toString(); } } |
From: Aleksandar T. <at...@us...> - 2004-03-30 01:15:10
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3679/src/org/python/pydev/parser Modified Files: PyParser.java Log Message: Started imoplementation of the PyDictionary Index: PyParser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/parser/PyParser.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyParser.java 26 Mar 2004 22:51:12 -0000 1.4 --- PyParser.java 30 Mar 2004 01:03:38 -0000 1.5 *************** *** 42,51 **** IDocument document; PyEdit editorView; IDocumentListener documentListener; // listens to changes in the document ArrayList parserListeners; // listeners that get notified - SimpleNode root; // root of the last PythonGrammar analysis - static final boolean parseOnThread = true; // can turn of thread parsing for debugging ParsingThread parsingThread; // thread that reparses the document --- 42,50 ---- IDocument document; PyEdit editorView; + SimpleNode root = null; IDocumentListener documentListener; // listens to changes in the document ArrayList parserListeners; // listeners that get notified static final boolean parseOnThread = true; // can turn of thread parsing for debugging ParsingThread parsingThread; // thread that reparses the document *************** *** 53,60 **** public PyParser(PyEdit editorView) { this.editorView = editorView; - root = null; parserListeners = new ArrayList(); parsingThread = new ParsingThread(this); ! parsingThread.setName("Parsing thread"); } --- 52,58 ---- public PyParser(PyEdit editorView) { this.editorView = editorView; parserListeners = new ArrayList(); parsingThread = new ParsingThread(this); ! parsingThread.setName("Pydev parsing thread"); } *************** *** 65,68 **** --- 63,70 ---- parsingThread.diePlease(); } + + public SimpleNode getRoot() { + return root; + } public void setDocument(IDocument document) { *************** *** 100,109 **** reparseDocument(); } ! ! ! public SimpleNode getRoot() { ! return root; ! } ! /** stock listener implementation */ public void addParseListener(IParserListener listener) { --- 102,106 ---- reparseDocument(); } ! /** stock listener implementation */ public void addParseListener(IParserListener listener) { *************** *** 123,127 **** * event is fired whenever we get a new root */ ! protected void fireParserChanged() { if (parserListeners.size() > 0) { ArrayList list= new ArrayList(parserListeners); --- 120,125 ---- * event is fired whenever we get a new root */ ! protected void fireParserChanged(SimpleNode root) { ! this.root = root; if (parserListeners.size() > 0) { ArrayList list= new ArrayList(parserListeners); *************** *** 153,156 **** --- 151,155 ---- */ void reparseDocument() { + // create a stream with document's data StringReader inString = new StringReader(document.get()); ReaderCharStream in = new ReaderCharStream(inString); *************** *** 163,169 **** try { SimpleNode newRoot = grammar.file_input(); // parses the file - root = newRoot; original.deleteMarkers(IMarker.PROBLEM, false, 1); ! fireParserChanged(); } catch (ParseException parseErr) { fireParserError(parseErr); --- 162,167 ---- try { SimpleNode newRoot = grammar.file_input(); // parses the file original.deleteMarkers(IMarker.PROBLEM, false, 1); ! fireParserChanged(newRoot); } catch (ParseException parseErr) { fireParserError(parseErr); |
From: Aleksandar T. <at...@us...> - 2004-03-30 01:15:10
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3679/src/org/python/pydev/editor Modified Files: PyEditConfiguration.java PyEdit.java package.html Added Files: PyContentAssistProcessor.java PyContentAssistant.java Log Message: Started imoplementation of the PyDictionary Index: package.html =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/package.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** package.html 10 Dec 2003 10:14:27 -0000 1.1 --- package.html 30 Mar 2004 01:03:37 -0000 1.2 *************** *** 4,6 **** --- 4,44 ---- <p>The main widget is {@link org.python.pydev.editor.PyEdit PyEdit}. It ties other utility classes together, sets error markers. + <p>PyContentAssistant & PyContentAssisProcessors are dummy classes, + avaiting implementation. + <h3>Design notes</h3> + <p>I really want to implement ctrl-click navigation. It is not as easy + as pluging in a new class to PyEditConfiguration. This one + See JavaEditor::MouseClickListener (set breakpoint at highlightRegion if debugging to see it in action) + <p> + <pre> + To implement navigation/completion. + - Each editor needs a vocabulary. The vocabulary is hierarchical in structure, and + has items: + Top-level (file vocabulary) has: + classes + functions + globals? + Class vocabulary has: + documentation string + classes + methods (functions) + instance variables (inferred from self.) + Method/function vocabulary has: + documentation string + locals + classes + functions + + Each definition in the vocabulary describes: + - where is it defined (file, char span) + - character range where it is applicable + + Vocabulary usage: + Find an innermost vocabulary containing current selection. + Then quiz it for whatever is needed + + Questions: + can vocabularies be overlapping? That would make things hard. + + </pre> </body> \ No newline at end of file Index: PyEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEdit.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyEdit.java 12 Mar 2004 00:18:40 -0000 1.8 --- PyEdit.java 30 Mar 2004 01:03:37 -0000 1.9 *************** *** 32,35 **** --- 32,36 ---- import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.plugin.PydevPrefs; + import org.python.pydev.editor.dictionary.PyDEditorItem; import org.python.pydev.outline.PyOutlinePage; import org.python.pydev.outline.SelectionPosition; *************** *** 47,51 **** * <li>The {@link org.python.pydev.outline.PyOutlinePage PyOutlinePage} shows the outline * ! * <p>Listens to the parser's events, and displays error markers from the parser * * <p>General notes: --- 48,52 ---- * <li>The {@link org.python.pydev.outline.PyOutlinePage PyOutlinePage} shows the outline * ! * <p>Listens to the parser's events, and displays error markers from the parser. * * <p>General notes: *************** *** 66,69 **** --- 67,72 ---- /** need to hold onto it to support indentPrefix change through preferences */ PyEditConfiguration editConfiguration; + /** top-level dictionary */ + PyDEditorItem dictionaryRoot; public PyEdit() { *************** *** 140,143 **** --- 143,148 ---- parser.setDocument(getDocumentProvider().getDocument(input)); + dictionaryRoot = new PyDEditorItem(parser); + // listen to changes in TAB_WIDTH preference prefListener = new Preferences.IPropertyChangeListener() { --- NEW FILE: PyContentAssistant.java --- /* * Author: atotic * Created on Mar 25, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContentAssistant; /** * * TODO Implement this class * It should implement navigation/ */ public class PyContentAssistant implements IContentAssistant { /** */ public void install(ITextViewer textViewer) { // TODO Auto-generated method stub } public void uninstall() { // TODO Auto-generated method stub } public String showPossibleCompletions() { // TODO Auto-generated method stub return null; } public String showContextInformation() { // TODO Auto-generated method stub return null; } /** * override * TODO comment this method */ public IContentAssistProcessor getContentAssistProcessor(String contentType) { // TODO Auto-generated method stub return null; } } --- NEW FILE: PyContentAssistProcessor.java --- /* * Author: atotic * Created on Mar 25, 2004 * License: Common Public License v1.0 */ package org.python.pydev.editor; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.ICompletionProposal; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationValidator; /** * * TODO Implement this class */ public class PyContentAssistProcessor implements IContentAssistProcessor { static char[] completionProposalActivators = new char['.']; /** * override * TODO comment this method */ public ICompletionProposal[] computeCompletionProposals( ITextViewer viewer, int documentOffset) { // TODO Auto-generated method stub return null; } /** * override * TODO comment this method */ public IContextInformation[] computeContextInformation( ITextViewer viewer, int documentOffset) { // TODO Auto-generated method stub return null; } public char[] getCompletionProposalAutoActivationCharacters() { return completionProposalActivators; } /** * override * TODO comment this method */ public char[] getContextInformationAutoActivationCharacters() { // TODO Auto-generated method stub return null; } /** * override * TODO comment this method */ public String getErrorMessage() { // TODO Auto-generated method stub return null; } /** * override * TODO comment this method */ public IContextInformationValidator getContextInformationValidator() { // TODO Auto-generated method stub return null; } } Index: PyEditConfiguration.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditConfiguration.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyEditConfiguration.java 12 Mar 2004 00:18:40 -0000 1.5 --- PyEditConfiguration.java 30 Mar 2004 01:03:37 -0000 1.6 *************** *** 15,18 **** --- 15,19 ---- import org.eclipse.jface.text.ITextDoubleClickStrategy; import org.eclipse.jface.text.TextAttribute; + import org.eclipse.jface.text.contentassist.IContentAssistant; import org.eclipse.jface.text.presentation.IPresentationReconciler; import org.eclipse.jface.text.presentation.PresentationReconciler; *************** *** 254,257 **** --- 255,261 ---- } + public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { + return new PyContentAssistant(); + } } \ No newline at end of file |
From: Aleksandar T. <at...@us...> - 2004-03-30 01:14:51
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/dictionary In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3594/src/org/python/pydev/editor/dictionary Log Message: Directory /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/dictionary added to the repository |
From: Aleksandar T. <at...@us...> - 2004-03-29 18:38:10
|
Update of /cvsroot/pydev/org.python.pydev/icons In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14504/icons Added Files: python.gif Log Message: Simple Python file icon --- NEW FILE: python.gif --- (This appears to be a binary file; contents omitted.) |
From: Aleksandar T. <at...@us...> - 2004-03-29 17:19:29
|
Update of /cvsroot/pydev/org.python.pydev.debug/docs In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32727/docs Added Files: jpydbg_doc_email.txt Log Message: jpydbg documentation --- NEW FILE: jpydbg_doc_email.txt --- Subject: Re: jpydbg protocol documentation? From: jean-yves MENGANT <jym...@if...> Date: Fri, 26 Mar 2004 12:16:56 +0100 To: Aleks Totic <a...@to...> Hi , Since I mainly use this protocol internally , I never take the time to document it , nevertheless I'll provide you with first basic semantics with jpydbg interaction and client side syntax right now : first jpydbg is started waiting for incoming commands on a socket (this is the same principle as the Java Debugging interface) the socket listener may either be the jpydbg client or jpydbg server itself depending on the parameters provided to the main jpydbg entry. (jpydbg server listening will usually implies security problems when remote debugging over a firewall) >From a gui debugging standpoint with jedit I have handled that inside a jpydbg configurable option pane. So I'll will also here provide you with entries to look at inside jpydbg.py in order to better understand the debugger's semantics : at that initial start state the jpydbg state is : active not debugging when a command is populated to jpydbg it is first handled by the jpydbg parseSingleCommand entry where you'll see the available list of command : CMD : execute a single python command and return the result back (OK meaning that the python command completed successfully) READSRC : Read source and populate it to client side (FOR REMOTE DEBUGGING) SETARGS : set debugging arguments DBG : enter DEBUG mode( Only once ) STOP : terminate jpydbg each command before is handle by a simple decicated method , the arguments requested by the above command are parsed by each of this method ; this parsing is straightforward and looking at the code should be sufficient there. Entering in DEBUG mode is a two step semantics : issue a SETARG command to populate parameters to jpydbg issue a DBG command to start debug mode. When jpydbg enters DEBUG mode no more COMMANDS may be handled only debugger's SUBCOMMAND will be accepted ; looking at parseSubCommand inside jpydbg provides you the list : CMD : execute a single python command using the current DEBUGGEE stack context (interesting to manipulate the debuggee data from a context console) READSRC : same as in non debugging context.(used mainly when a new module comes into debugging scope) NEXT : stop on next python instruction STEP : step into next instruction RUN : resume execution until the end of the PGM or the next Breakpoint BP+ : set a breakpoint BP- : unset a breakpoint STACK : populate back the python stack infos. LOCALS : populate the local variables infos GLOBALS : populate the global variables infos Debugging events are handled by overridding the basic debugging python module event handlers (bdb.py provided with the python package) populated events are : user_call : entering function call. <CALL ..... /CALL> xml message populated user_line : entering new user line <LINE .... /LINE> xml message populated user_return : leaving function <RETURN .... /RETURN> xml message populated user_exception : python exception handler <RETURN .... /RETURN> xml message populated stdout is captured and populated a STDOUT xml message to the client side where it's up to the client side implementer to display the information where he wants. events populate XML EVENT to the client side , those event may be captured and handled from there then in DEBUG mode jpydbg is always waiting for the next command over the wire , when not in RUN state ( RUN requested and no breakpoint reached yet) When in RUN state no interrupt capability is provided today. stdin : I did nothing special here for the moment, I did not even test it for now , but I suspect it should block the debugger server now (I'll look at that) hope it helps Let me know if you need complementary infos Jean-Yves On Thu, 25 Mar 2004 17:25:02 -0800, Aleks Totic wrote: >> Hi, >> after hacking some more, I understand your protocol a little better: >> STOP: exits the debugger >> READSRC <filename>: reads in a file >> SETARGS <arguments>: sets arguments before execution >> >> The mystery commands are still: >> CMD: what are its arguments, etc. For example CMD RUN gave me OK, >> but I could not see any evidence of my program running? It looks >> like the string is just compiled and executed straight. >> >> DBG: just like CMD. What are the arguments? >> >> Also, what happens with stdio when your program runs? It looks >> like you capture it, and send it back. How does stdin work? >> >> Aleks >> >> jean-yves MENGANT wrote: > >>>> Hi Alek , >>>> >>>> That's a cool idea , I was also on my side pondering on the way to >>>> integrate the jpydbg python debugging backend into Eclipse at some >>>> times since the debugger backend just send XML messages and is not >>>> neither JEdit nor Swing dependant it may be integrated in any IDE. >>>> >>>> So I am very happy to help on this : >>>> >>>> - All the Python stuff should be reusable as is for Eclipse : >>>> jpydbg.py : module is the debugger core just inheriting the >>>> standard bdb.py basic python debugging module. >>>> you may also use Inspector.py to generate an xml tree >>>> representation >>>> of a given python source to integrate into an IDE tree >>>> >>>> - From a Java standpoint I have tried to cleanly isolate both the >>>> swing and Jedit idiosynchrasis inside isolated packages , which >>>> are >>>> dealing with the JEdit / Swing gui sides. Since Eclipse will rely >>>> upon >>>> swt those packages won't be usefull. >>>> >>>> - org.jymc.jpydebug + org.jymc.jpydebug.utils : contains connector >>>> classes to the Python debugging environment and are fully usable >>>> for >>>> an Eclipse integration.(No Swing / No Jedit package references >>>> inside) >>>> >>>> - Inside the org.jymc.jpydebug.swing.ui , the ClientDebuggerShell >>>> class is a basic debugging GUI standalone tool which you can use >>>> to >>>> send and test the basic debugging commands to jpydebug.py. This >>>> one is >>>> also an example to start integrating the debugging API into >>>> eclipse. >>>> >>>> - The PythonDebugContainer class inside org.jymc.jpydebug.swing.ui >>>> contains the list of debugger's command as constant locating on >>>> the >>>> top of the class , and basic methods which implements them for a >>>> swing >>>> context. (No JEdit dependencies there ) >>>> >>>> - All debuggers return responses or events are in XML , and >>>> parsed by >>>> the JpyDebugXmlParser java class >>>> > >> >> ___[ Pub >> ]____________________________________________________________ >> Inscrivez-vous gratuitement sur Tandaime et gagnez un voyage à >> Venise >> www.Tandaime.com/index.php?origine=4 Tandaime, et la vie vous >> sourit ! _____________________________________________________________________ Envie de discuter en "live" avec vos amis ? Tilicharger MSN Messenger http://www.ifrance.com/_reloc/m la 1hre messagerie instantanie de France |
From: Aleksandar T. <at...@us...> - 2004-03-29 17:18:55
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32567/src/org/python/pydev/debug/model Added Files: PythonDebugTarget.java RemoteDebuggerCommand.java RemoteDebugger.java Log Message: Develpment of the debugger model --- NEW FILE: RemoteDebugger.java --- /* * Author: atotic * Created on Mar 23, 2004 * License: Common Public License v1.0 */ package org.python.pydev.debug.model; import java.io.*; import java.net.*; import java.util.ArrayList; import java.util.Iterator; /** * Network interface to the remote debugger. */ public class RemoteDebugger implements Runnable { // socket communication Socket socket; PrintWriter toServer; BufferedReader fromServer; InputStream sin; ArrayList commands = new ArrayList(); // command queue public RemoteDebugger(Socket socket) throws IOException { this.socket = socket; OutputStream sout = socket.getOutputStream(); sin = socket.getInputStream(); fromServer = new BufferedReader(new InputStreamReader(sin)); toServer = new PrintWriter(new OutputStreamWriter(sout)); } public void sendCommand(RemoteDebuggerCommand command) { synchronized(commands) { commands.add(command); } } private void execute1Command(RemoteDebuggerCommand c) { String sendThis = c.getXMLMessage(); toServer.write(sendThis); // TODO process result } /** * * @param commandList - a list of RemoteDebuggerCommand's to be executed */ private void executeCommands(ArrayList commandList) { Iterator iter = commandList.iterator(); while (!iter.hasNext()) { execute1Command((RemoteDebuggerCommand)iter.next()); } } /** * Execute commands in an infinite loop. */ public void run() { try { while (!socket.isClosed()) { if (!commands.isEmpty()) { ArrayList toExecute = new ArrayList(); synchronized(commands) { while (!commands.isEmpty()) toExecute.add(commands.remove(0)); } executeCommands(toExecute); } if (fromServer.ready()) { char[] cbuf = new char[2048]; int howMany = fromServer.read(cbuf); System.out.print(new String(cbuf, 0, howMany)); } Thread.sleep(100); } } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO handle this e.printStackTrace(); } } } --- NEW FILE: PythonDebugTarget.java --- /* * Author: atotic * Created on Mar 23, 2004 * License: Common Public License v1.0 */ package org.python.pydev.debug.model; import org.eclipse.core.resources.IMarkerDelta; import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.model.IBreakpoint; import org.eclipse.debug.core.model.IDebugTarget; import org.eclipse.debug.core.model.IMemoryBlock; import org.eclipse.debug.core.model.IProcess; import org.eclipse.debug.core.model.IThread; import org.python.pydev.debug.core.PydevDebugPlugin; /** * * TODO Comment this class * Make sure we fire the right org.eclipse.debug.core.DebugEvents */ public class PythonDebugTarget implements IDebugTarget { ILaunch launch; IProcess process; String name; RemoteDebugger debugger; public PythonDebugTarget(ILaunch launch, IProcess process, String name, RemoteDebugger debugger) { this.launch = launch; this.process = process; this.name = name; this.debugger = debugger; launch.addDebugTarget(this); } // From IDebugElement public String getModelIdentifier() { return PydevDebugPlugin.getPluginID(); } // From IDebugElement public IDebugTarget getDebugTarget() { return this; } // From IDebugElement public ILaunch getLaunch() { return launch; } public IProcess getProcess() { return process; } public String getName() throws DebugException { return name; } public IThread[] getThreads() throws DebugException { // TODO Auto-generated method stub return null; } public boolean hasThreads() throws DebugException { // TODO Auto-generated method stub return true; } public boolean supportsBreakpoint(IBreakpoint breakpoint) { // TODO Auto-generated method stub return false; } public boolean canTerminate() { // TODO NOW Auto-generated method stub return true; } public boolean isTerminated() { // TODO NOW Auto-generated method stub return false; } public void terminate() throws DebugException { // TODO Auto-generated method stub } public boolean canResume() { // TODO NOW Auto-generated method stub return false; } public boolean canSuspend() { // TODO NOW Auto-generated method stub return true; } public boolean isSuspended() { // TODO Auto-generated method stub return false; } public void resume() throws DebugException { // TODO Auto-generated method stub } public void suspend() throws DebugException { // TODO Auto-generated method stub } public void breakpointAdded(IBreakpoint breakpoint) { // TODO Auto-generated method stub } public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) { // TODO Auto-generated method stub } public void breakpointChanged(IBreakpoint breakpoint, IMarkerDelta delta) { // TODO Auto-generated method stub } public boolean canDisconnect() { // TODO NOW Auto-generated method stub return false; } public void disconnect() throws DebugException { // TODO Auto-generated method stub } public boolean isDisconnected() { // TODO NOW Auto-generated method stub return false; } public boolean supportsStorageRetrieval() { // TODO Auto-generated method stub return false; } public IMemoryBlock getMemoryBlock(long startAddress, long length) throws DebugException { // TODO Auto-generated method stub return null; } public Object getAdapter(Class adapter) { // TODO Auto-generated method stub if (adapter.equals(ILaunch.class)) return launch; else System.err.println("Need adapter " + adapter.toString()); return null; } } --- NEW FILE: RemoteDebuggerCommand.java --- /* * Author: atotic * Created on Mar 23, 2004 * License: Common Public License v1.0 */ package org.python.pydev.debug.model; /** * Interacts with jpydaemon.py. * * Knows how to create and interpret jpydaemon commands. * * jpydaemon commands: * * STOP: exits the debugger * CMD <command>: takes a command and executes it success: <JPY> <COMMAND cmd="CMD a=1" operation="a=1" result="OK" /></JPY> <JPY> <STDOUT content="1" /></JPY> <JPY> <STDOUT content="/EOL/" /></JPY> <JPY> <COMMAND cmd="CMD print a" operation="print a" result="OK" /></JPY> error: <JPY> <COMMAND cmd="CMD er!" operation="er!" result="Error on CMD" /></JPY> <JPY> <COMMANDDETAIL content="Traceback (most recent call last):" /></JPY> <JPY> <COMMANDDETAIL content=" File "D:\pydevspace2\org.python.pydev.debug\pysrc\jpydaemon.py", line 231, in dealWithCmd code = compile( arg ,"<string>" , cmdType)" /></JPY> <JPY> <COMMANDDETAIL content=" File "<string>", line 1" /></JPY> <JPY> <COMMANDDETAIL content=" er!" /></JPY> <JPY> <COMMANDDETAIL content=" ^" /></JPY> <JPY> <COMMANDDETAIL content="SyntaxError: unexpected EOF while parsing" /></JPY> * READSRC <filename>: reads in the whole file * SETARGS : sets arguments before we start execution <JPY> <COMMAND cmd="SETARGS -u -v" operation="-u -v" result="OK" /></JPY> * DBG: <JPY><COMMAND cmd="DBG test.py" /></JPY> <JPY> <LINE cmd="31" fn="<string>" lineno="1" name="?" line="" /></JPY> */ public class RemoteDebuggerCommand { public final static String VERSION = "JpyDbg 0.0.3" ; public final static int INACTIVE = 0 ; public final static int STARTING = 1 ; public final static int STARTED = 2 ; private final static String _ERROR_ = "ERROR:" ; private final static String _END_OF_LINE_ = "\n" ; private final static String _INACTIVE_TEXT_ = "inactive" ; private final static String _READY_TEXT_ = "ready" ; private final static String _STRING_ ="<string>" ; private final static String _EOL_ = "/EOL/" ; private final static String _OK_ = "OK" ; private final static String _COMMAND_ = "CMD " ; private final static String _BPSET_ = "BP+ " ; private final static String _BPCLEAR_ = "BP- " ; private final static String _DBG_ = "DBG " ; private final static String _SETARGS_ = "SETARGS " ; private final static String _READSRC_ = "READSRC " ; private final static String _NEXT_ = "NEXT " ; private final static String _SET_ = "set " ; private final static String _STEP_ = "STEP " ; private final static String _RUN_ = "RUN " ; private final static String _STOP_ = "STOP " ; private final static String _STACK_ = "STACK " ; private final static String _GLOBALS_ = "GLOBALS " ; private final static String _GLOBAL_ = "global" ; private final static String _EQUAL_ = "=" ; private final static String _SEMICOLON_= ";" ; private final static String _SILENT_ = "silent" ; private final static String _LOCALS_ = "LOCALS " ; private final static String _SPACE_ = " " ; String xmlMessage; public String getXMLMessage() { return xmlMessage; } } |
From: Aleksandar T. <at...@us...> - 2004-03-29 17:18:55
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32567/src/org/python/pydev/debug/ui/launching Modified Files: PythonRunActionDelegate.java LaunchShortcut.java package.html PythonLaunchConfigurationDelegate.java Added Files: PythonRunner.java SocketUtil.java PythonRunnerConfig.java Log Message: Develpment of the debugger model Index: package.html =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/package.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** package.html 8 Jan 2004 22:47:21 -0000 1.1 --- package.html 29 Mar 2004 17:07:25 -0000 1.2 *************** *** 1,9 **** <body> ! Launch configurations: integration with the org.eclipse.debug LaunchConfiguration framework (Debug menus etc). <p>PythonRunActionDelegate gets called by the popup menu. <p>It creates LaunchShortcut, which displays the "How do you want to launch" dialog. ! <p>Finally, LaunchShortcut dells PythonLaunchConfigurationDelegate to launch the file. ! <p>PythonLaunchConfigurationDelegate has the smarts about generating the right command ! line, etc. </body> \ No newline at end of file --- 1,13 ---- <body> ! This package handles processing after user presses "Run" button on launch until ! the program gets launched.<p> + <p>It integrates with the org.eclipse.debug LaunchConfiguration framework (Debug menus etc). <p>PythonRunActionDelegate gets called by the popup menu. <p>It creates LaunchShortcut, which displays the "How do you want to launch" dialog. ! <p>Finally, LaunchShortcut tells PythonLaunchConfigurationDelegate to launch the file. ! <p>PythonLaunchConfigurationDelegate passes all the parameters to PythonRunnerConfig, ! <p>and creates PythonRunner. ! <p>PythonRunner launches the executable and connects it to internal debug model. ! <p> </body> \ No newline at end of file --- NEW FILE: PythonRunner.java --- /* * Author: atotic * Created on Mar 18, 2004 * License: Common Public License v1.0 */ package org.python.pydev.debug.ui.launching; import java.io.IOException; import java.net.*; import java.util.HashMap; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; import org.eclipse.core.runtime.SubProgressMonitor; import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.model.IProcess; import org.python.pydev.debug.core.Constants; import org.python.pydev.debug.core.PydevDebugPlugin; import org.python.pydev.debug.model.PythonDebugTarget; import org.python.pydev.debug.model.RemoteDebugger; /** * Launches Python process, and connects it to Eclipse's debugger. * Waits for process to complete. * * Modelled after org.eclipse.jdt.internal.launching.StandardVMDebugger. */ public class PythonRunner { class DebugConnector implements Runnable { int port; int timeout; ServerSocket serverSocket; Socket socket; // what got accepted Exception e; boolean terminated; public DebugConnector(int port, int timeout) throws IOException { this.port = port; this.timeout = timeout; serverSocket = new ServerSocket(port); } Exception getException() { return e; } public Socket getSocket() { return socket; } public void stopListening() throws IOException { if (serverSocket != null) serverSocket.close(); terminated = true; } public void run() { try { serverSocket.setSoTimeout(timeout); socket = serverSocket.accept(); } catch (IOException e) { this.e = e; } } } /** * launches the debug configuration * @param config * @param launch * @param monitor * @throws CoreException */ public void run(PythonRunnerConfig config, ILaunch launch, IProgressMonitor monitor) throws CoreException, IOException { if (monitor == null) monitor = new NullProgressMonitor(); IProgressMonitor subMonitor = new SubProgressMonitor(monitor, 5); subMonitor.beginTask("Launching python", 1); // Launch & connect to the debugger subMonitor.subTask("Finding free socket..."); DebugConnector server = new DebugConnector(config.getDebugPort(), config.acceptTimeout); subMonitor.worked(1); subMonitor.subTask("Constructing command_line..."); String[] cmdLine = config.getCommandLine(); subMonitor.worked(1); Thread connectThread = new Thread(server, "Pydev debug listener"); connectThread.start(); Process p = DebugPlugin.exec(cmdLine, config.workingDirectory); if (p == null) // TODO this might not be an error throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Could not execute python process. Was it cancelled?", null)); // Register the process with the debug plugin subMonitor.worked(2); subMonitor.subTask("Starting debugger..."); HashMap processAttributes = new HashMap(); processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); processAttributes.put(IProcess.ATTR_CMDLINE, config.getCommandLineAsString()); IProcess process = DebugPlugin.newProcess(launch,p, config.file.lastSegment(), processAttributes); // Launch the debug listener on a thread, and wait until it completes while (connectThread.isAlive()) { if (monitor.isCanceled()) { server.stopListening(); p.destroy(); return; } try { p.exitValue(); // throws exception if process has terminated // process has terminated - stop waiting for a connection try { server.stopListening(); } catch (IOException e) { // expected } checkErrorMessage(process); } catch (IllegalThreadStateException e) { // expected while process is alive } try { Thread.sleep(100); } catch (InterruptedException e) { } } Exception ex = server.getException(); if (ex != null) { process.terminate(); p.destroy(); String message = "Unexpected error setting up the debugger"; if (ex instanceof SocketTimeoutException) message = "Timed out after " + Float.toString(config.acceptTimeout/1000) + " seconds while waiting for python script to connect."; throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, message, ex)); } // hook up debug model, and we are off & running RemoteDebugger debugger = new RemoteDebugger(server.getSocket()); PythonDebugTarget t = new PythonDebugTarget(launch, process, config.getRunningName(), debugger); Thread dt = new Thread(debugger, "Pydev remote debug connection"); dt.start(); } protected void checkErrorMessage(IProcess process) throws CoreException { String errorMessage= process.getStreamsProxy().getErrorStreamMonitor().getContents(); if (errorMessage.length() != 0) // TODO not sure if this is really an error throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Something got printed in the error stream", null)); } } Index: PythonRunActionDelegate.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/PythonRunActionDelegate.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonRunActionDelegate.java 8 Jan 2004 22:47:21 -0000 1.1 --- PythonRunActionDelegate.java 29 Mar 2004 17:07:25 -0000 1.2 *************** *** 18,23 **** * Implements "Run Python..." extension for org.eclipse.ui.popupMenus. * ! * <p>Lots of functionality borrowed from AntRunActionDelegate. ! * <p>Collects all the files, then passes everything off to LaunchShortcut * * @see org.python.pydev.debug.ui.launching.LaunchShortcut --- 18,22 ---- * Implements "Run Python..." extension for org.eclipse.ui.popupMenus. * ! * <p>Passes off the selected file to {@link org.python.pydev.debug.ui.launching.LaunchShortcut LaunchShortcut}. * * @see org.python.pydev.debug.ui.launching.LaunchShortcut Index: PythonLaunchConfigurationDelegate.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/PythonLaunchConfigurationDelegate.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PythonLaunchConfigurationDelegate.java 16 Jan 2004 23:54:30 -0000 1.3 --- PythonLaunchConfigurationDelegate.java 29 Mar 2004 17:07:25 -0000 1.4 *************** *** 6,40 **** package org.python.pydev.debug.ui.launching; ! import java.io.File; ! import java.text.MessageFormat; ! import java.util.HashMap; ! import java.util.Map; - import org.python.pydev.debug.core.Constants; - import org.python.pydev.debug.ui.InterpreterEditor; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; - import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; - import org.eclipse.debug.core.ILaunchManager; - import org.eclipse.debug.core.ILaunchConfigurationType; - import org.eclipse.debug.core.DebugPlugin; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; - import org.eclipse.debug.core.model.IProcess; - // E3 import org.eclipse.debug.ui.CommonTab; - // E3 import org.eclipse.debug.ui.RefreshTab; import org.eclipse.ui.IWindowListener; - import org.eclipse.ui.IWorkbenchWindow; - import org.eclipse.ui.PlatformUI; import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; ! import org.eclipse.ui.externaltools.internal.model.IExternalToolConstants; ! import org.eclipse.ui.externaltools.internal.program.launchConfigurations.BackgroundResourceRefresher; ! import org.eclipse.ui.externaltools.internal.program.launchConfigurations.ExternalToolsProgramMessages; import org.eclipse.ui.externaltools.internal.variable.ExpandVariableContext; ! ! import org.eclipse.jface.dialogs.MessageDialog; /** --- 6,24 ---- package org.python.pydev.debug.ui.launching; ! import java.io.IOException; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IProgressMonitor; import org.eclipse.core.runtime.IStatus; + import org.eclipse.core.runtime.NullProgressMonitor; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunch; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.model.ILaunchConfigurationDelegate; import org.eclipse.ui.IWindowListener; import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; ! // import org.eclipse.ui.externaltools.internal.program.launchConfigurations.BackgroundResourceRefresher; import org.eclipse.ui.externaltools.internal.variable.ExpandVariableContext; ! import org.python.pydev.debug.core.PydevDebugPlugin; /** *************** *** 50,172 **** { private static IWindowListener windowListener; - - /** - * A window listener that warns the user about any running programs when - * the workbench closes. Programs are killed when the VM exits. - */ - private class ProgramLaunchWindowListener implements IWindowListener { - public void windowActivated(IWorkbenchWindow window) { - } - public void windowDeactivated(IWorkbenchWindow window) { - } - public void windowClosed(IWorkbenchWindow window) { - IWorkbenchWindow windows[]= PlatformUI.getWorkbench().getWorkbenchWindows(); - if (windows.length > 1) { - // There are more windows still open. - return; - } - ILaunchManager manager= DebugPlugin.getDefault().getLaunchManager(); - ILaunchConfigurationType programType= manager.getLaunchConfigurationType(IExternalToolConstants.ID_PROGRAM_LAUNCH_CONFIGURATION_TYPE); - if (programType == null) { - return; - } - ILaunch launches[]= manager.getLaunches(); - ILaunchConfigurationType configType; - ILaunchConfiguration config; - for (int i = 0; i < launches.length; i++) { - try { - config= launches[i].getLaunchConfiguration(); - if (config == null) { - continue; - } - configType= config.getType(); - } catch (CoreException e) { - continue; - } - if (configType.equals(programType)) { - if (!launches[i].isTerminated()) { - MessageDialog.openWarning(window.getShell(), ExternalToolsProgramMessages.getString("ProgramLaunchDelegate.Workbench_Closing_1"), ExternalToolsProgramMessages.getString("ProgramLaunchDelegate.The_workbench_is_exiting")); //$NON-NLS-1$ //$NON-NLS-2$ - break; - } - } - } - } - public void windowOpened(IWorkbenchWindow window) { - } - } ! /* (non-Javadoc) ! * */ public void launch(ILaunchConfiguration conf, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { ! if (monitor.isCanceled()) ! return; ! ExpandVariableContext resourceContext = ExternalToolsUtil.getVariableContext(); ! // Get the basic parameters ! IPath location = ExternalToolsUtil.getLocation(conf, resourceContext); ! IPath workingDirectory = ExternalToolsUtil.getWorkingDirectory(conf, resourceContext); ! String interpreter = conf.getAttribute(Constants.ATTR_INTERPRETER, "python"); ! String[] arguments = ExternalToolsUtil.getArguments(conf, resourceContext); ! ! if (monitor.isCanceled()) ! return; ! ! // Set up the command-line arguments ! int cmdLineLength = 3; ! if (arguments != null) ! cmdLineLength += arguments.length; ! ! String[] cmdLine = new String[cmdLineLength]; ! cmdLine[0] = interpreter; ! // Next option is for unbuffered stdout, otherwise Eclipse will not see any output until done ! cmdLine[1] = InterpreterEditor.isJython(interpreter) ? "-i" : "-u"; ! cmdLine[2] = location.toOSString(); ! if (arguments != null) ! System.arraycopy(arguments, 0, cmdLine, 3, arguments.length); ! ! File workingDir = workingDirectory == null ? null : workingDirectory.toFile(); ! ! // E3 String[] envp = DebugPlugin.getDefault().getLaunchManager().getEnvironment(conf); ! ! if (monitor.isCanceled()) ! return; ! ! if (windowListener == null) { ! windowListener= new ProgramLaunchWindowListener(); ! PlatformUI.getWorkbench().addWindowListener(windowListener); ! } ! ! // Execute the process ! // E3 Process p = DebugPlugin.exec(cmdLine, workingDir, envp); ! //DebugPlugin.newProcess(launch, ) ! Process p = DebugPlugin.exec(cmdLine, workingDir); ! IProcess process = null; ! ! // add process type to process attributes ! Map processAttributes = new HashMap(); ! processAttributes.put(IProcess.ATTR_PROCESS_TYPE, Constants.PROCESS_TYPE); ! ! // org.eclipse.debug.internal.ui.views.console.ConsoleDocumentPartitioner.connect() attaches streams ! if (p != null) { ! monitor.beginTask(MessageFormat.format(ExternalToolsProgramMessages.getString("ProgramLaunchDelegate.3"), new String[] {conf.getName()}), IProgressMonitor.UNKNOWN); //$NON-NLS-1$ ! process = DebugPlugin.newProcess(launch, p, location.toOSString(), processAttributes); ! if (process == null) { ! p.destroy(); ! // E3 throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, IExternalToolConstants.ERR_INTERNAL_ERROR, ExternalToolsProgramMessages.getString("ProgramLaunchDelegate.4"), null)); //$NON-NLS-1$ ! throw new CoreException(new Status(IStatus.ERROR, IExternalToolConstants.PLUGIN_ID, -1, ExternalToolsProgramMessages.getString("ProgramLaunchDelegate.4"), null)); //$NON-NLS-1$ ! } } ! process.setAttribute(IProcess.ATTR_CMDLINE, generateCommandLine(cmdLine)); ! if (ExternalToolsUtil.isBackground(conf)) { ! // refresh resources after process finishes ! if (ExternalToolsUtil.getRefreshScope(conf) != null) { ! BackgroundResourceRefresher refresher = new BackgroundResourceRefresher(conf, process, resourceContext); ! refresher.startBackgroundRefresh(); ! } ! // E3 if (CommonTab.isLaunchInBackground(conf)) { // E3 // refresh resources after process finishes --- 34,72 ---- { private static IWindowListener windowListener; ! /** ! * Launches the python process. ! * ! * Modelled after Ant & Java runners ! * see WorkbenchLaunchConfigurationDelegate::launch */ public void launch(ILaunchConfiguration conf, String mode, ILaunch launch, IProgressMonitor monitor) throws CoreException { ! if (monitor == null) ! monitor = new NullProgressMonitor(); ! monitor.beginTask("Preparing configuration", 3); ! ExpandVariableContext resourceContext = ExternalToolsUtil.getVariableContext(); + PythonRunnerConfig runConfig = new PythonRunnerConfig(conf, mode, resourceContext); + PythonRunner runner = new PythonRunner(); ! monitor.worked(1); ! try { ! runner.run(runConfig, launch, monitor); ! } catch (IOException e) { ! e.printStackTrace(); ! throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Unexpected IO Exception in Pydev debugger", null)); } ! // ClassLoader save = cur.getContextClassLoader(); ! // cur.setContextClassLoader(getClass().getClassLoader()); ! // try { ! // PythonDebugClient test = new PythonDebugClient(); ! // test.init("localhost", 29000, -1, null, null, null); // do whatever needs the contextClassLoader ! // } catch (PythonDebugException e1) { ! // DebugPlugin.log(e1); ! // } finally { ! // cur.setContextClassLoader(save); ! // } // E3 if (CommonTab.isLaunchInBackground(conf)) { // E3 // refresh resources after process finishes *************** *** 175,223 **** // E3 refresher.startBackgroundRefresh(); // E3 } ! } else { ! // wait for process to exit ! while (!process.isTerminated()) { ! try { ! if (monitor.isCanceled()) { ! process.terminate(); ! break; ! } ! Thread.sleep(50); ! } catch (InterruptedException e) { ! } ! } ! ! // refresh resources // E3 RefreshTab.refreshResources(conf, monitor); - } - } - - private String generateCommandLine(String[] commandLine) { - if (commandLine.length < 1) - return ""; //$NON-NLS-1$ - StringBuffer buf= new StringBuffer(); - for (int i= 0; i < commandLine.length; i++) { - buf.append(' '); - char[] characters= commandLine[i].toCharArray(); - StringBuffer command= new StringBuffer(); - boolean containsSpace= false; - for (int j = 0; j < characters.length; j++) { - char character= characters[j]; - if (character == '\"') { - command.append('\\'); - } else if (character == ' ') { - containsSpace = true; - } - command.append(character); - } - if (containsSpace) { - buf.append('\"'); - buf.append(command); - buf.append('\"'); - } else { - buf.append(command); - } - } - return buf.toString(); } } --- 75,80 ---- // E3 refresher.startBackgroundRefresh(); // E3 } ! // refresh resources // E3 RefreshTab.refreshResources(conf, monitor); } } Index: LaunchShortcut.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/LaunchShortcut.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** LaunchShortcut.java 10 Jan 2004 03:13:18 -0000 1.2 --- LaunchShortcut.java 29 Mar 2004 17:07:25 -0000 1.3 *************** *** 92,96 **** status = new Status(IStatus.ERROR, "org.python.pydev.debug", 0, message, throwable); } ! ErrorDialog.openError(DebugPlugin.getActiveWorkbenchWindow().getShell(), "Python pydev.debug error", "Python launch failed", status); } --- 92,96 ---- status = new Status(IStatus.ERROR, "org.python.pydev.debug", 0, message, throwable); } ! ErrorDialog.openError(PydevDebugPlugin.getActiveWorkbenchWindow().getShell(), "Python pydev.debug error", "Python launch failed", status); } *************** *** 154,158 **** String baseDirectory = file.getRawLocation().removeLastSegments(1).toString(); String arguments = ""; ! String interpreter = DebugPlugin.getDefault().getInterpreters()[0]; workingCopy.setAttribute(Constants.ATTR_LOCATION,location); workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY,baseDirectory); --- 154,158 ---- String baseDirectory = file.getRawLocation().removeLastSegments(1).toString(); String arguments = ""; ! String interpreter = PydevDebugPlugin.getDefault().getInterpreters()[0]; workingCopy.setAttribute(Constants.ATTR_LOCATION,location); workingCopy.setAttribute(Constants.ATTR_WORKING_DIRECTORY,baseDirectory); *************** *** 223,227 **** IStatus status = new Status(IStatus.INFO, Constants.PLUGIN_ID, 0, "Hmm", null); //$NON-NLS-1$ String groupID = mode.equals("run") ? Constants.PYTHON_RUN_LAUNCH_GROUP : Constants.PYTHON_DEBUG_LAUNCH_GROUP; ! DebugUITools.openLaunchConfigurationDialog(DebugPlugin.getActiveWorkbenchWindow().getShell(), conf, groupID, null); } else { DebugUITools.launch(conf, mode); --- 223,227 ---- IStatus status = new Status(IStatus.INFO, Constants.PLUGIN_ID, 0, "Hmm", null); //$NON-NLS-1$ String groupID = mode.equals("run") ? Constants.PYTHON_RUN_LAUNCH_GROUP : Constants.PYTHON_DEBUG_LAUNCH_GROUP; ! DebugUITools.openLaunchConfigurationDialog(PydevDebugPlugin.getActiveWorkbenchWindow().getShell(), conf, groupID, null); } else { DebugUITools.launch(conf, mode); --- NEW FILE: SocketUtil.java --- /* * Author: atotic * Created on Mar 22, 2004 * License: Common Public License v1.0 */ package org.python.pydev.debug.ui.launching; import java.io.IOException; import java.net.ConnectException; import java.net.Socket; import java.util.Random; /** * Utility class to find a port to debug on. * * Straight copy of package org.eclipse.jdt.launching.SocketUtil. * I just could not figure out how to import that one. * No dependencies kept it on the classpath reliably */ public class SocketUtil { private static final Random fgRandom= new Random(System.currentTimeMillis()); /** * Returns a free port number on the specified host within the given range, * or -1 if none found. * * @param host name or IP addres of host on which to find a free port * @param searchFrom the port number from which to start searching * @param searchTo the port number at which to stop searching * @return a free port in the specified range, or -1 of none found */ public static int findUnusedLocalPort(String host, int searchFrom, int searchTo) { for (int i= 0; i < 10; i++) { Socket s= null; int port= getRandomPort(searchFrom, searchTo); try { s= new Socket(host, port); } catch (ConnectException e) { return port; } catch (IOException e) { } finally { if (s != null) { try { s.close(); } catch (IOException ioe) { } } } } return -1; } private static int getRandomPort(int low, int high) { return (int)(fgRandom.nextFloat() * (high-low)) + low; } } --- NEW FILE: PythonRunnerConfig.java --- /* * Author: atotic * Created on Mar 18, 2004 * License: Common Public License v1.0 */ package org.python.pydev.debug.ui.launching; import java.io.File; import java.net.URL; import java.util.Vector; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Status; import org.eclipse.debug.core.ILaunchConfiguration; import org.eclipse.debug.core.ILaunchManager; import org.eclipse.ui.externaltools.internal.launchConfigurations.ExternalToolsUtil; import org.eclipse.ui.externaltools.internal.variable.ExpandVariableContext; import org.python.pydev.debug.core.Constants; import org.python.pydev.debug.core.PydevDebugPlugin; import org.python.pydev.debug.ui.InterpreterEditor; /** * Holds configuration for PythonRunner. * * It knows how to extract proper launching arguments from disparate sources. * Has many launch utility functions (getCommandLine & friends). */ public class PythonRunnerConfig { public IPath file; public String interpreter; public String[] arguments; public File workingDirectory; // debugging public boolean isDebug; private int debugPort = 0; // use getDebugPort public String debugScript; public int acceptTimeout = 5000; // miliseconds /** * Sets defaults. */ public PythonRunnerConfig(ILaunchConfiguration conf, String mode, ExpandVariableContext resourceContext) throws CoreException { isDebug = mode.equals(ILaunchManager.DEBUG_MODE); file = ExternalToolsUtil.getLocation(conf, resourceContext); interpreter = conf.getAttribute(Constants.ATTR_INTERPRETER, "python"); arguments = ExternalToolsUtil.getArguments(conf, resourceContext); IPath workingPath = ExternalToolsUtil.getWorkingDirectory(conf, resourceContext); workingDirectory = workingPath == null ? null : workingPath.toFile(); if (isDebug) { debugScript = getDebugScript(); // TODO debug socket port? } // E3 String[] envp = DebugPlugin.getDefault().getLaunchManager().getEnvironment(conf); } public int getDebugPort() throws CoreException { if (debugPort == 0) { debugPort= SocketUtil.findUnusedLocalPort("", 5000, 15000); //$NON-NLS-1$ if (debugPort == -1) throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Could not find a free socket for debugger", null)); } return debugPort; } public String getRunningName() { return file.lastSegment(); } /** * @throws CoreException if arguments are inconsistent */ public void verify() throws CoreException { if (file == null || interpreter == null) throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Invalid PythonRunnerConfig",null)); if (isDebug && ( acceptTimeout < 0 || debugPort < 0 || debugScript == null)) throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Invalid PythonRunnerConfig",null)); } /** * gets location of jpydaemon.py */ public static String getDebugScript() throws CoreException { IPath relative = new Path("pysrc").addTrailingSeparator().append("jpydaemon.py"); // IPath relative = new Path("pysrc").addTrailingSeparator().append("rpdb.py"); URL location = org.python.pydev.debug.core.PydevDebugPlugin.getDefault().find(relative); if (location == null) throw new CoreException(new Status(IStatus.ERROR, PydevDebugPlugin.getPluginID(), 0, "Internal pydev error: Cannot find jpydaemon.py", null)); return location.getPath(); } /** * Create a command line for launching. * @return command line ready to be exec'd */ public String[] getCommandLine() { Vector cmdArgs = new Vector(10); cmdArgs.add(interpreter); // Next option is for unbuffered stdout, otherwise Eclipse will not see any output until done cmdArgs.add(InterpreterEditor.isJython(interpreter) ? "-i" : "-u"); if (isDebug) { // rpdb cmdArgs.add(debugScript); // cmdArgs.add("-c"); // cmdArgs.add("-p"+Integer.toString(debugPort)); cmdArgs.add(debugScript); cmdArgs.add("localhost"); cmdArgs.add(Integer.toString(debugPort)); } cmdArgs.add(file.toOSString()); for (int i=0; arguments != null && i<arguments.length; i++) cmdArgs.add(arguments[i]); String[] retVal = new String[cmdArgs.size()]; cmdArgs.toArray(retVal); return retVal; } public String getCommandLineAsString() { String[] args = getCommandLine(); StringBuffer s = new StringBuffer(); for (int i=0; i< args.length; i++) { s.append(args[i]); s.append(" "); } return s.toString(); } } |
From: Aleksandar T. <at...@us...> - 2004-03-29 17:18:54
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32567/src/org/python/pydev/debug/core Added Files: PydevDebugPlugin.java Removed Files: DebugPlugin.java Log Message: Develpment of the debugger model --- NEW FILE: PydevDebugPlugin.java --- package org.python.pydev.debug.core; import org.eclipse.ui.IWorkbenchWindow; import org.eclipse.ui.plugin.*; import org.eclipse.core.runtime.*; import org.eclipse.core.resources.*; import org.python.pydev.debug.ui.InterpreterEditor; /** * The main plugin for Python Debugger. * * Standard plugin functionality: preferences, logging, some utility functions */ public class PydevDebugPlugin extends AbstractUIPlugin { //The shared instance. private static PydevDebugPlugin plugin; public PydevDebugPlugin(IPluginDescriptor descriptor) { super(descriptor); plugin = this; } public static PydevDebugPlugin getDefault() { return plugin; } public static String getPluginID() { return getDefault().getDescriptor().getUniqueIdentifier(); } public static IWorkspace getWorkspace() { return ResourcesPlugin.getWorkspace(); } /** * Returns the active workbench window or <code>null</code> if none */ public static IWorkbenchWindow getActiveWorkbenchWindow() { return getDefault().getWorkbench().getActiveWorkbenchWindow(); } public String[] getInterpreters() { String interpreters = getPreferenceStore().getString(Constants.PREF_INTERPRETER_PATH); return InterpreterEditor.getInterpreterList(interpreters); } /** * @param errorLevel IStatus.[OK|INFO|WARNING|ERROR] */ public static void log(int errorLevel, String message, Throwable e) { Status s = new Status(errorLevel, getPluginID(), errorLevel, message, e); getDefault().getLog().log(s); } } --- DebugPlugin.java DELETED --- |
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32567/src/org/python/pydev/debug/ui Modified Files: DebugPrefsPage.java PythonMainTab.java InterpreterEditor.java PythonConsoleLineTracker.java StreamConsumer.java Added Files: package.html Log Message: Develpment of the debugger model --- NEW FILE: package.html --- <body> Debugger user interface: preferences, console line tracker,launcher tabs. </body> Index: DebugPrefsPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/DebugPrefsPage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DebugPrefsPage.java 8 Jan 2004 22:47:20 -0000 1.1 --- DebugPrefsPage.java 29 Mar 2004 17:07:25 -0000 1.2 *************** *** 12,16 **** import org.eclipse.ui.IWorkbenchPreferencePage; import org.python.pydev.debug.core.Constants; ! import org.python.pydev.debug.core.DebugPlugin; /** --- 12,16 ---- import org.eclipse.ui.IWorkbenchPreferencePage; import org.python.pydev.debug.core.Constants; ! import org.python.pydev.debug.core.PydevDebugPlugin; /** *************** *** 28,32 **** public DebugPrefsPage() { super(GRID); ! setPreferenceStore(DebugPlugin.getDefault().getPreferenceStore()); } --- 28,32 ---- public DebugPrefsPage() { super(GRID); ! setPreferenceStore(PydevDebugPlugin.getDefault().getPreferenceStore()); } Index: InterpreterEditor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/InterpreterEditor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** InterpreterEditor.java 16 Jan 2004 23:54:31 -0000 1.3 --- InterpreterEditor.java 29 Mar 2004 17:07:25 -0000 1.4 *************** *** 16,20 **** import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.FileDialog; ! import org.python.pydev.debug.core.DebugPlugin; /** --- 16,20 ---- import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.FileDialog; ! import org.python.pydev.debug.core.PydevDebugPlugin; /** *************** *** 86,90 **** public static String[] getInterpreterList(String stringList) { if (stringList == null) { ! DebugPlugin.log(IStatus.WARNING, "No python interpreters specified", (Throwable)null); return new String[] {"python"}; } --- 86,90 ---- public static String[] getInterpreterList(String stringList) { if (stringList == null) { ! PydevDebugPlugin.log(IStatus.WARNING, "No python interpreters specified", (Throwable)null); return new String[] {"python"}; } Index: StreamConsumer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/StreamConsumer.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** StreamConsumer.java 8 Jan 2004 22:47:20 -0000 1.1 --- StreamConsumer.java 29 Mar 2004 17:07:25 -0000 1.2 *************** *** 3,7 **** import org.eclipse.core.runtime.IStatus; ! import org.python.pydev.debug.core.DebugPlugin; --- 3,7 ---- import org.eclipse.core.runtime.IStatus; ! import org.python.pydev.debug.core.PydevDebugPlugin; *************** *** 28,32 **** bReader.close(); } catch (IOException ioe) { ! DebugPlugin.log(IStatus.ERROR, "Error in stream consumer", ioe); } } --- 28,32 ---- bReader.close(); } catch (IOException ioe) { ! PydevDebugPlugin.log(IStatus.ERROR, "Error in stream consumer", ioe); } } Index: PythonConsoleLineTracker.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/PythonConsoleLineTracker.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PythonConsoleLineTracker.java 8 Jan 2004 22:47:20 -0000 1.1 --- PythonConsoleLineTracker.java 29 Mar 2004 17:07:25 -0000 1.2 *************** *** 18,22 **** import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IRegion; ! import org.python.pydev.debug.core.DebugPlugin; /** --- 18,22 ---- import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IRegion; ! import org.python.pydev.debug.core.PydevDebugPlugin; /** *************** *** 73,77 **** } } catch (BadLocationException e) { ! DebugPlugin.log(IStatus.ERROR, "unexpected error", e); } } --- 73,77 ---- } } catch (BadLocationException e) { ! PydevDebugPlugin.log(IStatus.ERROR, "unexpected error", e); } } Index: PythonMainTab.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/PythonMainTab.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PythonMainTab.java 10 Jan 2004 03:13:18 -0000 1.3 --- PythonMainTab.java 29 Mar 2004 17:07:25 -0000 1.4 *************** *** 106,110 **** interpreterField = new Combo (comp, SWT.DROP_DOWN); ! interpreterField.setItems (DebugPlugin.getDefault().getInterpreters()); interpreterField.select(0); data = new GridData (); --- 106,110 ---- interpreterField = new Combo (comp, SWT.DROP_DOWN); ! interpreterField.setItems (PydevDebugPlugin.getDefault().getInterpreters()); interpreterField.select(0); data = new GridData (); *************** *** 154,158 **** try { URL url = new URL( ! DebugPlugin.getDefault().getDescriptor().getInstallURL(), Constants.MAIN_ICON); desc = ImageDescriptor.createFromURL(url); --- 154,158 ---- try { URL url = new URL( ! PydevDebugPlugin.getDefault().getDescriptor().getInstallURL(), Constants.MAIN_ICON); desc = ImageDescriptor.createFromURL(url); *************** *** 211,215 **** selectThis = i; if (selectThis == -1) { ! DebugPlugin.log(IStatus.INFO, "Obsolete interpreter selected", null); interpreterField.add(interpreter); interpreterField.select(interpreterField.getItemCount()-1); --- 211,215 ---- selectThis = i; if (selectThis == -1) { ! PydevDebugPlugin.log(IStatus.INFO, "Obsolete interpreter selected", null); interpreterField.add(interpreter); interpreterField.select(interpreterField.getItemCount()-1); |
From: Aleksandar T. <at...@us...> - 2004-03-29 17:18:40
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32526/src/org/python/pydev/debug/model Log Message: Directory /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model added to the repository |
From: Aleksandar T. <at...@us...> - 2004-03-29 17:17:19
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32273/pysrc Added Files: jpydaemon.py inspector.py Log Message: jpydbg v0.5 --- NEW FILE: jpydaemon.py --- #! /usr/bin/env python """ this daemon may be used by 'external' python sollicitors interfaces""" import sys import bdb import socket import string import traceback import os import inspect import types from inspector import * HOST = '' PORT = 29000 # default listening port OK = "OK" COMMAND = 0 SET_BP = 2 DEBUG = 31 STEP = 4 NEXT = 5 RUN = 6 FREEZE = 7 # remain on current line CLEAR_BP = 8 STACK = 9 QUIT = 10 LOCALS = 11 GLOBALS = 12 SETARGS = 13 READSRC = 14 UNKNOWN = -1 # instanciate a jpyutil object utils = jpyutils() class JPyDbg(bdb.Bdb) : def __init__(self): bdb.Bdb.__init__(self) # store debugger script name to avoid debugging it's own frame self.debuggerFName = os.path.normcase(sys.argv[0]) print self.debuggerFName # client debugger connection self.connection = None # frame debuggee contexts self.globalContext = None self.localContext = None self.verbose = 0 # hide is used to prevent debug inside debugger self.hide = 0 # debugger active information self.debuggee = None self.cmd = UNKNOWN # net buffer content self.lastBuffer = "" # EXCEPTION raised flag self.exceptionRaised = 0 # debuggee current 'command line arguments' self.debuggeeArgs = None # last executed line exception or None self.lastLineException = None def populateToClient( self , bufferList ) : buffer = '<JPY>' for element in bufferList: buffer = buffer + ' ' + str(element) buffer = buffer + '</JPY>\n' #print buffer self.connection.send( buffer ) # bdb overwitten to capture call debug event def user_call(self, frame, args): name = frame.f_code.co_name if not name: name = '???' fn = self.canonic(frame.f_code.co_filename) if not fn: fn = '???' # discard debugger frame if fn == self.debuggerFName or self.hide: self.hide = self.hide + 1 if self.hide: return None self.populateToClient( [ '<CALL', 'cmd="'+str(self.cmd)+'"' , 'fn="'+ utils.removeForXml(fn) +'"' , 'name="'+name+'"', 'args="'+str(args)+'"' , '/>' ] ) def checkDbgAction( self , frame ): if ( self.cmd == DEBUG ) or ( self.cmd == STEP ) or ( self.cmd == NEXT ) or ( self.cmd == RUN ): # DEBUG STARTING event # Debuggin starts stop on first line wait for NEXT , STEP , RUN , STOP .... while ( self.parseSubCommand( self.receiveCommand() , frame ) == FREEZE ): pass # bdb overwitten to capture line debug event def user_line(self, frame): if self.hide: return None import linecache name = frame.f_code.co_name if not name: name = '???' fn = self.canonic(frame.f_code.co_filename) if not fn: fn = '???' # populate info to client side line = linecache.getline(fn, frame.f_lineno) self.populateToClient( [ '<LINE', 'cmd="'+str(self.cmd)+'"' , 'fn="'+ utils.removeForXml(fn)+'"' , 'lineno="'+str(frame.f_lineno)+'"' , 'name="' + name + '"' , 'line="' + utils.removeForXml(line.strip())+'"', '/>'] ) # what's on next self.checkDbgAction( frame ) # bdb overwitten to capture return debug event def user_return(self, frame, retval): fn = self.canonic(frame.f_code.co_filename) if not fn: fn = '???' if self.hide: self.hide = self.hide - 1 return None self.populateToClient( [ '<RETURN', 'cmd="'+str(self.cmd)+'"' , 'fn="'+utils.removeForXml(fn)+'"' , 'retval="'+str(retval)+'"' , '/>'] ) def send_client_exception( self , cmd , content ): self.populateToClient( ['<EXCEPTION', 'cmd="'+cmd+'"' , 'content="'+content+'"' , '/>'] ) def populate_exception( self , exc_stuff): if ( self.exceptionRaised == 0 ): # exception not yet processed extype = exc_stuff[0] details = exc_stuff[1] ex = exc_stuff # Deal With SystemExit in specific way to reflect debuggee's return if issubclass( extype , SystemExit): content = 'System Exit REQUESTED BY DEBUGGEE with code =' + ex.code elif issubclass(extype, SyntaxError): content = str(details) error = details[0] compd = details[1] content = 'SOURCE:SYNTAXERROR:"'+str(compd[0])+'":('+str(compd[1])+','+str(compd[2])+')'+':'+error elif issubclass(extype,NameError): content = 'SOURCE:NAMEERROR:'+str(details) elif issubclass(extype,ImportError): content = 'SOURCE::IMPORTERROR:'+str(details) else: content = str(details) # keep track of received exception self.lastLineException = ['<EXCEPTION', 'cmd="'+str(self.cmd)+'"' , 'content="'+utils.removeForXml(content)+'"' , '/>'] self.send_client_exception( str(self.cmd) , utils.removeForXml(content) ) self.exceptionRaised = 1 # set ExceptionFlag On # bdb overwitten to capture Exception events def user_exception(self, frame, exc_stuff): # capture next / step go ahead when exception is around # current steatement while steping if self.cmd==NEXT or self.cmd==STEP: # self.populate_exception( exc_stuff ) self.set_step() sys.settrace(self.trace_dispatch) else: self.populate_exception( exc_stuff ) self.set_continue() def parsedReturned( self , command = 'COMMAND' , argument = None , message = None , details = None ): parsedCommand = [] parsedCommand.append(command) parsedCommand.append(argument) parsedCommand.append(message) parsedCommand.append(details) return parsedCommand # acting as stdio => redirect to client side def write( self , toPrint ): # transform eol pattern if ( toPrint == "\n" ): toPrint = "/EOL/" self.populateToClient( ['<STDOUT' , 'content="'+utils.removeForXml(toPrint)+'"' , '/>' ] ) def buildEvalArguments( self , arg ): posEqual = arg.find('=') if posEqual == -1: return None,None # Syntax error on provided expession couple return arg[:posEqual].strip() , arg[posEqual+1:].strip() # # parse & execute buffer command # def dealWithCmd( self , verb , arg , myGlobals = globals() , myLocals = locals() ): cmd = COMMAND msgOK = OK cmdType = "single" silent , silentarg = self.commandSyntax( arg ) if silent == 'silent': arg = silentarg # consume # "exec" is the magic way which makes # used debuggees dictionaries updatable while # stopped in debugging hooks cmdType = "exec" msgOK = silent # we use ';' as a python multiline syntaxic separator arg = string.replace(arg,';','\n') # execute requested dynamic command on this side try: oldstd = sys.stdout sys.stdout=self code = compile( arg ,"<string>" , cmdType) exec code in myGlobals , myLocals sys.stdout=oldstd return utils.parsedReturned( argument = arg , message = msgOK ) except: try: return utils.populateCMDException(arg,oldstd) except: tb , exctype , value = sys.exc_info() excTrace = traceback.format_exception( tb , exctype , value ) print excTrace # # build an xml CDATA structure # usage of plus is for jpysource.py xml CDATA encapsulation of itself # def CDATAForXml( self , data ): return '<'+'![CDATA['+ data + ']'+']>' # # parse & execute buffer command # def dealWithRead( self , verb , arg ): cmd = READSRC # check python code and send back any found syntax error if arg == None: return utils.parsedReturned( message = "JPyDaemon ReadSrc Argument missing") try: arg , lineno = self.nextArg(arg) candidate = file(arg) myBuffer = utils.parsedReturned( argument = arg , message=OK ) # # append the python source in <FILEREAD> TAG myBuffer.append( ['<FILEREAD' , 'fn="'+arg+'"' , 'lineno="'+str(lineno)+'">' + self.CDATAForXml(candidate.read()) + '</FILEREAD>' ] ) return myBuffer except IOError, e: return utils.parsedReturned( argument = arg , message = e.strerror ) # # parse & execute buffer command # def dealWithSetArgs( self , arg ): cmd = SETARGS # populate given command line argument before debugging start if arg == None: self.debuggeeArgs = [] # nor args provided else: self.debuggeeArgs = string.split(arg) self.debuggeeArgs.insert(0,'') # keep program name empty for the moment sys.argv = self.debuggeeArgs # store new argument list ins sys argv return utils.parsedReturned( argument = arg , message = OK ) # load the candidate source to debug # Run under debugger control def dealWithDebug( self , verb , arg ): self.cmd = DEBUG if self.debuggee == None: result = "source not found : " + arg for dirname in sys.path: fullname = os.path.join(dirname,arg) if os.path.exists(fullname): # Insert script directory in front of module search path # and make it current path (#sourceforge REQID 88108 fix) debugPath = os.path.dirname(fullname) sys.path.insert(0, debugPath) os.chdir(debugPath) oldstd = sys.stdout sys.stdout=self self.debuggee = fullname sys.argv[0] = fullname # keep sys.argv in sync try: self.run('execfile(' + `fullname` + ')') # send a dedicated message for syntax error in order for the # frontend debugger to handle a specific message and display the involved line # inside the frontend editor except: tb , exctype , value = sys.exc_info() excTrace = traceback.format_exception( tb , exctype , value ) # self.populateException(excTrace) self.send_client_exception(str(self.cmd) , utils.removeForXml(str(excTrace))) #print excTrace pass sys.stdout=oldstd result ="OK" self.debuggee = None break else: result = "debug already in progress on : " + self.debuggee return utils.parsedReturned( command = 'DEBUG' , argument = arg , message = result ) def formatStackElement( self , element ): curCode = element[0].f_code fName = curCode.co_filename line = element[1] if ( fName == '<string>' ): return ("program entry point") return utils.removeForXml(fName + ' (' + str(line) + ') ') # populate current stack info to client side def dealWithStack( self , frame ): stackList , size = self.get_stack ( frame , None ) stackList.reverse() xmlStack = ['<STACKLIST>' ] for stackElement in stackList: xmlStack.append('<STACK') xmlStack.append('content="'+ self.formatStackElement(stackElement) +'"') xmlStack.append( '/>') xmlStack.append('</STACKLIST>') self.populateToClient( xmlStack ) # populate requested disctionary to client side def dealWithVariables( self , frame , type , stackIndex ): # get the stack frame first stackList , size = self.get_stack ( frame , None ) stackList.reverse() stackElement = stackList[int(stackIndex)] if ( type == 'GLOBALS' ): variables = stackElement[0].f_globals else: variables = stackElement[0].f_locals xmlVariables = ['<VARIABLES type="'+type+'">' ] for mapElement in variables.iteritems(): xmlVariables.append('<VARIABLE ') xmlVariables.append('name="'+utils.removeForXml(mapElement[0])+'" ') xmlVariables.append('content="'+utils.removeForXml(str(mapElement[1]))+'" ') xmlVariables.append( '/>') xmlVariables.append('</VARIABLES>') self.populateToClient( xmlVariables ) def variablesSubCommand( self , frame , verb , arg , cmd ): self.cmd = cmd if ( arg == None ): arg = "0" else: arg , optarg = self.nextArg(arg) # split BP arguments self.dealWithVariables( frame , verb , arg ) self.cmd = FREEZE def nextArg( self , toParse ): nextSpace = string.strip(toParse).find(" ") if ( nextSpace == -1 ): return string.strip(toParse) , None else: return string.strip(toParse[:nextSpace]) , string.strip(toParse[nextSpace+1:]) # rough command/subcommand syntax analyzer def commandSyntax( self , command ): self.cmd = UNKNOWN verb , arg = self.nextArg(command) return verb , arg def quiting( self ): self.populateToClient( ['<TERMINATE/>'] ) self.set_quit() def parseSingleCommand( self , command ): verb , arg = self.commandSyntax( command ) if ( string.upper(verb) == "CMD" ): return self.dealWithCmd( verb , arg ) if ( string.upper(verb) == "READSRC" ): return self.dealWithRead( verb , arg ) if ( string.upper(verb) == "SETARGS" ): return self.dealWithSetArgs( arg ) elif ( string.upper(verb) == "DBG" ): return self.dealWithDebug( verb, arg ) elif ( string.upper(verb) == "STOP" ): return None else: return utils.parsedReturned( message = "JPyDaemon SYNTAX ERROR : " + command ) # receive a command when in debugging state using debuggee's frame local and global # contexts def parseSubCommand( self , command , frame ): if ( command == None ): # in case of IP socket Failures return UNKNOWN verb , arg = self.commandSyntax( command ) if ( string.upper(verb) == "CMD" ): self.populateCommandToClient( command , self.dealWithCmd( verb , arg , myGlobals= frame.f_globals , myLocals = frame.f_locals ) ) self.cmd = FREEZE elif ( string.upper(verb) == "READSRC" ): self.populateCommandToClient( command , self.dealWithRead( verb , arg ) ) self.cmd = FREEZE elif ( string.upper(verb) == "NEXT" ): self.cmd = NEXT self.set_next(frame) elif ( string.upper(verb) == "STEP" ): self.cmd = STEP self.set_step() elif ( string.upper(verb) == "RUN" ): self.cmd = RUN self.set_continue() elif ( string.upper(verb) == "STOP"): self.cmd = QUIT self.quiting() elif ( string.upper(verb) == "BP+"): self.cmd = SET_BP arg , optarg = self.nextArg(arg) # split BP arguments self.set_break( arg , int(optarg) ) self.cmd = FREEZE elif ( string.upper(verb) == "STACK"): self.cmd = STACK self.dealWithStack(frame) self.cmd = FREEZE elif ( string.upper(verb) == "LOCALS"): self.variablesSubCommand( frame , verb , arg , LOCALS ) elif ( string.upper(verb) == "GLOBALS"): self.variablesSubCommand( frame , verb , arg , GLOBALS ) elif ( string.upper(verb) == "BP-"): self.cmd = CLEAR_BP arg , optarg = self.nextArg(arg) # split BP arguments self.clear_break( arg , int(optarg) ) self.cmd = FREEZE return self.cmd # send command result back def populateCommandToClient( self , command , result ): self.populateToClient( [ '<' + result[0] , 'cmd="' +command+'"' , 'operation="' +utils.removeForXml(str(result[1]))+'"' , 'result="' +str(result[2])+'"' , '/>' ] ) if ( result[3] != None ): for element in result[3]: # print strElement self.populateToClient( [ '<COMMANDDETAIL ' , 'content="'+utils.removeForXml(element)+'"', ' />' ] ) # complementary TAG may be provided starting at position 4 if len(result) > 4 and (result[4]!=None): self.populateToClient( result[4] ) # check and execute a received command def parseCommand( self , command ): # IP exception populating None object if ( command == None ): return 0 # => stop daemon if ( self.verbose ): print command result = self.parseSingleCommand(command) if ( result == None ): self.populateToClient( ['<TERMINATE/>'] ) return 0 # stop requested self.populateCommandToClient( command , result ) return 1 # reading on network def readNetBuffer( self ): try: if ( self.lastBuffer.find('\n') != -1 ): return self.lastBuffer ; # buffer stills contains commands networkData = self.connection.recv(1024) if not networkData: # capture network interuptions if any return None data = self.lastBuffer + networkData return data except socket.error, (errno,strerror): print "recv interupted errno(%s) : %s" % ( errno , strerror ) return None # receive a command from the net def receiveCommand( self ): data = self.readNetBuffer() ; # data reception from Ip while ( data != None and data): eocPos = data.find('\n') nextPos = eocPos ; while ( nextPos < len(data) and \ ( data[nextPos] == '\n' or data[nextPos] == '\r') ): # ignore consecutive \n\r nextPos = nextPos+1 if ( eocPos != -1 ): # full command received in buffer self.lastBuffer = data[nextPos:] # cleanup received command from buffer returned = data[:eocPos] if (returned[-1] == '\r'): return returned[:-1] return returned data = self.readNetBuffer() ; # returning None on Ip Exception return None # start the deamon def start( self , port = PORT , host = None , debuggee = None ,debuggeeArgs = None ): if ( host == None ): # start in listen mode waiting for incoming sollicitors print "JPyDbg listening on " , port s = socket.socket( socket.AF_INET , socket.SOCK_STREAM ) s.bind( (HOST , port) ) s.listen(1) self.connection , addr = s.accept() print "connected by " , addr else: # connect back provided listening host print "JPyDbg connecting " , host , " on port " , port try: self.connection = socket.socket( socket.AF_INET , socket.SOCK_STREAM ) self.connection.connect( (host , port) ) print "JPyDbgI0001 : connected to " , host except socket.error, (errno,strerror): print "ERROR:JPyDbg connection failed errno(%s) : %s" % ( errno , strerror ) return None welcome = [ '<WELCOME/>' ] # populate debuggee's name for remote debugging bootstrap if debuggee != None: welcome = [ '<WELCOME' , 'debuggee="'+utils.removeForXml(debuggee)] if debuggeeArgs != None: welcome.append(string.join(debuggeeArgs)) # populate arguments after program Name # finally append XML closure welcome.append('" />') self.populateToClient( welcome ) while ( self.parseCommand( self.receiveCommand() ) ): pass print "'+++ JPy/sessionended/" self.connection.close() # start a listening instance when invoked as main program # without arguments # when [host [port]] are provided as argv jpydamon will try to # connect back host port instead of listening if __name__ == "__main__": instance = JPyDbg() port = PORT host = None localDebuggee = None args = None print "args = " , sys.argv if ( len(sys.argv) > 1 ): host=sys.argv[1] if ( len(sys.argv) > 2 ): port=int(sys.argv[2]) if ( len(sys.argv) > 3 ): localDebuggee=sys.argv[3] if ( len(sys.argv) > 4 ): args=sys.argv[4:] instance.start( host=host , port=port , debuggee=localDebuggee , debuggeeArgs=args ) print "deamon ended\n" --- NEW FILE: inspector.py --- #! /usr/bin/env python import sys import traceback import inspect import os import parser import symbol import token import types import string from types import ListType, TupleType def get_docs( source , basename ): """Retrieve information from the parse tree of a source file. source source code to parse. """ ast = parser.suite(source) return ModuleInfo(ast.totuple(1), basename) class SuiteInfoBase: _docstring = '' _name = '' def __init__(self, tree = None): self._class_info = {} self._function_info = {} if tree: self._extract_info(tree) def _extract_info(self, tree): # extract docstring if len(tree) == 2: found, vars = match(DOCSTRING_STMT_PATTERN[1], tree[1]) else: found, vars = match(DOCSTRING_STMT_PATTERN, tree[3]) if found: self._docstring = eval(vars['docstring']) # discover inner definitions for node in tree[1:]: found, vars = match(COMPOUND_STMT_PATTERN, node) if found: cstmt = vars['compound'] if cstmt[0] == symbol.funcdef: name = cstmt[2][1] self._function_info[name] = FunctionInfo(cstmt) elif cstmt[0] == symbol.classdef: name = cstmt[2][1] self._class_info[name] = ClassInfo(cstmt) def get_docstring(self): return self._docstring def get_name(self): return self._name def get_class_names(self): return self._class_info.keys() def get_class_info(self, name): return self._class_info[name] def __getitem__(self, name): try: return self._class_info[name] except KeyError: return self._function_info[name] class SuiteFuncInfo: # Mixin class providing access to function names and info. def get_function_names(self): return self._function_info.keys() def get_function_info(self, name): return self._function_info[name] class FunctionInfo(SuiteInfoBase, SuiteFuncInfo): def __init__(self, tree = None): self._name = tree[2][1] self._lineNo = tree[2][2] self._args = [] self.argListInfos( tree[3] ) SuiteInfoBase.__init__(self, tree and tree[-1] or None) def get_DeclareLineNo( self ): return self._lineNo def argListInfos( self , tree ): argType = tree[0] if argType == symbol.parameters: self.argListInfos(tree[2]) elif argType == symbol.varargslist: for arg in tree[1:]: self.argListInfos(arg) elif argType == symbol.fpdef: self._args.append(tree[1]) class ClassInfo(SuiteInfoBase): def __init__(self, tree = None): self._name = tree[2][1] self._lineNo = tree[2][2] SuiteInfoBase.__init__(self, tree and tree[-1] or None) def get_method_names(self): return self._function_info.keys() def get_method_info(self, name): return self._function_info[name] def get_DeclareLineNo(): return self._lineNo class ModuleInfo(SuiteInfoBase, SuiteFuncInfo): def __init__(self, tree = None, name = "<string>"): self._name = name SuiteInfoBase.__init__(self, tree) if tree: found, vars = match(DOCSTRING_STMT_PATTERN, tree[1]) if found: self._docstring = vars["docstring"] def match(pattern, data, vars=None): """Match `data' to `pattern', with variable extraction. pattern Pattern to match against, possibly containing variables. data Data to be checked and against which variables are extracted. vars Dictionary of variables which have already been found. If not provided, an empty dictionary is created. The `pattern' value may contain variables of the form ['varname'] which are allowed to match anything. The value that is matched is returned as part of a dictionary which maps 'varname' to the matched value. 'varname' is not required to be a string object, but using strings makes patterns and the code which uses them more readable. This function returns two values: a boolean indicating whether a match was found and a dictionary mapping variable names to their associated values. """ if vars is None: vars = {} if type(pattern) is ListType: # 'variables' are ['varname'] vars[pattern[0]] = data return 1, vars if type(pattern) is not TupleType: return (pattern == data), vars if len(data) != len(pattern): return 0, vars for pattern, data in map(None, pattern, data): same, vars = match(pattern, data, vars) if not same: break return same, vars # This pattern identifies compound statements, allowing them to be readily # differentiated from simple statements. # COMPOUND_STMT_PATTERN = ( symbol.stmt, (symbol.compound_stmt, ['compound']) ) # This pattern will match a 'stmt' node which *might* represent a docstring; # docstrings require that the statement which provides the docstring be the # first statement in the class or function, which this pattern does not check. # DOCSTRING_STMT_PATTERN = ( symbol.stmt, (symbol.simple_stmt, (symbol.small_stmt, (symbol.expr_stmt, (symbol.testlist, (symbol.test, (symbol.and_test, (symbol.not_test, (symbol.comparison, (symbol.expr, (symbol.xor_expr, (symbol.and_expr, (symbol.shift_expr, (symbol.arith_expr, (symbol.term, (symbol.factor, (symbol.power, (symbol.atom, (token.STRING, ['docstring']) )))))))))))))))), (token.NEWLINE, '') )) class jpyutils : def parsedReturned( self , command = 'COMMAND' , argument = None , message = None , details = None ): parsedCommand = [] parsedCommand.append(command) parsedCommand.append(argument) parsedCommand.append(message) parsedCommand.append(details) return parsedCommand def populateCMDException( self , arg , oldstd ): "global utility exception reporter for all pydbg classes" sys.stdout=oldstd tb , exctype , value = sys.exc_info() excTrace = traceback.format_exception( tb , exctype , value ) tb = None # release return self.parsedReturned( argument = arg , message = "Error on CMD" , details = excTrace ) def removeForXml( self , strElem , keepLinefeed = 0 ): "replace unsuported xml encoding characters" if (not keepLinefeed ): strElem = string.replace(strElem,'\n','') strElem = string.replace(strElem,'"',""") strElem = string.replace(strElem,'<','<') strElem = string.replace(strElem,'>','>') return strElem class xmlizer: "xmlize a provided syntax error or parsed module infos" def __init__(self , infos , baseName , fName , destFName , error = None ): self.Infos = infos self.Error = error self.Utils = jpyutils() self.FileName = fName self.DestFName = destFName self.BaseName = baseName def populate_error( self ): LINESTR = 'line ' reason=self.Error[len(self.Error)-1] lower =self.Error[2].find(LINESTR)+len(LINESTR) higher=self.Error[2].find(',',lower) lineNo=self.Error[2][lower:] self.Dest.write('<error fileid="'+ \ self.Utils.removeForXml(self.FileName)+ \ '" reason="' + \ reason + \ '" lineno="'+lineNo+'" />' ) def populate_class_infos( self , className ): classInfo = self.Infos.get_class_info(className) self.Dest.write('<class name="'+ \ self.Utils.removeForXml(className)+ \ '" doc="' + \ self.Utils.removeForXml(classInfo.get_docstring()) + \ '" lineno="'+ str(classInfo._lineNo) +'" >\n' ) # gather infos about class methods methods = classInfo.get_method_names() for methodName in methods: method = classInfo.get_method_info(methodName) self.populate_method_infos(method,methodName) self.Dest.write('</class>\n' ) def populate_function_arguments_infos( self , args ): for arg in args: self.Dest.write(' <argument name="' + \ arg[1] + '" lineno="' +\ str(arg[2]) + '"/>\n') def populate_method_infos( self , method , methodName): self.Dest.write('<function name="'+ \ self.Utils.removeForXml(methodName)+ \ '" doc="' + \ self.Utils.removeForXml(method.get_docstring()) + \ '" lineno="'+ str(method._lineNo) +'" >\n' ) if (len(method._args) != 0): self.populate_function_arguments_infos(method._args) self.Dest.write("</function>\n") def populate_function_infos( self , functionName ): functionInfo = self.Infos.get_function_info(functionName) self.populate_method_infos(functionInfo,functionName) def populate_tree( self ): self.Dest.write('<module name="'+self.BaseName+'">\n') classes = self.Infos.get_class_names() for curClass in classes: self.populate_class_infos(curClass) functions = self.Infos.get_function_names() for curFunction in functions: self.populate_function_infos(curFunction) self.Dest.write("</module>\n") def populate( self ): self.Dest = file( self.DestFName , 'w+' ) self.Dest.write( '<?xml version="1.0"?>\n') if self.Error != None: self.populate_error() else: self.populate_tree() self.Dest.close() class commander : "python source file inspector/introspector" def __init__(self , source , dest ): "constructor providing python source to inspect" self.SourceFile = source self.DestFile = dest self.Infos = None self.BaseName = None self.Errors = None def check(self): "make a syntaxic control of provided source " # execute requested dynamic command on this side fp = open(self.SourceFile,"r") sourceStr = fp.read() + "\n" try: # extract python module name self.BaseName = os.path.basename(os.path.splitext(self.SourceFile)[0]) self.Code = compile( sourceStr , self.SourceFile , "exec" ) self.Infos = get_docs( sourceStr , self.BaseName ) except: tb , exctype , value = sys.exc_info() self.Errors = traceback.format_exception(tb,exctype,value) pass xml = xmlizer(self.Infos , self.BaseName , self.SourceFile , self.DestFile , self.Errors ) xml.populate() # # inspector launcher entry point # if __name__ == "__main__": # inspect jpydaemon itself print "args = " , sys.argv if ( len(sys.argv) > 1 ): source = sys.argv[1] if ( len(sys.argv) > 2 ): dest = sys.argv[2] if ( len(sys.argv) < 3 ): sys.exit(12) # missing arguments instance = commander( source , dest) instance.check() pass |
From: Aleksandar T. <at...@us...> - 2004-03-29 17:16:10
|
Update of /cvsroot/pydev/org.python.pydev.debug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32116 Modified Files: build.properties Log Message: Add pysrc to the plugin includes Index: build.properties =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/build.properties,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** build.properties 10 Jan 2004 03:13:04 -0000 1.2 --- build.properties 29 Mar 2004 17:04:40 -0000 1.3 *************** *** 2,5 **** *.jar,\ pydev-debug.jar,\ ! icons/ source.pydev-debug.jar = src/ --- 2,7 ---- *.jar,\ pydev-debug.jar,\ ! icons/,\ ! pysrc/*.py ! source.pydev-debug.jar = src/ |
From: Aleksandar T. <at...@us...> - 2004-03-29 17:14:54
|
Update of /cvsroot/pydev/org.python.pydev.debug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31876 Modified Files: .classpath Log Message: Dynamic classpaths are much neater Index: .classpath =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/.classpath,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** .classpath 10 Jan 2004 03:13:04 -0000 1.2 --- .classpath 29 Mar 2004 17:03:25 -0000 1.3 *************** *** 2,38 **** <classpath> <classpathentry kind="src" path="src/"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.core.resources_2.1.1/resources.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.resources_2.1.1/resourcessrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.core.runtime_2.1.1/runtime.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.runtime_2.1.1/runtimesrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.core.boot_2.1.2/boot.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.core.boot_2.1.2/bootsrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.ui_2.1.1/ui.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui_2.1.1/uisrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.swt.win32_2.1.2/ws/win32/swt.jar" sourcepath="ORG_ECLIPSE_PLATFORM_WIN32_SOURCE_SRC/org.eclipse.swt.win32_2.1.2/ws/win32/swtsrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.text_2.1.0/text.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.text_2.1.0/textsrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.jface_2.1.1/jface.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.jface_2.1.1/jfacesrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.jface.text_2.1.0/jfacetext.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.jface.text_2.1.0/jfacetextsrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.ui.views_2.1.0/views.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.views_2.1.0/viewssrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.ui.workbench_2.1.1/workbench.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.workbench_2.1.1/workbenchsrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.ui.win32_2.1.0/workbenchwin32.jar" sourcepath="ORG_ECLIPSE_PLATFORM_WIN32_SOURCE_SRC/org.eclipse.ui.win32_2.1.0/workbenchwin32src.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.ui.workbench.texteditor_2.1.0/texteditor.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.workbench.texteditor_2.1.0/texteditorsrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.ui.editors_2.1.0/editors.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.editors_2.1.0/editorssrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.ui.externaltools_2.1.1/externaltools.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.ui.externaltools_2.1.1/externaltoolssrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.debug.core_2.1.2/dtcore.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.debug.core_2.1.2/dtcoresrc.zip"/> ! <classpathentry kind="var" ! path="ECLIPSE_HOME/plugins/org.eclipse.debug.ui_2.1.1/dtui.jar" sourcepath="ORG_ECLIPSE_PLATFORM_SOURCE_SRC/org.eclipse.debug.ui_2.1.1/dtuisrc.zip"/> ! <classpathentry kind="src" path="/org.python.pydev"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> --- 2,6 ---- <classpath> <classpathentry kind="src" path="src/"/> ! <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> <classpathentry kind="output" path="bin"/> |
From: Aleksandar T. <at...@us...> - 2004-03-29 17:13:55
|
Update of /cvsroot/pydev/org.python.pydev.debug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31697 Modified Files: plugin.xml Log Message: Renamed DebugPlugin PydevDebugPlugin to prevent conflicts. Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/plugin.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** plugin.xml 5 Mar 2004 16:20:36 -0000 1.3 --- plugin.xml 29 Mar 2004 17:02:26 -0000 1.4 *************** *** 5,9 **** version="0.3.0" provider-name="Aleks Totic" ! class="org.python.pydev.debug.core.DebugPlugin"> <runtime> --- 5,9 ---- version="0.3.0" provider-name="Aleks Totic" ! class="org.python.pydev.debug.core.PydevDebugPlugin"> <runtime> *************** *** 22,25 **** --- 22,26 ---- <import plugin="org.eclipse.debug.ui"/> <import plugin="org.python.pydev"/> + <import plugin="org.apache.xerces"/> </requires> *************** *** 61,66 **** icon="icons/python.gif" modes="run, debug" ! class="org.python.pydev.debug.ui.launching.LaunchShortcut" id="org.python.pydev.debug.launchShortcut"> </shortcut> </extension> --- 62,68 ---- icon="icons/python.gif" modes="run, debug" ! class="org.python.pydev.debug.launching.LaunchShortcut" id="org.python.pydev.debug.launchShortcut"> + <perspective id="org.eclipse.debug.ui.DebugPerspective"/> </shortcut> </extension> *************** *** 122,129 **** id="org.python.pydev.debug.debug"> </launchGroup> ! </extension> ! <extension ! point="org.eclipse.debug.ui.launchGroups"> ! <launchGroup label="Run" bannerImage="icons/python-big.gif" --- 124,128 ---- id="org.python.pydev.debug.debug"> </launchGroup> ! <launchGroup label="Run" bannerImage="icons/python-big.gif" *************** *** 143,146 **** --- 142,169 ---- </consoleLineTracker> </extension> + <!--- breakpoint marker --> + <!--- TODO just a placeholder for now --> + <extension + id="pyBreakpointMarker" + point="org.eclipse.core.resources.markers"> + <super + type="org.eclipse.debug.core.breakpointMarker"> + </super> + <persistent + value="true"> + </persistent> + <attribute + name="org.eclipse.cdt.debug.core.condition"> + </attribute> + <attribute + name="org.eclipse.cdt.debug.core.ignoreCount"> + </attribute> + <attribute + name="org.eclipse.cdt.debug.core.threadId"> + </attribute> + <attribute + name="org.eclipse.cdt.debug.core.installCount"> + </attribute> + </extension> </plugin> |
From: Aleksandar T. <at...@us...> - 2004-03-29 17:09:36
|
Update of /cvsroot/pydev/org.python.pydev.debug/pysrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30903/pysrc Log Message: Directory /cvsroot/pydev/org.python.pydev.debug/pysrc added to the repository |