pydev-cvs Mailing List for PyDev for Eclipse (Page 308)
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: Fabio Z. <fa...@us...> - 2004-08-10 11:39:21
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22463/src/org/python/pydev/editor Modified Files: PythonCompletionProcessor.java Log Message: Added template proposals. Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PythonCompletionProcessor.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PythonCompletionProcessor.java 10 Aug 2004 02:00:57 -0000 1.11 --- PythonCompletionProcessor.java 10 Aug 2004 11:39:11 -0000 1.12 *************** *** 2,7 **** * 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; --- 2,5 ---- *************** *** 16,19 **** --- 14,18 ---- import java.net.URL; import java.util.ArrayList; + import java.util.Arrays; import java.util.Iterator; import java.util.List; *************** *** 26,29 **** --- 25,29 ---- import org.eclipse.core.runtime.Platform; import org.eclipse.jface.text.IDocument; + import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.CompletionProposal; *************** *** 32,46 **** import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationValidator; import org.eclipse.swt.graphics.Point; import org.osgi.framework.Bundle; import org.python.pydev.plugin.PydevPlugin; /** * @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 { /* --- 32,73 ---- import org.eclipse.jface.text.contentassist.IContextInformation; import org.eclipse.jface.text.contentassist.IContextInformationValidator; + import org.eclipse.jface.text.templates.Template; + import org.eclipse.jface.text.templates.TemplateCompletionProcessor; + import org.eclipse.jface.text.templates.TemplateContextType; + import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; import org.osgi.framework.Bundle; + import org.python.pydev.editor.templates.PyContextType; import org.python.pydev.plugin.PydevPlugin; /** * @author Dmoore + * @author Fabio Zadrozny - added template completion. * ! * This class is responsible for code completion / template completion. */ ! public class PythonCompletionProcessor extends TemplateCompletionProcessor implements IContentAssistProcessor { ! /* (non-Javadoc) ! * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getTemplates(java.lang.String) ! */ ! protected Template[] getTemplates(String contextTypeId) { ! return PydevPlugin.getDefault().getTemplateStore().getTemplates(); ! } ! ! /* (non-Javadoc) ! * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getContextType(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) ! */ ! protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) { ! return PydevPlugin.getDefault().getContextTypeRegistry().getContextType(PyContextType.PY_CONTEXT_TYPE); ! } ! ! ! /* (non-Javadoc) ! * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getImage(org.eclipse.jface.text.templates.Template) ! */ ! protected Image getImage(Template template) { ! // TODO Auto-generated method stub ! return null; ! } /* *************** *** 82,86 **** propList.add(proposal); } ! ICompletionProposal[] proposals = new ICompletionProposal[propList .size()]; --- 109,118 ---- propList.add(proposal); } ! ! //templates proposals are added here. ! ICompletionProposal[] templateProposals = super.computeCompletionProposals(viewer, documentOffset); ! propList.addAll(Arrays.asList(templateProposals)); ! ! ICompletionProposal[] proposals = new ICompletionProposal[propList .size()]; |
From: Dana M. <dan...@us...> - 2004-08-10 02:01:05
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8010/src/org/python/pydev/editor Modified Files: PythonCompletionProcessor.java Log Message: fixed compiler advisory warnings Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PythonCompletionProcessor.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PythonCompletionProcessor.java 10 Aug 2004 01:36:59 -0000 1.10 --- PythonCompletionProcessor.java 10 Aug 2004 02:00:57 -0000 1.11 *************** *** 7,11 **** package org.python.pydev.editor; - import java.io.BufferedInputStream; import java.io.BufferedReader; import java.io.BufferedWriter; --- 7,10 ---- *************** *** 15,28 **** import java.io.InputStream; import java.io.InputStreamReader; - import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.Iterator; import java.util.List; - import java.util.Properties; import java.util.Vector; - import org.eclipse.core.resources.IFile; - import org.eclipse.core.resources.ResourcesPlugin; import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.IPath; --- 14,23 ---- *************** *** 30,34 **** import org.eclipse.core.runtime.Path; import org.eclipse.core.runtime.Platform; - import org.eclipse.core.runtime.Plugin; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; --- 25,28 ---- *************** *** 40,44 **** import org.eclipse.swt.graphics.Point; import org.osgi.framework.Bundle; - import org.python.parser.ast.If; import org.python.pydev.plugin.PydevPlugin; --- 34,37 ---- |
From: Dana M. <dan...@us...> - 2004-08-10 01:37:08
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4612/src/org/python/pydev/editor Modified Files: PythonCompletionProcessor.java Log Message: reomved all debug System.out.printlna Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PythonCompletionProcessor.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PythonCompletionProcessor.java 9 Aug 2004 22:30:58 -0000 1.9 --- PythonCompletionProcessor.java 10 Aug 2004 01:36:59 -0000 1.10 *************** *** 65,69 **** List propList = new ArrayList(); IDocument doc = viewer.getDocument(); ! // System.out.println("The document:"+doc.get()); Point selectedRange = viewer.getSelectedRange(); // there may not be a selected range --- 65,69 ---- List propList = new ArrayList(); IDocument doc = viewer.getDocument(); ! //System.out.println("The document:"+doc.get()); Point selectedRange = viewer.getSelectedRange(); // there may not be a selected range *************** *** 72,84 **** String activationToken = this .getActivationToken(theDoc, documentOffset); ! System.out.println("DBG:theActivationToken: " + activationToken); theDoc = partialDocument(theDoc, documentOffset); java.lang.String qualifier = getQualifier(doc, documentOffset); int qlen = qualifier.length(); theDoc += "\n"+activationToken; ! System.out.println("Interpreted doc: " + theDoc); ! // System.out.println("activationToken: " + activationToken); Vector theList = autoComplete(theDoc, activationToken); ! System.out.println("DBG:vector:" + theList); for (Iterator iter = theList.iterator(); iter.hasNext();) { --- 72,84 ---- String activationToken = this .getActivationToken(theDoc, documentOffset); ! //System.out.println("DBG:theActivationToken: " + activationToken); theDoc = partialDocument(theDoc, documentOffset); java.lang.String qualifier = getQualifier(doc, documentOffset); int qlen = qualifier.length(); theDoc += "\n"+activationToken; ! //System.out.println("Interpreted doc: " + theDoc); ! //System.out.println("activationToken: " + activationToken); Vector theList = autoComplete(theDoc, activationToken); ! //System.out.println("DBG:vector:" + theList); for (Iterator iter = theList.iterator(); iter.hasNext();) { *************** *** 104,114 **** String s = new String(); File tmp = null; ! System.out.println("DBG:autoComplete"); try { // get the inspect.py file from the package: s = getAutoCompleteScript(); ! System.out.println("DBG:getAutoCompleteScript() returns" + s); } catch (CoreException e) { ! System.out.println("DBG:getAutoCompleteScript() fails " + e); e.printStackTrace(); } --- 104,114 ---- String s = new String(); File tmp = null; ! //System.out.println("DBG:autoComplete"); try { // get the inspect.py file from the package: s = getAutoCompleteScript(); ! //System.out.println("DBG:getAutoCompleteScript() returns" + s); } catch (CoreException e) { ! //System.out.println("DBG:getAutoCompleteScript() fails " + e); e.printStackTrace(); } *************** *** 124,128 **** String ss = new String("python " + s + " " + tmp.getAbsolutePath()); ! System.out.println("DBG:exec string " + ss); Process p = Runtime.getRuntime().exec(ss); BufferedReader in = new BufferedReader(new InputStreamReader(p --- 124,128 ---- String ss = new String("python " + s + " " + tmp.getAbsolutePath()); ! //System.out.println("DBG:exec string " + ss); Process p = Runtime.getRuntime().exec(ss); BufferedReader in = new BufferedReader(new InputStreamReader(p *************** *** 132,136 **** if(!str.startsWith("tip: ")) continue; str = str.substring(5); ! System.out.println("DBG:autoComplete:output: " + str); theList.add(str); } --- 132,136 ---- if(!str.startsWith("tip: ")) continue; str = str.substring(5); ! //System.out.println("DBG:autoComplete:output: " + str); theList.add(str); } *************** *** 141,145 **** while ((str = eIn.readLine()) != null) { ! System.out.println("error output: " + str); } p.waitFor(); --- 141,145 ---- while ((str = eIn.readLine()) != null) { ! //System.out.println("error output: " + str); } p.waitFor(); *************** *** 149,153 **** } catch (InterruptedException e) { // TODO Auto-generated catch block ! System.out.println("Interrupted call: error output: "); e.printStackTrace(); } --- 149,153 ---- } catch (InterruptedException e) { // TODO Auto-generated catch block ! //System.out.println("Interrupted call: error output: "); e.printStackTrace(); } *************** *** 179,188 **** public static String getAutoCompleteScript() throws CoreException { String targetExec = "tipper.py"; ! System.out.println("DBG:getAutoCompleteScript();"); IPath relative = new Path("PySrc").addTrailingSeparator().append( targetExec); ! System.out.println("DBG:getAutoCompleteScript(); relative " + relative); Bundle bundle = PydevPlugin.getDefault().getBundle(); ! System.out.println("DBG:getAutoCompleteScript(); bundle " + bundle); URL bundleURL = Platform.find(bundle, relative); URL fileURL; --- 179,188 ---- public static String getAutoCompleteScript() throws CoreException { String targetExec = "tipper.py"; ! //System.out.println("DBG:getAutoCompleteScript();"); IPath relative = new Path("PySrc").addTrailingSeparator().append( targetExec); ! //System.out.println("DBG:getAutoCompleteScript(); relative " + relative); Bundle bundle = PydevPlugin.getDefault().getBundle(); ! //System.out.println("DBG:getAutoCompleteScript(); bundle " + bundle); URL bundleURL = Platform.find(bundle, relative); URL fileURL; *************** *** 190,195 **** fileURL = Platform.asLocalURL(bundleURL); String filePath = new File(fileURL.getPath()).getAbsolutePath(); ! System.out.println("DBG:getAutoCompleteScript();filePath " ! + filePath); return filePath; } catch (IOException e) { --- 190,194 ---- fileURL = Platform.asLocalURL(bundleURL); String filePath = new File(fileURL.getPath()).getAbsolutePath(); ! //System.out.println("DBG:getAutoCompleteScript();filePath " + filePath); return filePath; } catch (IOException e) { |
From: Dana M. <dan...@us...> - 2004-08-10 01:16:23
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1875/src/org/python/pydev/plugin Modified Files: PydevPlugin.java Log Message: revamp of the autocompletion code to use only a CPython interpreter Index: PydevPlugin.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PydevPlugin.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PydevPlugin.java 6 Aug 2004 17:20:03 -0000 1.10 --- PydevPlugin.java 10 Aug 2004 01:16:13 -0000 1.11 *************** *** 87,90 **** --- 87,93 ---- return ResourcesPlugin.getWorkspace(); } + public static Status makeStatus(int errorLevel, String message, Throwable e) { + return new Status(errorLevel, getPluginID(), errorLevel, message, e); + } /** |
From: Aleksandar T. <at...@us...> - 2004-08-10 00:21:39
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26255 Modified Files: plugin.xml Log Message: Fix the StripTrailingWhitespace bug Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.26 retrieving revision 1.27 diff -C2 -d -r1.26 -r1.27 *** plugin.xml 6 Aug 2004 17:20:03 -0000 1.26 --- plugin.xml 10 Aug 2004 00:21:29 -0000 1.27 *************** *** 139,149 **** </action> <action - definitionId="org.python.pydev.editor.actions.stripTrailingWhitespace" - label="Strip trailing whitespace" - class="org.python.pydev.editor.actions.PyStripTrailingWhitespace" - menubarPath="org.python.pydev.editor.actions.sourceMenu/whitespaceGroup" - id="org.python.pydev.editor.actions.stripTrailingWhitespace"> - </action> - <action definitionId="org.python.pydev.editor.actions.uncomment" label="Uncomment" --- 139,142 ---- *************** *** 264,273 **** </action> <action - label="Strip trailing whitespace" - class="org.python.pydev.editor.actions.PyStripTrailingWhitespace" - menubarPath="org.python.pydev.editor.actions.editorPopup/whitespaceGroup" - id="org.python.pydev.editor.actions.stripTrailingWhitespace"> - </action> - <action label="Uncomment" class="org.python.pydev.editor.actions.PyUncomment" --- 257,260 ---- *************** *** 400,416 **** configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> </keyBinding> - <!-- command: whitespace--> - <command - name="Strip trailing whitespace" - description="Strips trailing whitespace from selected region or whole document if nothing selected" - category="org.python.pydev.ui.category.source" - id="org.python.pydev.editor.actions.stripTrailingWhitespace"> - </command> - <keyBinding - string="Shift+Space" - scope="org.python.pydev.ui.editor.scope" - command="org.python.pydev.editor.actions.stripTrailingWhitespace" - configuration="org.eclipse.ui.defaultAcceleratorConfiguration"> - </keyBinding> <!-- command: unblock--> <command --- 387,390 ---- |
From: Aleksandar T. <at...@us...> - 2004-08-10 00:02:39
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23438/src/org/python/pydev/plugin Modified Files: DebugPrefsPage.java Log Message: Fixed the Debug Timeout preference bug. Index: DebugPrefsPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/DebugPrefsPage.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** DebugPrefsPage.java 25 Jul 2004 13:51:39 -0000 1.2 --- DebugPrefsPage.java 10 Aug 2004 00:02:16 -0000 1.3 *************** *** 49,54 **** PydevPrefs.INTERPRETER_PATH, "Python interpreters (for example python.exe)", p); addField(pathEditor); ! IntegerFieldEditor ife = new IntegerFieldEditor(PydevPrefs.CONNECT_TIMEOUT, "Connect timeout (ms)", p, 1); ! ife.setValidRange(1000, 200000); addField(ife); } --- 49,55 ---- PydevPrefs.INTERPRETER_PATH, "Python interpreters (for example python.exe)", p); addField(pathEditor); ! IntegerFieldEditor ife = new IntegerFieldEditor(PydevPrefs.CONNECT_TIMEOUT, "Connect timeout (ms)", p, 10); ! // ife.setValidateStrategy(StringFieldEditor.VALIDATE_ON_FOCUS_LOST); ! // ife.setValidRange(0, 200000); addField(ife); } |
From: Dana M. <dan...@us...> - 2004-08-09 22:31:08
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8237/src/org/python/pydev/editor Modified Files: PyEditConfiguration.java PythonCompletionProcessor.java Log Message: revamp of the autocompletion code to use only a CPython interpreter Index: PyEditConfiguration.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditConfiguration.java,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** PyEditConfiguration.java 6 Aug 2004 17:20:02 -0000 1.14 --- PyEditConfiguration.java 9 Aug 2004 22:30:58 -0000 1.15 *************** *** 297,301 **** assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); // Allow automatic activation after 500 msec ! assistant.enableAutoActivation(false); assistant.setAutoActivationDelay(500); Color bgColor = colorCache.getColor(new RGB(230,255,230)); --- 297,301 ---- 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)); Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PythonCompletionProcessor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PythonCompletionProcessor.java 6 Aug 2004 17:20:02 -0000 1.8 --- PythonCompletionProcessor.java 9 Aug 2004 22:30:58 -0000 1.9 *************** *** 7,248 **** package org.python.pydev.editor; ! import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; ! import org.eclipse.jface.text.templates.Template; ! import org.eclipse.jface.text.templates.TemplateCompletionProcessor; ! import org.eclipse.jface.text.templates.TemplateContextType; ! import org.eclipse.swt.graphics.Image; ! import org.python.pydev.editor.templates.PyContextType; import org.python.pydev.plugin.PydevPlugin; ! public class PythonCompletionProcessor extends TemplateCompletionProcessor implements IContentAssistProcessor { ! /* (non-Javadoc) ! * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getTemplates(java.lang.String) ! */ ! protected Template[] getTemplates(String contextTypeId) { ! return PydevPlugin.getDefault().getTemplateStore().getTemplates(); ! } ! /* (non-Javadoc) ! * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getContextType(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) ! */ ! protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) { ! return PydevPlugin.getDefault().getContextTypeRegistry().getContextType(PyContextType.PY_CONTEXT_TYPE); ! } ! /* (non-Javadoc) ! * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getImage(org.eclipse.jface.text.templates.Template) ! */ ! protected Image getImage(Template template) { ! // TODO Auto-generated method stub ! return null; ! } ! } ! ///** ! // * @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) ! // */ ! // int docBoundary = -1; // the document prior to the activation token ! // int docBoundary2 = 0; ! // public ICompletionProposal[] computeCompletionProposals( ! // ITextViewer viewer, ! // int documentOffset) { ! // List propList = new ArrayList(); ! // IDocument doc = viewer.getDocument(); ! // // System.out.println("The document:"+doc.get()); ! // Point selectedRange = viewer.getSelectedRange(); ! // // there may not be a selected range ! // java.lang.String theDoc = doc.get(); ! // calcDocBoundary(theDoc, documentOffset); ! // String activationToken = this.getActivationToken(theDoc, documentOffset); ! //// System.out.println("DBG:theActivationToken: "+activationToken); ! // theDoc = partialDocument(theDoc, documentOffset); ! //// System.out.println("DBG:theDoc: "+theDoc); ! // PythonInterpreter interp = initInterpreter(null); ! // java.lang.String qualifier = getQualifier(doc, documentOffset); ! // int qlen = qualifier.length(); ! // try { ! // System.out.println("Interpreted doc: "+theDoc); ! // PyList theList = autoComplete(interp, theDoc, activationToken); ! // PyObject o = new PyObject(); ! // for (int i = 0; i < theList.__len__(); i++) { ! // String p = theList.__getitem__(i).toString(); ! //// System.out.println("Item:" + p); ! // CompletionProposal proposal = ! // new CompletionProposal( ! // p, ! // documentOffset - qlen, ! // qlen, ! // p.length()); ! // propList.add(proposal); ! // } ! // ! // } catch (PyException e) { ! // e.printStackTrace(); ! // } ! // ! // PyObject theCode = null; ! // ! // ICompletionProposal[] proposals = ! // new ICompletionProposal[propList.size()]; ! // // and fill with list elements ! // propList.toArray(proposals); ! // // Return the proposals ! // return proposals; ! // ! // } ! // private PyList autoComplete( ! // PythonInterpreter interp, ! // java.lang.String theCode, ! // java.lang.String theActivationToken) ! // throws PyException { ! // StringBuffer example = new StringBuffer(); ! // interp.exec("from PyDev import jintrospect"); ! //// System.out.println("DBG:from PyDev import jintrospect:done"); ! // interp.exec("class object:pass"); //TODO: REMOVE AFTER JYTHON ADDS SUPPORT TO NEW STYLE CLASSES. ! // interp.exec(theCode); ! // String xCommand = "theList = jintrospect.getAutoCompleteList(command='"+theActivationToken+"', locals=locals())"; ! //// System.out.println("DBG:xCommand:"+xCommand); ! // interp.exec(xCommand); ! // PyList theList = (PyList) interp.get("theList"); ! // return theList; ! // } ! // ! // /** ! // * @param qualifier ! // * @param documentOffset ! // * @param proposals ! // */ ! // public void calcDocBoundary(String theDoc, int documentOffset){ ! // this.docBoundary = theDoc.substring(0, documentOffset).lastIndexOf('\n'); ! // } ! // public String getActivationToken(String theDoc, int documentOffset) { ! // if (this.docBoundary < 0){ ! // calcDocBoundary(theDoc,documentOffset); ! // } ! // return theDoc.substring(this.docBoundary+1, documentOffset); ! // } ! // ! // /** ! // * @param theDoc ! // */ ! // private String partialDocument(String theDoc, int documentOffset) { ! // if (this.docBoundary < 0){ ! // calcDocBoundary(theDoc,documentOffset); ! // } ! // ! // String before = theDoc.substring(0, this.docBoundary); ! // return before; ! // ! // } ! // ! // /** ! // * @param doc ! // * @param documentOffset ! // */ ! // private java.lang.String getQualifier(IDocument doc, int documentOffset) { ! // // this routine should return any partial entry after the activation character ! // return ""; ! // } ! // ! // /* (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 java.lang.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; ! // } ! //// 1. create the PythonSystemState with the embedded $py.class files inserted into its path ! //// 2. ! // protected PythonInterpreter initInterpreter(java.lang.String[] argv) { ! // Properties p = System.getProperties(); ! //// p.setProperty("python.path", "c:\\Jython\\Lib"); ! // PySystemState.initialize(); ! // PythonInterpreter.initialize(System.getProperties(), p, null); ! // return new PythonInterpreter(null, createPySystemState()); ! // } ! // /** ! // * Create a new Python interpreter system state object aware for standard ! // * Jython library. ! // * ! // * @return Python interpreter system state. ! // * ! // * @throws JythonRuntimeException if it fails to locate the Jython ! // * libraries. The exception message will contain an explanation of the ! // * reason to fail. ! // */ ! // private String _jythonLib = null; ! // public PySystemState createPySystemState() { ! // if (_jythonLib == null) { ! // // Locate org.jython plugin and grab the jar location ! // Plugin jythonPlugin = Platform.getPlugin("org.pydev.jython"); ! // ! // String jythonPath = ! // jythonPlugin.getDescriptor().getInstallURL().toString() + "jythonlib.jar"; ! // try { ! // _jythonLib = Platform.asLocalURL(new URL(jythonPath)).getFile(); ! //// System.out.println("_jythonLib:"+_jythonLib); ! // } catch (MalformedURLException e) { ! // System.out.println( ! // "Failed to located Python System library because of invalid URL."+ ! // e); ! // } catch (IOException e) { ! // System.out.println( ! // "Failed to located Python System library because of IO Error."+ ! // e); ! // } ! // } ! // PySystemState result = new PySystemState(); ! // result.path.insert(0, new PyString(_jythonLib + "/Lib")); ! //// System.out.println("result.path: "+result.path); ! // // Location of the jython/python modules ! // return result; ! // } ! // ! //} --- 7,292 ---- package org.python.pydev.editor; ! import java.io.BufferedInputStream; ! import java.io.BufferedReader; ! import java.io.BufferedWriter; ! import java.io.File; ! import java.io.FileWriter; ! import java.io.IOException; ! import java.io.InputStream; ! import java.io.InputStreamReader; ! import java.net.MalformedURLException; ! import java.net.URL; ! import java.util.ArrayList; ! import java.util.Iterator; ! import java.util.List; ! import java.util.Properties; ! import java.util.Vector; ! ! import org.eclipse.core.resources.IFile; ! import org.eclipse.core.resources.ResourcesPlugin; ! 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.Platform; ! import org.eclipse.core.runtime.Plugin; ! 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.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; ! import org.osgi.framework.Bundle; ! import org.python.parser.ast.If; import org.python.pydev.plugin.PydevPlugin; + /** + * @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) + */ + int docBoundary = -1; // the document prior to the activation token ! int docBoundary2 = 0; ! public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, ! int documentOffset) { ! List propList = new ArrayList(); ! IDocument doc = viewer.getDocument(); ! // System.out.println("The document:"+doc.get()); ! Point selectedRange = viewer.getSelectedRange(); ! // there may not be a selected range ! java.lang.String theDoc = doc.get(); ! calcDocBoundary(theDoc, documentOffset); ! String activationToken = this ! .getActivationToken(theDoc, documentOffset); ! System.out.println("DBG:theActivationToken: " + activationToken); ! theDoc = partialDocument(theDoc, documentOffset); ! java.lang.String qualifier = getQualifier(doc, documentOffset); ! int qlen = qualifier.length(); ! theDoc += "\n"+activationToken; ! System.out.println("Interpreted doc: " + theDoc); ! // System.out.println("activationToken: " + activationToken); ! Vector theList = autoComplete(theDoc, activationToken); ! System.out.println("DBG:vector:" + theList); ! for (Iterator iter = theList.iterator(); iter.hasNext();) { ! String element = (String) iter.next(); + CompletionProposal proposal = new CompletionProposal(element, + documentOffset - qlen, qlen, element.length()); + propList.add(proposal); + } ! ICompletionProposal[] proposals = new ICompletionProposal[propList ! .size()]; ! // and fill with list elements ! propList.toArray(proposals); ! // Return the proposals ! return proposals; ! } ! ! private Vector autoComplete(java.lang.String theCode, ! java.lang.String theActivationToken) { ! Vector theList = new Vector(); ! String s = new String(); ! File tmp = null; ! System.out.println("DBG:autoComplete"); ! try { ! // get the inspect.py file from the package: ! s = getAutoCompleteScript(); ! System.out.println("DBG:getAutoCompleteScript() returns" + s); ! } catch (CoreException e) { ! System.out.println("DBG:getAutoCompleteScript() fails " + e); ! e.printStackTrace(); ! } ! ! // ! try { ! tmp = bufferContent(theCode); ! if (tmp == null) { ! System.out ! .println("DBG:bufferContent() null. No tip for you!!"); ! return theList; ! } ! String ss = new String("python " + s + " " ! + tmp.getAbsolutePath()); ! System.out.println("DBG:exec string " + ss); ! Process p = Runtime.getRuntime().exec(ss); ! BufferedReader in = new BufferedReader(new InputStreamReader(p ! .getInputStream())); ! String str; ! while ((str = in.readLine()) != null) { ! if(!str.startsWith("tip: ")) continue; ! str = str.substring(5); ! System.out.println("DBG:autoComplete:output: " + str); ! theList.add(str); ! } ! in.close(); ! InputStream eInput = p.getErrorStream(); ! BufferedReader eIn = new BufferedReader(new InputStreamReader( ! eInput)); ! ! while ((str = eIn.readLine()) != null) { ! System.out.println("error output: " + str); ! } ! p.waitFor(); ! } catch (IOException e) { ! // TODO Auto-generated catch block ! e.printStackTrace(); ! } catch (InterruptedException e) { ! // TODO Auto-generated catch block ! System.out.println("Interrupted call: error output: "); ! e.printStackTrace(); ! } ! return theList; ! } ! ! /** ! * @param theCode ! */ ! private File bufferContent(java.lang.String theCode) { ! // ! try { ! // Create temp file. ! File temp = File.createTempFile("PyDev", ".tmp"); ! ! // Delete temp file when program exits. ! temp.deleteOnExit(); ! ! // Write to temp file ! BufferedWriter out = new BufferedWriter(new FileWriter(temp)); ! out.write(theCode); ! out.close(); ! return temp; ! } catch (IOException e) { ! return null; ! } ! } ! ! public static String getAutoCompleteScript() throws CoreException { ! String targetExec = "tipper.py"; ! System.out.println("DBG:getAutoCompleteScript();"); ! IPath relative = new Path("PySrc").addTrailingSeparator().append( ! targetExec); ! System.out.println("DBG:getAutoCompleteScript(); relative " + relative); ! Bundle bundle = PydevPlugin.getDefault().getBundle(); ! System.out.println("DBG:getAutoCompleteScript(); bundle " + bundle); ! URL bundleURL = Platform.find(bundle, relative); ! URL fileURL; ! try { ! fileURL = Platform.asLocalURL(bundleURL); ! String filePath = new File(fileURL.getPath()).getAbsolutePath(); ! System.out.println("DBG:getAutoCompleteScript();filePath " ! + filePath); ! return filePath; ! } catch (IOException e) { ! throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR, ! "Can't find python debug script", null)); ! } ! } ! ! /** ! * @param qualifier ! * @param documentOffset ! * @param proposals ! */ ! public void calcDocBoundary(String theDoc, int documentOffset) { ! this.docBoundary = theDoc.substring(0, documentOffset) ! .lastIndexOf('\n'); ! } ! ! public String getActivationToken(String theDoc, int documentOffset) { ! if (this.docBoundary < 0) { ! calcDocBoundary(theDoc, documentOffset); ! } ! return theDoc.substring(this.docBoundary + 1, documentOffset); ! } ! ! /** ! * @param theDoc ! */ ! private String partialDocument(String theDoc, int documentOffset) { ! if (this.docBoundary < 0) { ! calcDocBoundary(theDoc, documentOffset); ! } ! ! String before = theDoc.substring(0, this.docBoundary); ! return before; ! ! } ! ! /** ! * @param doc ! * @param documentOffset ! */ ! private java.lang.String getQualifier(IDocument doc, int documentOffset) { ! // this routine should return any partial entry after the activation ! // character ! return ""; ! } ! ! /* ! * (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 java.lang.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; ! } ! ! } \ No newline at end of file |
From: Dana M. <dan...@us...> - 2004-08-09 21:10:55
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26350/PySrc Modified Files: inspect.py introspect.py jintrospect.py Added Files: debug.py tipper.py Log Message: revamp of the autocompletion code to use only a CPython interpreter --- NEW FILE: debug.py --- import sys debugToggle = 0 def debug(name, value=None): if debugToggle == 0: return if value == None: print >> sys.stderr, "DBG:",name else: print >> sys.stderr, "DBG:%s = %s" % (name, value) Index: introspect.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/introspect.py,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** introspect.py 25 May 2004 21:42:14 -0000 1.2 --- introspect.py 9 Aug 2004 21:10:45 -0000 1.3 *************** *** 18,22 **** import tokenize import types ! from debug import * try: --- 18,22 ---- import tokenize import types ! from debug import debug try: *************** *** 26,54 **** False = 1==0 ! def getAutoCompleteList(command='', locals=None, includeMagic=1, includeSingle=1, includeDouble=1): """Return list of auto-completion options for command. ! The list of options will be based on the locals namespace.""" attributes = [] # Get the proper chunk of code from the command. root = getRoot(command, terminator='.') ! debug( "getAutoCompleteList: root ", root) try: if locals is not None: object = eval(root, locals) ! debug( "getAutoCompleteList: object w locals ", object) else: object = eval(root) ! debug( "getAutoCompleteList: object ", object) except: debug( "getAutoCompleteList: could not eval object ") pass else: ! attributes = getAttributeNames(object, includeMagic, includeSingle, includeDouble) ! debug( "getAutoCompleteList: attributes ", attributes) return attributes ! def getAttributeNames(object, includeMagic=1, includeSingle=1, includeDouble=1): --- 26,55 ---- False = 1==0 ! ! def getAutoCompleteList(command='', locals=None, includeMagic=1, includeSingle=1, includeDouble=1): """Return list of auto-completion options for command. ! The list of options will be based on the locals namespace.""" attributes = [] # Get the proper chunk of code from the command. root = getRoot(command, terminator='.') ! debug( "introspect:getAutoCompleteList: root ", root) try: if locals is not None: object = eval(root, locals) ! debug( "introspect:getAutoCompleteList: object w locals ", object) else: object = eval(root) ! debug( "introspect:getAutoCompleteList: object ", object) except: debug( "getAutoCompleteList: could not eval object ") pass else: ! attributes = getAttributeNames(object, includeMagic, includeSingle, includeDouble) ! debug( "getAutoCompleteList: attributes ", attributes) return attributes ! def getAttributeNames(object, includeMagic=1, includeSingle=1, includeDouble=1): *************** *** 59,64 **** # Add some attributes that don't always get picked up. If # they don't apply, they'll get filtered out at the end. ! attributes += ['__bases__', '__class__', '__dict__', '__name__', ! 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name'] if includeMagic: --- 60,65 ---- # Add some attributes that don't always get picked up. If # they don't apply, they'll get filtered out at the end. ! attributes += ['__bases__', '__class__', '__dict__', '__name__', ! 'func_closure', 'func_code', 'func_defaults', 'func_dict', 'func_doc', 'func_globals', 'func_name'] if includeMagic: *************** *** 82,86 **** attributes = [attribute for attribute in attributes \ if hasattr(object, attribute)] ! debug( "getAttributeNames: attributes ",attributes) return attributes --- 83,87 ---- attributes = [attribute for attribute in attributes \ if hasattr(object, attribute)] ! debug( "getAttributeNames: attributes ",attributes) return attributes *************** *** 90,94 **** def getAllAttributeNames(object): """Return dict of all attributes, including inherited, for an object. ! Recursively walk through a class and all base classes. """ --- 91,95 ---- def getAllAttributeNames(object): """Return dict of all attributes, including inherited, for an object. ! Recursively walk through a class and all base classes. """ *************** *** 149,153 **** def getCallTip(command='', locals=None): """For a command, return a tuple of object name, argspec, tip text. ! The call tip information will be based on the locals namespace.""" calltip = ('', '', '') # object name, argspec, tip text. --- 150,154 ---- def getCallTip(command='', locals=None): """For a command, return a tuple of object name, argspec, tip text. ! The call tip information will be based on the locals namespace.""" calltip = ('', '', '') # object name, argspec, tip text. *************** *** 209,217 **** def getRoot(command, terminator=None): """Return the rightmost root portion of an arbitrary Python command. ! Return only the root portion that can be eval()'d without side effects. The command would normally terminate with a '(' or '.'. The terminator and anything after the terminator will be dropped.""" command = command.split('\n')[-1] #~ print "DBG: command", command --- 210,220 ---- def getRoot(command, terminator=None): """Return the rightmost root portion of an arbitrary Python command. ! Return only the root portion that can be eval()'d without side effects. The command would normally terminate with a '(' or '.'. The terminator and anything after the terminator will be dropped.""" + debug("introspect: getRoot:command >>>", command) + debug("<<< introspect: getRoot:command:") command = command.split('\n')[-1] #~ print "DBG: command", command *************** *** 289,293 **** root = prefix + root ! return root def getTokens(command): --- 292,296 ---- root = prefix + root ! return root def getTokens(command): *************** *** 295,299 **** command = str(command) # In case the command is unicode, which fails. f = cStringIO.StringIO(command) ! # tokens is a list of token tuples, each looking like: # (type, string, (srow, scol), (erow, ecol), line) tokens = [] --- 298,302 ---- command = str(command) # In case the command is unicode, which fails. f = cStringIO.StringIO(command) ! # tokens is a list of token tuples, each looking like: # (type, string, (srow, scol), (erow, ecol), line) tokens = [] *************** *** 315,319 **** # feeding in fragments of Python code. pass ! return tokens def rtrimTerminus(command, terminator=None): --- 318,322 ---- # feeding in fragments of Python code. pass ! return tokens def rtrimTerminus(command, terminator=None): *************** *** 380,381 **** --- 383,422 ---- return constructor return None + + def printAttributes (theDoc, locals): + print "the Doc:", theDoc, '\n' + attributes = getAutoCompleteList(theDoc) + #~ attributes = ['first', 'second' , 'third'] + for a in attributes: + print "attribute:", a + print 'done!' + + theDoc = """ + import sys,os + class AClass: + def __init__(self, attribute): + self.attribute = attribute + def doSomething(self, value): + try: + self.attribute += value + print "attribute >>>", self.attribute + except TypeError: + print 'Error unable to concat ', self.attribute, 'and', value + + + a = AClass('Hello ') + b = 'world' + a.doSomething(b) + a.doSomething(42) + a. + """ + theDoc = """ + import os + os. + """ + theActivation = "a." + if __name__ == '__main__': + import sys,os + #~ printAttributes(sys.argv[1], sys.argv[2]) + printAttributes(theDoc, theActivation) + --- NEW FILE: tipper.py --- import jintrospect from debug import debug from code import InteractiveInterpreter import sys,string class Tipper: BANNER = "Tipper" def __init__(self): # command buffer self.buffer = [] self.locals = {} self.interp = Interpreter(self, self.locals) # add some handles to our objects self.locals['console'] = self def evalText(self, line): """ Triggered when enter is pressed """ #~ offsets = self.__lastLine() #~ text = self.doc.getText(offsets[0], offsets[1]-offsets[0]) #~ text = text[:-1] # chomp \n #~ self.buffer.append(text) self.buffer.append(line) source = "\n".join(self.buffer) more = self.interp.runsource(source) if more: debug("runSource output:", more) else: self.buffer = [] def showCompletions(self, line): # get the display point before writing text # otherwise magicCaretPosition is None debug('showCompletions:line:', line) line = line[:-1] # remove \n debug("showCompletions:self.locals:", self.locals) try: list = jintrospect.getAutoCompleteList(line, self.locals) debug("showCompletions:list:",list) return list except Exception, e: # TODO handle this gracefully print >> sys.stderr, e return def showClosure(self, line): debug('showClosure:line:', line) debug("showClosure:self.locals", self.locals) line = line[:-1] # remove \n (name, argspec, tip) = jintrospect.getCallTipJava(line, self.locals) return (name, argspec, tip) class Interpreter(InteractiveInterpreter): def __init__(self, tipper, locals): InteractiveInterpreter.__init__(self, locals) self.tipper= tipper def write(self, data): print >> sys.stdout, data[:-1] def GenerateTip (theDoc): debug("GenerateTip:theDoc:", theDoc) t = Tipper() theDoc = theDoc.split("\n") while len(theDoc) > 0 and theDoc[len(theDoc)-1] == "": #chomp empty trailers theDoc = theDoc[:-1] activationString = theDoc[len(theDoc)-1] debug("activationString:", activationString) theDoc = theDoc[:-1] for line in theDoc: debug("next line:", line) t.evalText(line) if activationString[len(activationString)-1] != '\n': activationString += '\n' if activationString[len(activationString)-2] == '.': list = t.showCompletions(activationString) for l in list: print >> sys.stdout, "tip:",l debug("GenerateTip:done!!") if activationString[len(activationString)-2] == '(': tuple = t.showClosure("a.doSomething(\n") #~ debug("showClosure:name", tuple[0]) #~ debug("showClosure:argspec", tuple[1]) #~ debug("showClosure:tip", tuple[2]) tip = str(tuple[2]) print >> sys.stdout, "tip:",tip[string.rindex(tip, '(')+1:] if __name__ == '__main__': import sys,os #~ printAttributes(sys.argv[1], sys.argv[2]) f = open (sys.argv[1]) theDoc = f.read() GenerateTip(theDoc) Index: jintrospect.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/jintrospect.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** jintrospect.py 25 May 2004 21:36:56 -0000 1.1 --- jintrospect.py 9 Aug 2004 21:10:45 -0000 1.2 *************** *** 3,28 **** from introspect import * import string ! from debug import * ! __author__ = "Don Coleman <dco...@ch...>" __cvsid__ = "$Id$" ! def getAutoCompleteList(command='', locals=None, includeMagic=1, includeSingle=1, includeDouble=1): """Return list of auto-completion options for command. ! The list of options will be based on the locals namespace.""" attributes = [] # Get the proper chunk of code from the command. root = getRoot(command, terminator='.') ! debug( "JgetAutoCompleteList: root ", root) try: if locals is not None: object = eval(root, locals) else: object = eval(root) except: return attributes ! debug( "JgetAutoCompleteList: object ", object) if ispython(object): # use existing code --- 3,29 ---- from introspect import * import string ! from debug import debug __author__ = "Don Coleman <dco...@ch...>" __cvsid__ = "$Id$" ! def getAutoCompleteList(command='', locals=None, includeMagic=1, includeSingle=1, includeDouble=1): """Return list of auto-completion options for command. ! The list of options will be based on the locals namespace.""" attributes = [] # Get the proper chunk of code from the command. root = getRoot(command, terminator='.') ! debug( "getAutoCompleteList: root ", root) try: if locals is not None: object = eval(root, locals) + debug( "getAutoCompleteList: object w locals ", object) else: object = eval(root) + debug( "getAutoCompleteList:locals is None object ", object) except: return attributes ! if ispython(object): # use existing code *************** *** 31,35 **** methods = methodsOf(object.__class__) attributes = [eachMethod.__name__ for eachMethod in methods] ! return attributes --- 32,36 ---- methods = methodsOf(object.__class__) attributes = [eachMethod.__name__ for eachMethod in methods] ! return attributes *************** *** 70,77 **** except AttributeError: pass ! tipList = [] argspec = '' # not using argspec for Java ! if inspect.isbuiltin(object): # inspect.isbuiltin() fails for Jython --- 71,78 ---- except AttributeError: pass ! tipList = [] argspec = '' # not using argspec for Java ! if inspect.isbuiltin(object): # inspect.isbuiltin() fails for Jython *************** *** 93,97 **** tip = "%s(%s)" % (constructor.name, paramString) tipList.append(tip) ! elif inspect.ismethod(object): method = object --- 94,98 ---- tip = "%s(%s)" % (constructor.name, paramString) tipList.append(tip) ! elif inspect.ismethod(object): method = object *************** *** 106,110 **** for eachParam in eachMethod.parameterTypes: paramList.append(eachParam.__name__) ! paramString = string.join(paramList,', ') --- 107,111 ---- for eachParam in eachMethod.parameterTypes: paramList.append(eachParam.__name__) ! paramString = string.join(paramList,', ') *************** *** 119,123 **** tip = "%s(%s) -> %s" % (eachMethod.name, paramString, eachMethod.returnType) tipList.append(tip) ! # else: # print "Not a java class :(" --- 120,124 ---- tip = "%s(%s) -> %s" % (eachMethod.name, paramString, eachMethod.returnType) tipList.append(tip) ! # else: # print "Not a java class :(" *************** *** 125,129 **** calltip = (name, argspec, string.join(tipList,"\n")) return calltip ! def ispython(object): """ --- 126,130 ---- calltip = (name, argspec, string.join(tipList,"\n")) return calltip ! def ispython(object): """ *************** *** 134,138 **** pycode = 0 pyinstance = 0 ! if inspect.isclass(object): try: --- 135,139 ---- pycode = 0 pyinstance = 0 ! if inspect.isclass(object): try: *************** *** 156,160 **** # print "object", object, "pyclass", pyclass, "pycode", pycode, "returning", pyclass | pycode ! return pyclass | pycode | pyinstance --- 157,201 ---- # print "object", object, "pyclass", pyclass, "pycode", pycode, "returning", pyclass | pycode ! return pyclass | pycode | pyinstance + def printAttributes (theDoc, theActivation): + debug("printAttributes:theDoc:", theDoc) + debug("printAttributes:locals >>>", dir(locals)) + attributes = getAutoCompleteList(theActivation) + #~ attributes = getAutoCompleteList(theDoc) + #~ attributes = ['first', 'second' , 'third'] + debug("ATTRS >>>", attributes) + debug("<<< ATTRS DONE") + for attr in attributes: + print >> sys.stdout, attr + debug('done!') + + theDoc = """ + import sys,os + class AClass: + def __init__(self, attribute): + self.attribute = attribute + def doSomething(self, value): + try: + self.attribute += value + print "attribute >>>", self.attribute + except TypeError: + print 'Error unable to concat ', self.attribute, 'and', value + + + a = AClass('Hello ') + b = 'world' + a.doSomething(b) + a.doSomething(42) + a. + """ + #~ theDoc = """ + #~ import sys + #~ sys. + #~ """ + theActivation = "sys." + if __name__ == '__main__': + import sys,os + #~ printAttributes(sys.argv[1], sys.argv[2]) + printAttributes(theDoc, theActivation) Index: inspect.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/inspect.py,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** inspect.py 25 May 2004 21:36:56 -0000 1.1 --- inspect.py 9 Aug 2004 21:10:45 -0000 1.2 *************** *** 29,33 **** import sys, os, types, string, re, dis, imp, tokenize ! # ----------------------------------------------------------- type-checking def ismodule(object): --- 29,33 ---- import sys, os, types, string, re, dis, imp, tokenize ! from debug import debug # ----------------------------------------------------------- type-checking def ismodule(object): *************** *** 581,585 **** ## We don't have co_code, so skip this for now ! ## ## # The following acrobatics are for anonymous (tuple) arguments. ## for i in range(nargs): --- 581,585 ---- ## We don't have co_code, so skip this for now ! ## ## # The following acrobatics are for anonymous (tuple) arguments. ## for i in range(nargs): |
From: Fabio Z. <fa...@us...> - 2004-08-06 17:20:18
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8585/src/org/python/pydev/editor/templates Added Files: PyTemplatePreferencesPage.java PyContextType.java Log Message: Template proposals added. --- NEW FILE: PyTemplatePreferencesPage.java --- /* * Created on Aug 6, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.editor.templates; import org.eclipse.ui.IWorkbenchPreferencePage; import org.eclipse.ui.texteditor.templates.TemplatePreferencePage; import org.python.pydev.plugin.PydevPlugin; /** * @author Fabio Zadrozny */ public class PyTemplatePreferencesPage extends TemplatePreferencePage implements IWorkbenchPreferencePage { public PyTemplatePreferencesPage() { setPreferenceStore(PydevPlugin.getDefault().getPreferenceStore()); setTemplateStore(PydevPlugin.getDefault().getTemplateStore()); setContextTypeRegistry(PydevPlugin.getDefault().getContextTypeRegistry()); } protected boolean isShowFormatterSetting() { return true; } public boolean performOk() { boolean ok= super.performOk(); PydevPlugin.getDefault().savePluginPreferences(); return ok; } } --- NEW FILE: PyContextType.java --- /* * Created on Aug 6, 2004 * * @author Fabio Zadrozny */ package org.python.pydev.editor.templates; import org.eclipse.jface.text.templates.GlobalTemplateVariables; import org.eclipse.jface.text.templates.TemplateContextType; /** * @author Fabio Zadrozny */ public class PyContextType extends TemplateContextType { public static final String PY_CONTEXT_TYPE = "org.python.pydev.editor.templates.python"; /** * Creates a new XML context type. */ public PyContextType() { addGlobalResolvers(); } private void addGlobalResolvers() { addResolver(new GlobalTemplateVariables.Cursor()); addResolver(new GlobalTemplateVariables.WordSelection()); addResolver(new GlobalTemplateVariables.LineSelection()); addResolver(new GlobalTemplateVariables.Dollar()); addResolver(new GlobalTemplateVariables.Date()); addResolver(new GlobalTemplateVariables.Year()); addResolver(new GlobalTemplateVariables.Time()); addResolver(new GlobalTemplateVariables.User()); } } |
From: Fabio Z. <fa...@us...> - 2004-08-06 17:20:17
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8585/src/org/python/pydev/editor Modified Files: PythonCompletionProcessor.java PyEditConfiguration.java PyEdit.java Log Message: Template proposals added. Index: PyEditConfiguration.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEditConfiguration.java,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** PyEditConfiguration.java 16 Jul 2004 15:31:20 -0000 1.13 --- PyEditConfiguration.java 6 Aug 2004 17:20:02 -0000 1.14 *************** *** 12,15 **** --- 12,16 ---- import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.text.DefaultInformationControl; + import org.eclipse.jface.text.DefaultUndoManager; import org.eclipse.jface.text.IAutoIndentStrategy; import org.eclipse.jface.text.IDocument; *************** *** 17,22 **** --- 18,26 ---- import org.eclipse.jface.text.IInformationControlCreator; import org.eclipse.jface.text.ITextDoubleClickStrategy; + import org.eclipse.jface.text.IUndoManager; 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; *************** *** 36,39 **** --- 40,44 ---- 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; *************** *** 61,64 **** --- 66,73 ---- } + public IUndoManager getUndoManager(ISourceViewer sourceViewer) { + return new DefaultUndoManager(100); + } + /** * Has to return all the types generated by partition scanner. *************** *** 273,285 **** */ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { - return null; - /* final String PY_SINGLELINE_STRING = "__python_singleline_string"; final 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(); ! // No code completion in strings assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_SINGLELINE_STRING ); assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_MULTILINE_STRING ); --- 282,295 ---- */ public IContentAssistant getContentAssistant(ISourceViewer sourceViewer) { final String PY_SINGLELINE_STRING = "__python_singleline_string"; final 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(); ! ! // No code completion in strings assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_SINGLELINE_STRING ); assistant.setContentAssistProcessor(processor,PyPartitionScanner.PY_MULTILINE_STRING ); *************** *** 287,296 **** 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; - */ } --- 297,305 ---- assistant.setInformationControlCreator(getInformationControlCreator(sourceViewer)); // Allow automatic activation after 500 msec ! assistant.enableAutoActivation(false); assistant.setAutoActivationDelay(500); Color bgColor = colorCache.getColor(new RGB(230,255,230)); assistant.setProposalSelectorBackground(bgColor); return assistant; } Index: PyEdit.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PyEdit.java,v retrieving revision 1.19 retrieving revision 1.20 diff -C2 -d -r1.19 -r1.20 *** PyEdit.java 22 Jul 2004 13:27:43 -0000 1.19 --- PyEdit.java 6 Aug 2004 17:20:02 -0000 1.20 *************** *** 33,36 **** --- 33,37 ---- import org.eclipse.ui.texteditor.DefaultRangeIndicator; import org.eclipse.ui.texteditor.IEditorStatusLine; + import org.eclipse.ui.texteditor.ITextEditorActionDefinitionIds; import org.eclipse.ui.texteditor.MarkerUtilities; import org.eclipse.ui.texteditor.TextOperationAction; *************** *** 198,201 **** --- 199,203 ---- private static final String CONTENTASSIST_PROPOSAL_ID = "org.python.pydev.editors.PyEdit.ContentAssistProposal"; + private static final String TEMPLATE_PROPOSALS= "org.python.pydev.editors.PyEdit.TemplateProposalsAction"; /* (non-Javadoc) *************** *** 207,212 **** // 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 --- 209,218 ---- // 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 *************** *** 216,219 **** --- 222,238 ---- setActionActivationCode(CONTENTASSIST_PROPOSAL_ID,' ', -1, SWT.CTRL); + + //template proposals + action= new TextOperationAction( + PydevPlugin.getDefault().getResourceBundle(), + "ContentTemplateProposal", + this, + ISourceViewer.CONTENTASSIST_PROPOSALS); + + action.setActionDefinitionId(ITextEditorActionDefinitionIds.CONTENT_ASSIST_PROPOSALS); + setAction(TEMPLATE_PROPOSALS, action); + markAsStateDependentAction(TEMPLATE_PROPOSALS, true); + + IAction openAction = new PyOpenAction(); setAction(ACTION_OPEN, openAction); Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/PythonCompletionProcessor.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PythonCompletionProcessor.java 19 Jul 2004 18:06:17 -0000 1.7 --- PythonCompletionProcessor.java 6 Aug 2004 17:20:02 -0000 1.8 *************** *** 7,67 **** 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; ! - 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 offset) { ! // TODO Auto-generated method stub ! return null; ! } /* (non-Javadoc) ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#computeContextInformation(org.eclipse.jface.text.ITextViewer, int) */ ! public IContextInformation[] computeContextInformation(ITextViewer viewer, int offset) { ! // TODO Auto-generated method stub ! return null; } /* (non-Javadoc) ! * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getCompletionProposalAutoActivationCharacters() */ ! public char[] getCompletionProposalAutoActivationCharacters() { ! // TODO Auto-generated method stub ! return null; } - /* (non-Javadoc) - * @see org.eclipse.jface.text.contentassist.IContentAssistProcessor#getContextInformationAutoActivationCharacters() - */ - public char[] getContextInformationAutoActivationCharacters() { - // TODO Auto-generated method stub - return null; - } /* (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; - } } ///** --- 7,47 ---- package org.python.pydev.editor; + import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.ITextViewer; import org.eclipse.jface.text.contentassist.IContentAssistProcessor; ! import org.eclipse.jface.text.templates.Template; ! import org.eclipse.jface.text.templates.TemplateCompletionProcessor; ! import org.eclipse.jface.text.templates.TemplateContextType; ! import org.eclipse.swt.graphics.Image; ! import org.python.pydev.editor.templates.PyContextType; ! import org.python.pydev.plugin.PydevPlugin; ! public class PythonCompletionProcessor extends TemplateCompletionProcessor implements IContentAssistProcessor { /* (non-Javadoc) ! * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getTemplates(java.lang.String) */ ! protected Template[] getTemplates(String contextTypeId) { ! return PydevPlugin.getDefault().getTemplateStore().getTemplates(); } /* (non-Javadoc) ! * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getContextType(org.eclipse.jface.text.ITextViewer, org.eclipse.jface.text.IRegion) */ ! protected TemplateContextType getContextType(ITextViewer viewer, IRegion region) { ! return PydevPlugin.getDefault().getContextTypeRegistry().getContextType(PyContextType.PY_CONTEXT_TYPE); } /* (non-Javadoc) ! * @see org.eclipse.jface.text.templates.TemplateCompletionProcessor#getImage(org.eclipse.jface.text.templates.Template) */ ! protected Image getImage(Template template) { // TODO Auto-generated method stub return null; } } ///** |
From: Fabio Z. <fa...@us...> - 2004-08-06 17:20:17
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8585 Modified Files: .classpath plugin.xml Log Message: Template proposals added. Index: .classpath =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/.classpath,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** .classpath 2 Jul 2004 02:50:37 -0000 1.8 --- .classpath 6 Aug 2004 17:20:03 -0000 1.9 *************** *** 1,5 **** <?xml version="1.0" encoding="UTF-8"?> <classpath> ! <classpathentry excluding="org/python/pydev/editor/PythonCompletionProcessor.java" kind="src" path="src"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> --- 1,5 ---- <?xml version="1.0" encoding="UTF-8"?> <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"/> Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** plugin.xml 22 Jul 2004 14:08:51 -0000 1.25 --- plugin.xml 6 Aug 2004 17:20:03 -0000 1.26 *************** *** 4,8 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.3" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 4,8 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.7.2" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> *************** *** 84,87 **** --- 84,92 ---- id="org.python.pydev.prefs.debugPage"> </page> + <page + class="org.python.pydev.editor.templates.PyTemplatePreferencesPage" + category="org.python.pydev.prefs" + name="Templates" + id="org.python.pydev.prefs.template"/> </extension> <!-- Editor menus --> *************** *** 574,577 **** --- 579,615 ---- </filter> </extension> + <extension + point="org.eclipse.ui.editors.templates"> + <contextType + class="org.python.pydev.editor.templates.PyContextType" + id="org.python.pydev.editor.templates.python"/> + <template + name="pd" + icon="icons/template.gif" + description="pdb" + contextTypeId="org.python.pydev.editor.templates.python" + id="org.python.pydev.editor.templates.python.pdb"> + <pattern>import pdb;pdb.set_trace</pattern> + </template> + <template + name="eq" + icon="icons/template.gif" + description="equals and not equals" + contextTypeId="org.python.pydev.editor.templates.python" + id="org.python.pydev.editor.templates.python.eq"> + <pattern> + def __eq__(self,o): + if isintance(o, self.__class__): + pass + #TODO:class checking + + return False + + def __ne__(self,o): + return not self == o + </pattern> + </template> + + </extension> </plugin> |
From: Fabio Z. <fa...@us...> - 2004-08-06 17:20:17
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8585/src/org/python/pydev/plugin Modified Files: PydevPlugin.java Log Message: Template proposals added. Index: PydevPlugin.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PydevPlugin.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PydevPlugin.java 2 Jul 2004 02:50:38 -0000 1.9 --- PydevPlugin.java 6 Aug 2004 17:20:03 -0000 1.10 *************** *** 1,4 **** --- 1,5 ---- package org.python.pydev.plugin; + import java.io.IOException; import java.util.MissingResourceException; import java.util.ResourceBundle; *************** *** 12,15 **** --- 13,18 ---- import org.eclipse.core.runtime.Preferences; import org.eclipse.core.runtime.Status; + import org.eclipse.jface.text.templates.ContextTypeRegistry; + import org.eclipse.jface.text.templates.persistence.TemplateStore; import org.eclipse.ui.IEditorDescriptor; import org.eclipse.ui.IEditorInput; *************** *** 19,25 **** import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; ! import org.eclipse.ui.ide.IDE; /** --- 22,31 ---- import org.eclipse.ui.PartInitException; import org.eclipse.ui.PlatformUI; + import org.eclipse.ui.editors.text.templates.ContributionContextTypeRegistry; + import org.eclipse.ui.editors.text.templates.ContributionTemplateStore; + import org.eclipse.ui.ide.IDE; import org.eclipse.ui.plugin.AbstractUIPlugin; import org.osgi.framework.BundleContext; ! import org.python.pydev.editor.templates.PyContextType; /** *************** *** 35,38 **** --- 41,51 ---- private ResourceBundle resourceBundle; //Resource bundle. + /** The template store. */ + private TemplateStore fStore; + /** The context type registry. */ + private ContributionContextTypeRegistry fRegistry=null; + /** Key to store custom templates. */ + private static final String CUSTOM_TEMPLATES_PY_KEY = "org.python.pydev.editor.templates.PyTemplatePreferencesPage"; + /** * The constructor. *************** *** 140,142 **** --- 153,188 ---- } } + + /** + * Returns this plug-in's template store. + * + * @return the template store of this plug-in instance + */ + public TemplateStore getTemplateStore() { + if (fStore == null) { + fStore= new ContributionTemplateStore(getContextTypeRegistry(), getPreferenceStore(), CUSTOM_TEMPLATES_PY_KEY); + try { + fStore.load(); + } catch (IOException e) { + e.printStackTrace(); + throw new RuntimeException(e); + } + } + return fStore; + } + + /** + * Returns this plug-in's context type registry. + * + * @return the context type registry for this plug-in instance + */ + public ContextTypeRegistry getContextTypeRegistry() { + if (fRegistry == null) { + // create an configure the contexts available in the template editor + fRegistry= new ContributionContextTypeRegistry(); + fRegistry.addContextType(PyContextType.PY_CONTEXT_TYPE); + } + return fRegistry; + } + } |
From: Fabio Z. <fa...@us...> - 2004-08-06 17:20:12
|
Update of /cvsroot/pydev/org.python.pydev/icons In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8585/icons Added Files: template.gif Log Message: Template proposals added. --- NEW FILE: template.gif --- (This appears to be a binary file; contents omitted.) |
From: Fabio Z. <fa...@us...> - 2004-08-06 17:20:02
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/templates In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8547/src/org/python/pydev/editor/templates Log Message: Directory /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/templates added to the repository |
From: Fabio Z. <fa...@us...> - 2004-08-06 11:20:08
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codefolding In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7236/src/org/python/pydev/editor/codefolding Modified Files: CodeFoldingSetter.java Log Message: new code folding strategy. Index: CodeFoldingSetter.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codefolding/CodeFoldingSetter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** CodeFoldingSetter.java 4 Aug 2004 13:18:43 -0000 1.3 --- CodeFoldingSetter.java 6 Aug 2004 11:19:58 -0000 1.4 *************** *** 205,217 **** } - // for (int j = i+1; j < nodes.size(); j++) { - // AbstractNode curr = (AbstractNode) nodes.get(j); - // System.out.println("getStartColumn(curr) "+getStartColumn(curr)+" start "+start); - // if (getStartColumn(curr) <= start){ - // end = curr.getEnd().line; - // return end; - // } - // } - return end; } --- 205,208 ---- |
From: Fabio Z. <fa...@us...> - 2004-08-04 13:18:52
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codefolding In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19863/src/org/python/pydev/editor/codefolding Modified Files: CodeFoldingSetter.java Log Message: Code folding strategy changed (still has bug in multiline). Index: CodeFoldingSetter.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codefolding/CodeFoldingSetter.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** CodeFoldingSetter.java 22 Jul 2004 13:27:31 -0000 1.2 --- CodeFoldingSetter.java 4 Aug 2004 13:18:43 -0000 1.3 *************** *** 11,14 **** --- 11,15 ---- import org.eclipse.jface.text.BadLocationException; import org.eclipse.jface.text.IDocument; + import org.eclipse.jface.text.IRegion; import org.eclipse.jface.text.Position; import org.eclipse.jface.text.source.IAnnotationModel; *************** *** 17,20 **** --- 18,22 ---- import org.eclipse.ui.IPropertyListener; import org.python.pydev.editor.PyEdit; + import org.python.pydev.editor.actions.PyAction; import org.python.pydev.editor.model.AbstractNode; import org.python.pydev.editor.model.ClassNode; *************** *** 47,51 **** if (model == null){ //we have to get the model to do it... so, start a thread and try until get it... ! //this had to be done because sometime we get here and we still are unable to get the //projection annotation model. (there should be a better way, but this solves it... //even if it looks like a hack...) --- 49,53 ---- if (model == null){ //we have to get the model to do it... so, start a thread and try until get it... ! //this had to be done because sometimes we get here and we still are unable to get the //projection annotation model. (there should be a better way, but this solves it... //even if it looks like a hack...) *************** *** 91,102 **** //(re) insert annotations. AbstractNode current = ModelUtils.getNextNode(root); while (current != null) { if (current instanceof FunctionNode || current instanceof ClassNode) { ! addFoldingMark(current, model, collapsed); } current = ModelUtils.getNextNode(current); } //remove the annotations that have not been reinserted. for (Iterator it = collapsed.iterator(); it.hasNext();) { --- 93,110 ---- //(re) insert annotations. AbstractNode current = ModelUtils.getNextNode(root); + + ArrayList nodes = new ArrayList(); + while (current != null) { if (current instanceof FunctionNode || current instanceof ClassNode) { ! nodes.add(current); } current = ModelUtils.getNextNode(current); } + addMarks(nodes,model, collapsed); + + //remove the annotations that have not been reinserted. for (Iterator it = collapsed.iterator(); it.hasNext();) { *************** *** 111,127 **** /** ! * @param node * @param model - * @throws BadLocationException */ ! private void addFoldingMark(AbstractNode node, IAnnotationModel model, ArrayList collapsed) throws BadLocationException { ! int start = node.getStart().line; ! int end = start; ! int size = node.getChildren().size(); ! if(size > 0){ ! end = ((AbstractNode)node.getChildren().get(size-1)).getScope().getEnd().line+1; }else{ ! throw new BadLocationException("Invalid location"); } try { --- 119,227 ---- /** ! * To add a mark, we have to do the following: ! * ! * Get the current node to add and find the next that is on the same indentation ! * or on an indentation that is lower than the current (this will mark the ! * end of the selection). ! * ! * If we don't find that, the end of the selection is the end of the file. ! * ! * @param nodes ! * @param collapsed * @param model */ ! private void addMarks(ArrayList nodes, IAnnotationModel model, ArrayList collapsed) { ! int i=0; ! ! IDocument doc = editor.getDocumentProvider().getDocument(editor.getEditorInput()); ! ! for (Iterator iter = nodes.iterator(); iter.hasNext();++i) { ! ! AbstractNode element = (AbstractNode) iter.next(); ! int end = findEnd(element, nodes, i, doc); ! int start = element.getStart().line; ! if (end == -1){ ! end = start; ! } ! try { ! addFoldingMark(element, start, end, model, collapsed); ! } catch (BadLocationException e) { ! e.printStackTrace(); ! } ! } ! } ! ! /** ! * @param element ! */ ! private int getStartColumn(AbstractNode element) { ! int start = element.getStart().column; ! if (element instanceof FunctionNode){ ! return start-4; //this is the 'def ' token ! }else if( element instanceof ClassNode){ ! return start-6; //this is the 'class ' token }else{ ! throw new RuntimeException("Invalid class"); } + + } + + /** + * @param element + * @param nodes + * @param i + * @param doc + */ + private int findEnd(AbstractNode element, ArrayList nodes, int m, IDocument doc) { + int end = -1; + + int start = getStartColumn(element); + + //we are interested in getting the next code that is not a comment and that + //starts in the same or lower indentation level. + int line = element.getStart().line; + int endDocLine = doc.getNumberOfLines(); + try { + for(int i=line+1; i<endDocLine; ++i){ + + + IRegion region; + region = doc.getLineInformation(i); + String src = doc.get(region.getOffset(), region.getLength()); + //we have to ignore comments and whitespaces. + String trimmed = src.trim(); + if(trimmed.length() == 0 || trimmed.startsWith("#")){ + continue; + } + //TODO: check for multiline strings. + + int position = PyAction.getFirstCharRelativePosition(doc, region); + if (position <= start){ + return i; + } + } + } catch (BadLocationException e) { + e.printStackTrace(); + } + + // for (int j = i+1; j < nodes.size(); j++) { + // AbstractNode curr = (AbstractNode) nodes.get(j); + // System.out.println("getStartColumn(curr) "+getStartColumn(curr)+" start "+start); + // if (getStartColumn(curr) <= start){ + // end = curr.getEnd().line; + // return end; + // } + // } + + return end; + } + + + /** + * @param node + * @param model + * @throws BadLocationException + */ + private void addFoldingMark(AbstractNode node, int start, int end, IAnnotationModel model, ArrayList collapsed) throws BadLocationException { try { |
From: Fabio Z. <fa...@us...> - 2004-08-04 13:18:51
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19863/src/org/python/pydev/editor/actions Modified Files: PyAction.java Log Message: Code folding strategy changed (still has bug in multiline). Index: PyAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyAction.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PyAction.java 29 Jul 2004 12:43:02 -0000 1.7 --- PyAction.java 4 Aug 2004 13:18:43 -0000 1.8 *************** *** 152,159 **** * @throws BadLocationException */ ! protected int getFirstCharRelativePosition(IDocument doc, int cursorOffset) throws BadLocationException { IRegion region; region = doc.getLineInformationOfOffset(cursorOffset); ! int offset = region.getOffset(); String src = doc.get(offset, region.getLength()); --- 152,181 ---- * @throws BadLocationException */ ! public static int getFirstCharRelativePosition(IDocument doc, int cursorOffset) throws BadLocationException { IRegion region; region = doc.getLineInformationOfOffset(cursorOffset); ! return getFirstCharRelativePosition(doc, region); ! } ! ! /** ! * @param doc ! * @param cursorOffset ! * @return ! * @throws BadLocationException ! */ ! public static int getFirstCharRelativeLinePosition(IDocument doc, int line) throws BadLocationException { ! IRegion region; ! region = doc.getLineInformation(line); ! return getFirstCharRelativePosition(doc, region); ! } ! ! /** ! * @param doc ! * @param region ! * @return ! * @throws BadLocationException ! */ ! public static int getFirstCharRelativePosition(IDocument doc, IRegion region) throws BadLocationException { ! int offset = region.getOffset(); String src = doc.get(offset, region.getLength()); |
From: Fabio Z. <fa...@us...> - 2004-07-29 12:43:13
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28899/src/org/python/pydev/editor/actions Modified Files: PyAction.java Log Message: changed getDelimiter to public. Index: PyAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyAction.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyAction.java 16 Jul 2004 15:34:39 -0000 1.6 --- PyAction.java 29 Jul 2004 12:43:02 -0000 1.7 *************** *** 60,64 **** * @throws BadLocationException */ ! protected static String getDelimiter(IDocument doc, int startLineIndex) throws BadLocationException { String endLineDelim = doc.getLineDelimiter(startLineIndex); --- 60,64 ---- * @throws BadLocationException */ ! public static String getDelimiter(IDocument doc, int startLineIndex) throws BadLocationException { String endLineDelim = doc.getLineDelimiter(startLineIndex); |
From: Aleksandar T. <at...@us...> - 2004-07-25 13:54:00
|
Update of /cvsroot/pydev/org.python.pydev.debug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18380 Modified Files: plugin.xml Log Message: Added debugger launch timeout preference Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/plugin.xml,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** plugin.xml 16 Jul 2004 15:40:29 -0000 1.13 --- plugin.xml 25 Jul 2004 13:53:51 -0000 1.14 *************** *** 4,8 **** id="org.python.pydev.debug" name="Pydev debug" ! version="0.5" provider-name="Aleks Totic" class="org.python.pydev.debug.core.PydevDebugPlugin"> --- 4,8 ---- id="org.python.pydev.debug" name="Pydev debug" ! version="0.5.3" provider-name="Aleks Totic" class="org.python.pydev.debug.core.PydevDebugPlugin"> |
From: Aleksandar T. <at...@us...> - 2004-07-25 13:53:59
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18380/src/org/python/pydev/debug/ui/launching Modified Files: PythonRunnerConfig.java Log Message: Added debugger launch timeout preference Index: PythonRunnerConfig.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/ui/launching/PythonRunnerConfig.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** PythonRunnerConfig.java 6 Jul 2004 17:52:07 -0000 1.7 --- PythonRunnerConfig.java 25 Jul 2004 13:53:51 -0000 1.8 *************** *** 23,26 **** --- 23,27 ---- import org.python.pydev.debug.core.Constants; import org.python.pydev.debug.core.PydevDebugPlugin; + import org.python.pydev.plugin.PydevPrefs; /** *************** *** 54,57 **** --- 55,59 ---- IPath workingPath = ExternalToolsUtil.getWorkingDirectory(conf); workingDirectory = workingPath == null ? null : workingPath.toFile(); + acceptTimeout = PydevPrefs.getPreferences().getInt(PydevPrefs.CONNECT_TIMEOUT); if (isDebug) { debugScript = getDebugScript(); |
From: Aleksandar T. <at...@us...> - 2004-07-25 13:52:53
|
Update of /cvsroot/pydev/org.python.pydev.help In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18277 Modified Files: plugin.xml Log Message: Docs to 0.5.3 Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.help/plugin.xml,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** plugin.xml 11 May 2004 11:02:05 -0000 1.3 --- plugin.xml 25 Jul 2004 13:52:42 -0000 1.4 *************** *** 3,7 **** id="org.python.pydev.help" name="Pydev Online Help" ! version="0.4.0" provider-name="Aleks Totic"> --- 3,7 ---- id="org.python.pydev.help" name="Pydev Online Help" ! version="0.5.3" provider-name="Aleks Totic"> |
From: Aleksandar T. <at...@us...> - 2004-07-25 13:52:53
|
Update of /cvsroot/pydev/org.python.pydev.help/pydev.sf.net In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18277/pydev.sf.net Modified Files: index.html Log Message: Docs to 0.5.3 Index: index.html =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.help/pydev.sf.net/index.html,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** index.html 11 May 2004 11:02:05 -0000 1.1 --- index.html 25 Jul 2004 13:52:42 -0000 1.2 *************** *** 13,17 **** <legend>About</legend> <p>Pydev is a project to create a complete python development environment for eclipse: syntax highlighting, ! outline view, code navigation, debugger integration. The current release is 0.4. Both editor and debugger require Java 1.4.x. Editor runs on Eclipse 2.1.x, and 3.x, while debugger is not compatible with Eclipse 3 yet. Pydev consists of 3 plugins:</p> <p><b><a href="snap.gif">Editor</a></b> (org.python.pydev): </p> <li>syntax highlighting --- 13,17 ---- <legend>About</legend> <p>Pydev is a project to create a complete python development environment for eclipse: syntax highlighting, ! outline view, code navigation, debugger integration. The current release is 0.5.3. Both editor and debugger require Java 1.4.x. and Eclipse 3.0. If you are running Eclipse 2.1.x, use 0.4.2. Pydev consists of 3 plugins:</p> <p><b><a href="snap.gif">Editor</a></b> (org.python.pydev): </p> <li>syntax highlighting *************** *** 22,25 **** --- 22,26 ---- <li>comment/uncomment commands (on the popup menu) </li> <li> hyperlinks over functions//import statements</li> + <li>code folding </li> <p><b><a href="images/debugger.gif">Debugger</a></b> (org.python.pydev.debug)</p> <li>breakpoints</li> *************** *** 33,39 **** You can download the releases from there, or from an Eclipse update site <a href="http://pydev.sf.net/updates/">http://pydev.sf.net/updates/</a>. Developer issues are discussed at <a href="http://sourceforge.net/mailarchive/forum.php?forum_id=39082">pydev-code</a> mailing list. For support, try the <a href="http://sourceforge.net/forum/forum.php?forum_id=293649">users</a> bulletin board. I sometimes post tidbits about the development progress in the <a href="http://blogs.osafoundation.org/atotic/cat_work_log.html">weblog</a>. ! <p>Most of the pydev has been developed by Aleks Totic as a "getting to know Eclipse" project, with some wonderful help from Fabio Zadrozny. </fieldset> <p> <fieldset> <legend>Development notes</legend> --- 34,58 ---- You can download the releases from there, or from an Eclipse update site <a href="http://pydev.sf.net/updates/">http://pydev.sf.net/updates/</a>. Developer issues are discussed at <a href="http://sourceforge.net/mailarchive/forum.php?forum_id=39082">pydev-code</a> mailing list. For support, try the <a href="http://sourceforge.net/forum/forum.php?forum_id=293649">users</a> bulletin board. I sometimes post tidbits about the development progress in the <a href="http://blogs.osafoundation.org/atotic/cat_work_log.html">weblog</a>. ! <p>Most of the pydev has been developed by Aleks Totic as a "getting to know Eclipse" project, with some wonderful help from Fabio "Foldin" Zadrozny. </fieldset> + <fieldset> + <legend><a name="debug"></a>Debugging the debugger</legend> <p> + The current release of the debugger is of alpha quality. + <li>I wrote the + whole thing from scratch. + <li>I am not very familiar with python internals. + <li>I have not used it daily + <p>These three reasons add up to something which is an alpha. For some users, it works + great, the others do not get beyond the launch. If you'd like to help me on the road to beta, please + file detailed bug reports. With your bug reports, attach the trace of the debugger. + To get the trace, you need to edit debugger source:</p> + <p>Inside eclipse/plugins/org.python.pydev.debug/pysrc/pydevd.py, change + <pre>pydevd_trace = 0</pre> + to + <pre>pydevd_trace = 2</pre> + Now, when you launch the debugger, you'll get a lot of tracing output. Attach this + to your bug reports. + </fieldset> <fieldset> <legend>Development notes</legend> *************** *** 64,71 **** <b>Future</b> My plans for the future are: ! - 0.5 will be a bug-fix release, I am sure there are a few, there has been a lot of new ! code between 0.3 & 0.4. ! - 1.0 will be an Eclipse 3.0 compatibility release. There are some new debugger features ! like an environment tab that are cheap to implement, and very useful. And that's it. Over & out, off to new projects. --- 83,88 ---- <b>Future</b> My plans for the future are: ! - Wrap up the production of 1.0. We are feature complete, and as soon as I ! like the quality, I'll release the code under 1.0 banner. And that's it. Over & out, off to new projects. *************** *** 118,123 **** As for me, I have several possible projects coming up. I might do something with Mozilla guys. I am also thinking of developing a family tree web site that my family ! could use. Of course, there is no web site software out there I am happy with, so ! it'd involve writing a whole new web ui development system. Or I might do some work with startups, or something completely different. Life is never boring. Well, coding gets boring every once in a while, but I am just such an amateur when it comes --- 135,140 ---- As for me, I have several possible projects coming up. I might do something with Mozilla guys. I am also thinking of developing a family tree web site that my family ! could use. Of course, there is no CMS system out there I am happy with, so ! it'd involve writing a whole new one. Or I might do some work with startups, or something completely different. Life is never boring. Well, coding gets boring every once in a while, but I am just such an amateur when it comes |
From: Aleksandar T. <at...@us...> - 2004-07-25 13:51:48
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18166/src/org/python/pydev/plugin Modified Files: DebugPrefsPage.java PydevPrefs.java Log Message: Added debugger launch timeout preference Index: PydevPrefs.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/PydevPrefs.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PydevPrefs.java 19 Jul 2004 19:50:57 -0000 1.10 --- PydevPrefs.java 25 Jul 2004 13:51:39 -0000 1.11 *************** *** 66,70 **** public static final String DEFAULT_BLOCK_COMMENT_STRING = "================================================================================"; public static final boolean DEFAULT_BLOCK_COMMENT = true; ! /** * Initializer sets the preference store --- 66,73 ---- public static final String DEFAULT_BLOCK_COMMENT_STRING = "================================================================================"; public static final boolean DEFAULT_BLOCK_COMMENT = true; ! ! public static final String CONNECT_TIMEOUT = "CONNECT_TIMEOUT"; ! public static final int DEFAULT_CONNECT_TIMEOUT = 20000; ! /** * Initializer sets the preference store *************** *** 119,123 **** COMMENT_COLOR, "Comments", p)); ! StringFieldEditor sfe = new StringFieldEditor ( BLOCK_COMMENT, "Block comment separator", p ); addField(sfe); } --- 122,126 ---- COMMENT_COLOR, "Comments", p)); ! StringFieldEditor sfe = new StringFieldEditor ( BLOCK_COMMENT, "Block comment separator", 40, StringFieldEditor.VALIDATE_ON_FOCUS_LOST ,p ); addField(sfe); } *************** *** 138,141 **** --- 141,145 ---- prefs.setDefault(HYPERLINK_COLOR, StringConverter.asString(DEFAULT_HYPERLINK_COLOR)); prefs.setDefault(BLOCK_COMMENT, DEFAULT_BLOCK_COMMENT_STRING); + prefs.setDefault(CONNECT_TIMEOUT, DEFAULT_CONNECT_TIMEOUT); } } Index: DebugPrefsPage.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/plugin/DebugPrefsPage.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** DebugPrefsPage.java 15 Apr 2004 23:19:22 -0000 1.1 --- DebugPrefsPage.java 25 Jul 2004 13:51:39 -0000 1.2 *************** *** 8,11 **** --- 8,12 ---- import org.eclipse.core.runtime.Preferences; import org.eclipse.jface.preference.FieldEditorPreferencePage; + import org.eclipse.jface.preference.IntegerFieldEditor; import org.eclipse.swt.widgets.Composite; import org.eclipse.ui.IWorkbench; *************** *** 48,51 **** --- 49,55 ---- PydevPrefs.INTERPRETER_PATH, "Python interpreters (for example python.exe)", p); addField(pathEditor); + IntegerFieldEditor ife = new IntegerFieldEditor(PydevPrefs.CONNECT_TIMEOUT, "Connect timeout (ms)", p, 1); + ife.setValidRange(1000, 200000); + addField(ife); } |
From: Aleksandar T. <at...@us...> - 2004-07-25 13:51:48
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18166 Modified Files: .project Log Message: Added debugger launch timeout preference Index: .project =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/.project,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** .project 2 Jul 2004 02:50:37 -0000 1.5 --- .project 25 Jul 2004 13:51:39 -0000 1.6 *************** *** 25,28 **** --- 25,29 ---- <nature>org.eclipse.pde.PluginNature</nature> <nature>org.eclipse.jdt.core.javanature</nature> + <nature>org.python.pydev.pythonNature</nature> </natures> </projectDescription> |
From: Fabio Z. <fa...@us...> - 2004-07-22 16:15:02
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/parser In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6070/src/org/python/pydev/parser Modified Files: PyParser.java Log Message: event.getText could return null on Ctrl+X Index: PyParser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/parser/PyParser.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyParser.java 2 Jul 2004 02:50:38 -0000 1.8 --- PyParser.java 22 Jul 2004 16:14:53 -0000 1.9 *************** *** 27,191 **** import org.python.pydev.editor.PyEdit; - /** ! * PyParser uses org.python.parser to parse the document ! * (lexical analysis) ! * It is attached to PyEdit (a view), and it listens to document changes ! * On every document change, the syntax tree is regenerated ! * The reparsing of the document is done on a ParsingThread * ! * Clients that need to know when new parse tree has been generated ! * should register as parseListeners. */ - public class PyParser { - - IDocument document; - PyEdit editorView; - SimpleNode root = null; // Document root - - IDocumentListener documentListener; // listens to changes in the document - ArrayList parserListeners; // listeners that get notified - - final static int PARSE_LATER_INTERVAL = 20; // 20 = 2 seconds ! boolean parseNow = false; // synchronized access by ParsingThread ! /* counter how to parse. ! * 0 means do not parse, > 0 means wait this many loops in main thread ! */ ! int parseLater = 0; // synchronized access by ParsingThread ! public PyParser(PyEdit editorView) { ! this.editorView = editorView; ! parserListeners = new ArrayList(); ! ParsingThread.getParsingThread().register(this); ! } ! public void parseNow() { ! parseNow = true; ! } ! ! public void parseLater() { ! parseNow = false; ! parseLater = PARSE_LATER_INTERVAL; // delay of 1 second ! } ! public void dispose() { ! // remove the listeners ! if (document != null) ! document.removeDocumentListener(documentListener); ! parserListeners.clear(); ! ParsingThread.getParsingThread().unregister(this); ! } ! ! public SimpleNode getRoot() { ! return root; ! } ! public void setDocument(IDocument document) { ! // Cleans up old listeners ! if (this.document != null) { ! document.removeDocumentListener(documentListener); ! } ! ! // Set up new listener ! this.document = document; ! if (document == null) { ! System.err.println("No document in PyParser::setDocument?"); ! return; ! } ! final PyParser parser = this; ! documentListener = new IDocumentListener() { ! public void documentChanged(DocumentEvent event) { ! if (event.getText().indexOf("\n") == -1) ! // carriage return in changed text means parse now, anything else means parse later ! parseLater(); ! else ! parseNow(); ! } ! public void documentAboutToBeChanged(DocumentEvent event) {} ! }; ! document.addDocumentListener(documentListener); ! // Reparse document on the initial set ! parseNow(); ! } ! /** stock listener implementation */ ! public void addParseListener(IParserListener listener) { ! Assert.isNotNull(listener); ! if (! parserListeners.contains(listener)) ! parserListeners.add(listener); ! } ! ! /** stock listener implementation */ ! public void removeParseListener(IParserListener listener) { ! Assert.isNotNull(listener); ! parserListeners.remove(listener); ! } ! /** ! * stock listener implementation ! * 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); ! Iterator e= list.iterator(); ! while (e.hasNext()) { ! IParserListener l= (IParserListener) e.next(); ! l.parserChanged(root); ! } ! } ! } ! ! /** ! * stock listener implementation ! * event is fired when parse fails ! */ ! protected void fireParserError(Throwable error) { ! if (parserListeners.size() > 0) { ! ArrayList list= new ArrayList(parserListeners); ! Iterator e= list.iterator(); ! while (e.hasNext()) { ! IParserListener l= (IParserListener) e.next(); ! l.parserError(error); ! } ! } ! } ! /** ! * Parses the document, generates error annotations ! */ ! void reparseDocument() { ! // create a stream with document's data ! StringReader inString = new StringReader(document.get()); ! ReaderCharStream in = new ReaderCharStream(inString); ! IParserHost host = new CompilerAPI(); ! ! PythonGrammar g1 = new PythonGrammar((CharStream)null, (IParserHost)null); ! ! PythonGrammar grammar = new PythonGrammar(in, host); ! ! IEditorInput input = editorView.getEditorInput(); ! if (input == null) ! return; ! IFile original= (input instanceof IFileEditorInput) ? ((IFileEditorInput) input).getFile() : null; ! try { ! SimpleNode newRoot = grammar.file_input(); // parses the file ! if (original != null) ! original.deleteMarkers(IMarker.PROBLEM, false, 1); ! fireParserChanged(newRoot); ! } catch (ParseException parseErr) { ! fireParserError(parseErr); ! } ! catch (TokenMgrError tokenErr) { ! fireParserError(tokenErr); ! }catch (Exception e) { ! System.err.println("Unexpected parse error"); ! e.printStackTrace(); ! } ! } } --- 27,197 ---- import org.python.pydev.editor.PyEdit; /** ! * PyParser uses org.python.parser to parse the document (lexical analysis) It ! * is attached to PyEdit (a view), and it listens to document changes On every ! * document change, the syntax tree is regenerated The reparsing of the document ! * is done on a ParsingThread * ! * Clients that need to know when new parse tree has been generated should ! * register as parseListeners. */ public class PyParser { ! IDocument document; ! PyEdit editorView; ! SimpleNode root = null; // Document root ! IDocumentListener documentListener; // listens to changes in the document ! ArrayList parserListeners; // listeners that get notified ! final static int PARSE_LATER_INTERVAL = 20; // 20 = 2 seconds ! boolean parseNow = false; // synchronized access by ParsingThread ! /* ! * counter how to parse. 0 means do not parse, > 0 means wait this many ! * loops in main thread ! */ ! int parseLater = 0; // synchronized access by ParsingThread ! ! public PyParser(PyEdit editorView) { ! this.editorView = editorView; ! parserListeners = new ArrayList(); ! ParsingThread.getParsingThread().register(this); ! } ! ! public void parseNow() { ! parseNow = true; ! } ! ! public void parseLater() { ! parseNow = false; ! parseLater = PARSE_LATER_INTERVAL; // delay of 1 second ! } ! ! public void dispose() { ! // remove the listeners ! if (document != null) ! document.removeDocumentListener(documentListener); ! parserListeners.clear(); ! ParsingThread.getParsingThread().unregister(this); ! } ! ! public SimpleNode getRoot() { ! return root; ! } ! ! public void setDocument(IDocument document) { ! // Cleans up old listeners ! if (this.document != null) { ! document.removeDocumentListener(documentListener); ! } ! ! // Set up new listener ! this.document = document; ! if (document == null) { ! System.err.println("No document in PyParser::setDocument?"); ! return; ! } ! final PyParser parser = this; ! documentListener = new IDocumentListener() { ! public void documentChanged(DocumentEvent event) { ! if (event == null || event.getText() == null || event.getText().indexOf("\n") == -1) { ! // carriage return in changed text means parse now, anything ! // else means parse later ! parseLater(); ! } else { ! parseNow(); ! } ! } ! ! public void documentAboutToBeChanged(DocumentEvent event) { ! } ! }; ! document.addDocumentListener(documentListener); ! // Reparse document on the initial set ! parseNow(); ! } ! ! /** stock listener implementation */ ! public void addParseListener(IParserListener listener) { ! Assert.isNotNull(listener); ! if (!parserListeners.contains(listener)) ! parserListeners.add(listener); ! } ! ! /** stock listener implementation */ ! public void removeParseListener(IParserListener listener) { ! Assert.isNotNull(listener); ! parserListeners.remove(listener); ! } ! ! /** ! * stock listener implementation 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); ! Iterator e = list.iterator(); ! while (e.hasNext()) { ! IParserListener l = (IParserListener) e.next(); ! l.parserChanged(root); ! } ! } ! } ! ! /** ! * stock listener implementation event is fired when parse fails ! */ ! protected void fireParserError(Throwable error) { ! if (parserListeners.size() > 0) { ! ArrayList list = new ArrayList(parserListeners); ! Iterator e = list.iterator(); ! while (e.hasNext()) { ! IParserListener l = (IParserListener) e.next(); ! l.parserError(error); ! } ! } ! } ! ! /** ! * Parses the document, generates error annotations ! */ ! void reparseDocument() { ! // create a stream with document's data ! StringReader inString = new StringReader(document.get()); ! ReaderCharStream in = new ReaderCharStream(inString); ! IParserHost host = new CompilerAPI(); ! ! PythonGrammar g1 = new PythonGrammar((CharStream) null, ! (IParserHost) null); ! ! PythonGrammar grammar = new PythonGrammar(in, host); ! ! IEditorInput input = editorView.getEditorInput(); ! if (input == null) ! return; ! IFile original = (input instanceof IFileEditorInput) ? ((IFileEditorInput) input) ! .getFile() ! : null; ! try { ! SimpleNode newRoot = grammar.file_input(); // parses the file ! if (original != null) ! original.deleteMarkers(IMarker.PROBLEM, false, 1); ! fireParserChanged(newRoot); ! } catch (ParseException parseErr) { ! fireParserError(parseErr); ! } catch (TokenMgrError tokenErr) { ! fireParserError(tokenErr); ! } catch (Exception e) { ! System.err.println("Unexpected parse error"); ! e.printStackTrace(); ! } ! } } *************** *** 195,277 **** * Singleton. * ! * Current algorithm is: ! * - if parseLater is called, parse 10 main loops later ! * - if parseNow is called, parse immediately */ class ParsingThread extends Thread { - - private static ParsingThread thread = null; - private static ArrayList parsers = new ArrayList(); // synchronized access only - - private boolean done = false; - - private ParsingThread() { - setName("Pydev parsing thread"); - } - - static public ParsingThread getParsingThread() { - synchronized(ParsingThread.class) { - if (thread == null) { - thread = new ParsingThread(); - thread.start(); - } - return thread; - } - } ! public void register(PyParser parser) { ! synchronized(parsers) { ! parsers.add(parser); ! } ! } ! ! public void unregister(PyParser parser) { ! synchronized(parsers) { ! parser.parseNow = false; ! parser.parseLater = 0; ! parsers.remove(parser); ! if (parsers.size() == 0) { ! done = true; ! thread = null; ! } ! } ! } ! ! public void run() { ! // wait for document change, and reparse ! try { ! while (!done) { ! ArrayList parseUs = new ArrayList(); ! ! // Populate the list of parsers waiting to be parsed ! synchronized(parsers) { ! Iterator i = parsers.iterator(); ! while (i.hasNext()) { ! PyParser p = (PyParser)i.next(); ! p.parseLater--; ! if (p.parseLater == 1) ! p.parseNow = true; ! if (p.parseNow) ! parseUs.add(p); ! } ! } ! ! // Now parse the queue ! Iterator i = parseUs.iterator(); ! while (i.hasNext()) { ! PyParser p = (PyParser)i.next(); ! if (p.parseNow) { ! p.parseNow = false; ! p.parseLater = 0; ! p.reparseDocument(); ! } ! } ! sleep(100); // sleep a bit, to avoid flicker ! } ! } catch (InterruptedException e) { ! } finally { ! if (thread == this) ! thread = null; ! } ! } ! } --- 201,285 ---- * Singleton. * ! * Current algorithm is: - if parseLater is called, parse 10 main loops later - ! * if parseNow is called, parse immediately */ + class ParsingThread extends Thread { ! private static ParsingThread thread = null; ! ! private static ArrayList parsers = new ArrayList(); // synchronized access ! // only ! ! private boolean done = false; ! ! private ParsingThread() { ! setName("Pydev parsing thread"); ! } ! ! static public ParsingThread getParsingThread() { ! synchronized (ParsingThread.class) { ! if (thread == null) { ! thread = new ParsingThread(); ! thread.start(); ! } ! return thread; ! } ! } ! ! public void register(PyParser parser) { ! synchronized (parsers) { ! parsers.add(parser); ! } ! } ! ! public void unregister(PyParser parser) { ! synchronized (parsers) { ! parser.parseNow = false; ! parser.parseLater = 0; ! parsers.remove(parser); ! if (parsers.size() == 0) { ! done = true; ! thread = null; ! } ! } ! } ! ! public void run() { ! // wait for document change, and reparse ! try { ! while (!done) { ! ArrayList parseUs = new ArrayList(); ! ! // Populate the list of parsers waiting to be parsed ! synchronized (parsers) { ! Iterator i = parsers.iterator(); ! while (i.hasNext()) { ! PyParser p = (PyParser) i.next(); ! p.parseLater--; ! if (p.parseLater == 1) ! p.parseNow = true; ! if (p.parseNow) ! parseUs.add(p); ! } ! } ! ! // Now parse the queue ! Iterator i = parseUs.iterator(); ! while (i.hasNext()) { ! PyParser p = (PyParser) i.next(); ! if (p.parseNow) { ! p.parseNow = false; ! p.parseLater = 0; ! p.reparseDocument(); ! } ! } ! sleep(100); // sleep a bit, to avoid flicker ! } ! } catch (InterruptedException e) { ! } finally { ! if (thread == this) ! thread = null; ! } ! } ! } \ No newline at end of file |