pydev-cvs Mailing List for PyDev for Eclipse (Page 300)
Brought to you by:
fabioz
You can subscribe to this list here.
2004 |
Jan
|
Feb
(4) |
Mar
(48) |
Apr
(56) |
May
(64) |
Jun
(27) |
Jul
(66) |
Aug
(81) |
Sep
(148) |
Oct
(194) |
Nov
(78) |
Dec
(46) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2005 |
Jan
(125) |
Feb
(126) |
Mar
(163) |
Apr
(133) |
May
(115) |
Jun
(307) |
Jul
(387) |
Aug
(417) |
Sep
(283) |
Oct
(148) |
Nov
(45) |
Dec
(53) |
2006 |
Jan
(240) |
Feb
(200) |
Mar
(267) |
Apr
(231) |
May
(245) |
Jun
(361) |
Jul
(142) |
Aug
(12) |
Sep
(210) |
Oct
(99) |
Nov
(7) |
Dec
(30) |
2007 |
Jan
(161) |
Feb
(511) |
Mar
(265) |
Apr
(74) |
May
(147) |
Jun
(151) |
Jul
(94) |
Aug
(68) |
Sep
(98) |
Oct
(144) |
Nov
(26) |
Dec
(36) |
2008 |
Jan
(98) |
Feb
(107) |
Mar
(199) |
Apr
(113) |
May
(119) |
Jun
(112) |
Jul
(92) |
Aug
(71) |
Sep
(101) |
Oct
(16) |
Nov
|
Dec
|
From: Aleksandar T. <at...@us...> - 2004-09-28 19:44:56
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28173 Modified Files: plugin.xml Log Message: 0.6.1 Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.45 retrieving revision 1.46 diff -C2 -d -r1.45 -r1.46 *** plugin.xml 24 Sep 2004 18:08:52 -0000 1.45 --- plugin.xml 28 Sep 2004 19:44:45 -0000 1.46 *************** *** 4,8 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.6" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 4,8 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.6.1" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> |
From: Fabio Z. <fa...@us...> - 2004-09-28 18:19:26
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8868/src/org/python/pydev/editor/codecompletion Modified Files: PyCodeCompletion.java Log Message: Index: PyCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PyCodeCompletion.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PyCodeCompletion.java 24 Sep 2004 16:41:21 -0000 1.11 --- PyCodeCompletion.java 28 Sep 2004 18:19:17 -0000 1.12 *************** *** 100,104 **** docToParse); }else{ ! Scope scope = closest.getScope().findContainingClass(); String token = scope.getStartNode().getName(); completions = serverShell --- 100,104 ---- docToParse); }else{ ! Scope scope = closest.getScope().findContainingClass(); //null returned if self. within a method and not in a class. String token = scope.getStartNode().getName(); completions = serverShell |
From: Fabio Z. <fa...@us...> - 2004-09-27 18:39:59
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12008/src/org/python/pydev/editor/codecompletion Modified Files: PythonShell.java Log Message: Index: PythonShell.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PythonShell.java,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** PythonShell.java 27 Sep 2004 18:39:14 -0000 1.11 --- PythonShell.java 27 Sep 2004 18:39:49 -0000 1.12 *************** *** 146,152 **** int attempts = 0; while(!connected && attempts < 20){ attempts += 1; - sleepALittle(milisSleep); try { socketToWrite = new Socket("127.0.0.1",pWrite); //we should write in this port --- 146,152 ---- int attempts = 0; + sleepALittle(200); while(!connected && attempts < 20){ attempts += 1; try { socketToWrite = new Socket("127.0.0.1",pWrite); //we should write in this port *************** *** 157,160 **** --- 157,161 ---- PydevPlugin.log(IStatus.ERROR, "Attempt: "+attempts+" of 20 failed, trying again...", e1); } + sleepALittle(milisSleep); } |
From: Fabio Z. <fa...@us...> - 2004-09-27 18:39:25
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11877/src/org/python/pydev/editor/codecompletion Modified Files: PythonShell.java Log Message: Changed msg... Index: PythonShell.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PythonShell.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PythonShell.java 24 Sep 2004 19:23:49 -0000 1.10 --- PythonShell.java 27 Sep 2004 18:39:14 -0000 1.11 *************** *** 155,159 **** connected = true; } catch (IOException e1) { ! PydevPlugin.log(IStatus.ERROR, "Error starting server", e1); } } --- 155,159 ---- connected = true; } catch (IOException e1) { ! PydevPlugin.log(IStatus.ERROR, "Attempt: "+attempts+" of 20 failed, trying again...", e1); } } |
From: Fabio Z. <fa...@us...> - 2004-09-27 18:31:28
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv10414/src/org/python/pydev/editor/actions/refactoring Modified Files: PyRefactorAction.java Log Message: Index: PyRefactorAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring/PyRefactorAction.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyRefactorAction.java 24 Sep 2004 16:41:12 -0000 1.5 --- PyRefactorAction.java 27 Sep 2004 18:31:11 -0000 1.6 *************** *** 123,127 **** PyEdit e = (PyEdit) ed; if (e != edit) { ! refreshEditor(e); } } --- 123,130 ---- PyEdit e = (PyEdit) ed; if (e != edit) { ! try { ! refreshEditor(e); ! } catch (Exception e1) { ! } } } |
From: Fabio Z. <fa...@us...> - 2004-09-27 18:27:22
|
Update of /cvsroot/pydev/org.python.pydev/PySrc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9553/PySrc Modified Files: pycompletionserver.py Log Message: Removed the C:\temp dependency... Index: pycompletionserver.py =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/PySrc/pycompletionserver.py,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** pycompletionserver.py 20 Sep 2004 19:08:41 -0000 1.11 --- pycompletionserver.py 27 Sep 2004 18:27:10 -0000 1.12 *************** *** 205,218 **** if __name__ == '__main__': #let's log this!! ! import os ! f = 'c:/temp/pydev.log' ! i=0 ! while os.path.exists(f): ! f = 'c:/temp/pydev%s.log' % i ! i+=1 ! ! out = open(f, 'w') ! sys.stdout = out ! sys.stderr = out thisPort = int(sys.argv[1]) #this is from where we want to receive messages. --- 205,218 ---- if __name__ == '__main__': #let's log this!! ! # import os ! # f = 'c:/temp/pydev.log' ! # i=0 ! # while os.path.exists(f): ! # f = 'c:/temp/pydev%s.log' % i ! # i+=1 ! # ! # out = open(f, 'w') ! # sys.stdout = out ! # sys.stderr = out thisPort = int(sys.argv[1]) #this is from where we want to receive messages. *************** *** 220,224 **** t = T(thisPort, serverPort) ! print 'will start' t.start() --- 220,224 ---- t = T(thisPort, serverPort) ! # print 'will start' t.start() |
From: Fabio Z. <fa...@us...> - 2004-09-24 19:24:49
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv14016/src/org/python/pydev/editor/correctionassist Modified Files: PythonCorrectionProcessor.java Log Message: adding self on class methods Index: PythonCorrectionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist/PythonCorrectionProcessor.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PythonCorrectionProcessor.java 24 Sep 2004 16:41:12 -0000 1.3 --- PythonCorrectionProcessor.java 24 Sep 2004 19:24:39 -0000 1.4 *************** *** 105,109 **** } ! String params = "("+getInsideParentesisTok(ps)+")"; int firstCharPosition = PyAction.getFirstCharRelativePosition(ps.doc, ps.absoluteCursorOffset); --- 105,109 ---- } ! String params = getInsideParentesisTok(ps); int firstCharPosition = PyAction.getFirstCharRelativePosition(ps.doc, ps.absoluteCursorOffset); *************** *** 113,120 **** String delim = PyAction.getDelimiter(ps.doc, 0); String cls = "class "+callName+":"+delim+delim; ! cls += indentation+"def __init__"+params+":"+delim; cls += indentation+indentation+"pass"+delim; ! String method = "def "+callName+params+":"+delim+indentation+"pass"+delim; if (firstCharPosition == 0){ //we are in the global context --- 113,126 ---- String delim = PyAction.getDelimiter(ps.doc, 0); String cls = "class "+callName+":"+delim+delim; ! ! String self = "self"; ! if(params.trim().length() != 0){ ! self += ", "; ! } ! ! cls += indentation+"def __init__("+self+params+"):"+delim; cls += indentation+indentation+"pass"+delim; ! String method = "def "+callName+"(%s"+params+"):"+delim+indentation+"pass"+delim; if (firstCharPosition == 0){ //we are in the global context *************** *** 130,133 **** --- 136,140 ---- "Create new class (global context)", null, null)); + method = method.replaceFirst("%s", ""); l.add(new CompletionProposal(method, newPos, 0, method.length()+1, null, "Create new method (global context)", null, null)); *************** *** 173,176 **** --- 180,185 ---- method = atStart+method+delim; + method = method.replaceFirst("%s", self); + l.add(new CompletionProposal(method, newPos, 0, method.length()-4, null, "Create new method (in class)", null, null)); |
From: Fabio Z. <fa...@us...> - 2004-09-24 19:23:59
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13822/src/org/python/pydev/editor/codecompletion Modified Files: PythonShell.java Log Message: Changes to server, was hanging if too many completions were returned... That is, if the namespace is too polluted...ehhehehe Index: PythonShell.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PythonShell.java,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** PythonShell.java 24 Sep 2004 16:41:21 -0000 1.9 --- PythonShell.java 24 Sep 2004 19:23:49 -0000 1.10 *************** *** 212,216 **** public String read(Operation operation) throws IOException { String str = ""; ! int j = 0; while(j != 100){ --- 212,216 ---- public String read(Operation operation) throws IOException { String str = ""; ! String tempStr = ""; int j = 0; while(j != 100){ *************** *** 248,253 **** break; }else{ ! j++; sleepALittle(10); } --- 248,259 ---- break; }else{ ! ! if(tempStr.equals(str) == true){ //only raise if nothing was received. ! j++; ! }else{ ! j = 0; //we are receiving, even though that may take a long time if the namespace is really polluted... ! } sleepALittle(10); + tempStr = str; } *************** *** 258,264 **** //remove END@@ try { ! str = str.substring(0, str.lastIndexOf("END@@")); ! return str; } catch (RuntimeException e) { PydevPlugin.log(IStatus.ERROR, "ERROR WITH STRING:"+str, e); return ""; --- 264,278 ---- //remove END@@ try { ! if(str.indexOf("END@@")!= -1){ ! str = str.substring(0, str.indexOf("END@@")); ! return str; ! }else{ ! throw new RuntimeException("Couldn't find END@@ on received string."); ! } } catch (RuntimeException e) { + e.printStackTrace(); + if(str.length() > 1000){ + str = str.substring(0, 999)+"...(continued)...";//if the string gets too big, it can crash Eclipse... + } PydevPlugin.log(IStatus.ERROR, "ERROR WITH STRING:"+str, e); return ""; |
From: Fabio Z. <fa...@us...> - 2004-09-24 18:09:03
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv993 Modified Files: plugin.xml Log Message: Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.44 retrieving revision 1.45 diff -C2 -d -r1.44 -r1.45 *** plugin.xml 24 Sep 2004 00:37:48 -0000 1.44 --- plugin.xml 24 Sep 2004 18:08:52 -0000 1.45 *************** *** 745,753 **** point="org.eclipse.ui.ide.markerResolution"> <markerResolutionGenerator ! class="org.python.pydev.editor.markers.PyQuickFix" markerType="org.eclipse.core.resources.problemmarker"/> - <markerResolutionGenerator - markerType="org.python.pydev.editor.markers.pycontentgeneratormarker" - class="org.python.pydev.editor.markers.PyContentGenerator"/> </extension> --- 745,750 ---- point="org.eclipse.ui.ide.markerResolution"> <markerResolutionGenerator ! class="org.python.pydev.editor.correctionassist.PyQuickFix" markerType="org.eclipse.core.resources.problemmarker"/> </extension> |
From: Aleksandar T. <at...@us...> - 2004-09-24 17:50:20
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30105/src/org/python/pydev/editor/actions Removed Files: PyStripTrailingWhitespace.java Log Message: Remove obsolete files --- PyStripTrailingWhitespace.java DELETED --- |
From: Fabio Z. <fa...@us...> - 2004-09-24 16:41:51
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15928/src/org/python/pydev/editor/actions/refactoring Modified Files: PyRefactorAction.java Log Message: Decoration support / Making correction assistant on Ctrl+1 Index: PyRefactorAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/refactoring/PyRefactorAction.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** PyRefactorAction.java 22 Sep 2004 12:04:30 -0000 1.4 --- PyRefactorAction.java 24 Sep 2004 16:41:12 -0000 1.5 *************** *** 242,249 **** --- 242,252 ---- restartRefactorShell(); String[] strings = operation.statusOfOperation.split("DETAILS:"); + if (strings.length == 2) { + IStatus status = new Status(IStatus.ERROR, PydevPlugin .getPluginID(), 0, strings[0], new Exception(strings[0])); + ErrorDialog.openError(getPyEditShell(), "ERROR", strings[0], status); |
From: Fabio Z. <fa...@us...> - 2004-09-24 16:41:51
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codefolding In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15928/src/org/python/pydev/editor/codefolding Modified Files: PyEditProjection.java Log Message: Decoration support / Making correction assistant on Ctrl+1 Index: PyEditProjection.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codefolding/PyEditProjection.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** PyEditProjection.java 23 Sep 2004 17:59:58 -0000 1.5 --- PyEditProjection.java 24 Sep 2004 16:41:11 -0000 1.6 *************** *** 46,50 **** protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { ! return new PySourceViewer(parent, ruler, getOverviewRuler(), true, styles, this); } --- 46,52 ---- protected ISourceViewer createSourceViewer(Composite parent, IVerticalRuler ruler, int styles) { ! PySourceViewer viewer = new PySourceViewer(parent, ruler, getOverviewRuler(), true, styles, this); ! getSourceViewerDecorationSupport(viewer); ! return viewer; } |
From: Fabio Z. <fa...@us...> - 2004-09-24 16:41:50
|
Update of /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15928/tests/org/python/pydev/editor/codecompletion Modified Files: PythonShellTest.java Log Message: Decoration support / Making correction assistant on Ctrl+1 Index: PythonShellTest.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/tests/org/python/pydev/editor/codecompletion/PythonShellTest.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PythonShellTest.java 17 Sep 2004 19:22:03 -0000 1.3 --- PythonShellTest.java 24 Sep 2004 16:41:10 -0000 1.4 *************** *** 8,18 **** import java.io.File; import java.io.IOException; - import java.util.Iterator; import java.util.List; - import org.eclipse.core.runtime.CoreException; - import junit.framework.TestCase; /** * @author Fabio Zadrozny --- 8,17 ---- import java.io.File; import java.io.IOException; import java.util.List; import junit.framework.TestCase; + import org.eclipse.core.runtime.CoreException; + /** * @author Fabio Zadrozny *************** *** 48,60 **** String str = "import math\n"; List list = shell.getGlobalCompletions(str); - for (Iterator iter = list.iterator(); iter.hasNext();) { - Object[] element = (Object[]) iter.next(); - assertEquals("math", element[0]); - assertEquals( - "This module is always available. It provides access to the\n" - + "mathematical functions defined by the C standard.", - element[1]); ! } } --- 47,63 ---- String str = "import math\n"; List list = shell.getGlobalCompletions(str); ! Object[] element = null; ! ! element = (Object[]) list.get(0); ! assertEquals("math", element[0]); ! assertEquals( ! "This module is always available. It provides access to the\n" ! + "mathematical functions defined by the C standard.", ! element[1]); ! ! element = (Object[]) list.get(1); ! assertEquals("__builtins__", element[0]); ! } *************** *** 75,82 **** assertEquals(1, list.size()); Object object[] = (Object[]) list.get(0); ! assertEquals("ERROR_COMPLETING", object[0]); } ! public void testOther() { String str = getTestStr(); --- 78,85 ---- assertEquals(1, list.size()); Object object[] = (Object[]) list.get(0); ! assertEquals("ERROR:", object[0]); } ! public void testOther() throws CoreException { String str = getTestStr(); |
From: Fabio Z. <fa...@us...> - 2004-09-24 16:41:31
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15928/src/org/python/pydev/editor/codecompletion Modified Files: PythonShell.java PythonCompletionProcessor.java PyCodeCompletion.java CompletionCache.java Log Message: Decoration support / Making correction assistant on Ctrl+1 Index: PythonShell.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PythonShell.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PythonShell.java 20 Sep 2004 13:18:05 -0000 1.8 --- PythonShell.java 24 Sep 2004 16:41:21 -0000 1.9 *************** *** 17,21 **** --- 17,23 ---- import org.eclipse.core.runtime.CoreException; + import org.eclipse.core.runtime.IStatus; import org.python.pydev.editor.actions.refactoring.PyRefactorAction.Operation; + import org.python.pydev.plugin.PydevPlugin; import org.python.pydev.plugin.PydevPrefs; import org.python.pydev.plugin.SocketUtil; *************** *** 127,132 **** * @param milisSleep: time to wait after creating the process. * @throws IOException is some error happens creating the sockets - the process is terminated. */ ! public void startIt(int milisSleep) throws IOException{ try { --- 129,135 ---- * @param milisSleep: time to wait after creating the process. * @throws IOException is some error happens creating the sockets - the process is terminated. + * @throws CoreException */ ! public void startIt(int milisSleep) throws IOException, CoreException{ try { *************** *** 136,143 **** if(process != null) endIt(); ! process = Runtime.getRuntime().exec(PydevPrefs.getDefaultInterpreter()+" "+serverFile.getAbsolutePath()+" "+pWrite+" "+pRead); boolean connected = false; int attempts = 0; while(!connected && attempts < 20){ attempts += 1; --- 139,149 ---- if(process != null) endIt(); ! String interpreter = getDefaultInterpreter(); ! String execMsg = interpreter+" "+serverFile.getAbsolutePath()+" "+pWrite+" "+pRead; ! process = Runtime.getRuntime().exec(execMsg); boolean connected = false; int attempts = 0; + while(!connected && attempts < 20){ attempts += 1; *************** *** 149,155 **** connected = true; } catch (IOException e1) { ! //e1.printStackTrace(); } } } catch (IOException e) { --- 155,168 ---- connected = true; } catch (IOException e1) { ! PydevPlugin.log(IStatus.ERROR, "Error starting server", e1); } } + + if(!connected){ + //what, after all this trouble we are still not connected????!?!?!?! + //let's communicate this to the user... + throw new CoreException(PydevPlugin.makeStatus(IStatus.ERROR, "Error creating python process ("+execMsg+")", new Exception("Error creating python process."))); + } + } catch (IOException e) { *************** *** 158,162 **** } process = null; - //e.printStackTrace(); throw e; } --- 171,174 ---- *************** *** 164,173 **** /** * This method creates the python server process and starts the sockets, so that we * can talk with the server. ! * ! * @throws IOException is some error happens creating the sockets - the process is terminated. */ ! public void startIt() throws IOException{ this.startIt(25); } --- 176,197 ---- /** + * @return + */ + protected String getDefaultInterpreter() { + try { + return PydevPrefs.getDefaultInterpreter(); + } catch (RuntimeException e) { + return "python"; + } + } + + + /** * This method creates the python server process and starts the sockets, so that we * can talk with the server. ! * @throws IOException ! * @throws CoreException */ ! public void startIt() throws IOException, CoreException{ this.startIt(25); } *************** *** 237,242 **** return str; } catch (RuntimeException e) { ! System.out.println("ERROR WITH STRING:"+str); ! e.printStackTrace(); return ""; } --- 261,265 ---- return str; } catch (RuntimeException e) { ! PydevPlugin.log(IStatus.ERROR, "ERROR WITH STRING:"+str, e); return ""; } *************** *** 343,347 **** } catch (IOException e) { ! e.printStackTrace(); } } --- 366,370 ---- } catch (IOException e) { ! PydevPlugin.log(IStatus.ERROR, "ERROR sending go to dir msg.", e); } } *************** *** 353,357 **** } catch (IOException e) { ! e.printStackTrace(); } } --- 376,380 ---- } catch (IOException e) { ! PydevPlugin.log(IStatus.ERROR, "ERROR sending reload modules msg.", e); } } *************** *** 359,365 **** /** * @param str * @throws IOException */ ! public List getGlobalCompletions(String str) { str = URLEncoder.encode(str); return this.getTheCompletions("@@GLOBALS:"+str+"\nEND@@"); --- 382,389 ---- /** * @param str + * @throws CoreException * @throws IOException */ ! public List getGlobalCompletions(String str) throws CoreException { str = URLEncoder.encode(str); return this.getTheCompletions("@@GLOBALS:"+str+"\nEND@@"); *************** *** 368,374 **** /** * @param str * @throws IOException */ ! public List getTokenCompletions(String token, String str) { token = URLEncoder.encode(token); str = URLEncoder.encode(str); --- 392,399 ---- /** * @param str + * @throws CoreException * @throws IOException */ ! public List getTokenCompletions(String token, String str) throws CoreException { token = URLEncoder.encode(token); str = URLEncoder.encode(str); *************** *** 381,386 **** * @param docToParse * @return */ ! public List getClassCompletions(String token, String str) { token = URLEncoder.encode(token); str = URLEncoder.encode(str); --- 406,412 ---- * @param docToParse * @return + * @throws CoreException */ ! public List getClassCompletions(String token, String str) throws CoreException { token = URLEncoder.encode(token); str = URLEncoder.encode(str); *************** *** 392,402 **** * @param importsTipper * @return */ ! public List getImportCompletions(String str) { str = URLEncoder.encode(str); return this.getTheCompletions("@@IMPORTS:"+str+"\nEND@@"); } ! private List getTheCompletions(String str){ try { this.write(str); --- 418,429 ---- * @param importsTipper * @return + * @throws CoreException */ ! public List getImportCompletions(String str) throws CoreException { str = URLEncoder.encode(str); return this.getTheCompletions("@@IMPORTS:"+str+"\nEND@@"); } ! private List getTheCompletions(String str) throws CoreException{ try { this.write(str); *************** *** 404,408 **** return getCompletions(); } catch (Exception e) { ! e.printStackTrace(); restartShell(); --- 431,435 ---- return getCompletions(); } catch (Exception e) { ! PydevPlugin.log(IStatus.ERROR, "ERROR getting completions.", e); restartShell(); *************** *** 412,427 **** /** * */ ! public void restartShell() { try { this.endIt(); ! } catch (Exception e2) { ! e2.printStackTrace(); } try { this.startIt(); ! } catch (IOException e2) { ! e2.printStackTrace(); } } --- 439,454 ---- /** + * @throws CoreException * */ ! public void restartShell() throws CoreException { try { this.endIt(); ! } catch (Exception e) { } try { this.startIt(); ! } catch (IOException e) { ! PydevPlugin.log(IStatus.ERROR, "ERROR restarting shell.", e); } } Index: PyCodeCompletion.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PyCodeCompletion.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** PyCodeCompletion.java 22 Sep 2004 16:32:41 -0000 1.10 --- PyCodeCompletion.java 24 Sep 2004 16:41:21 -0000 1.11 *************** *** 65,71 **** * @param theActivationToken * @return */ public List autoComplete(PyEdit edit, IDocument doc, int documentOffset, ! java.lang.String theActivationToken) { List theList = new ArrayList(); PythonShell serverShell = null; --- 65,72 ---- * @param theActivationToken * @return + * @throws CoreException */ public List autoComplete(PyEdit edit, IDocument doc, int documentOffset, ! java.lang.String theActivationToken) throws CoreException { List theList = new ArrayList(); PythonShell serverShell = null; Index: PythonCompletionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/PythonCompletionProcessor.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PythonCompletionProcessor.java 23 Sep 2004 18:00:01 -0000 1.8 --- PythonCompletionProcessor.java 24 Sep 2004 16:41:21 -0000 1.9 *************** *** 10,13 **** --- 10,15 ---- import java.util.List; + import org.eclipse.core.runtime.CoreException; + import org.eclipse.jface.dialogs.ErrorDialog; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.ITextViewer; *************** *** 56,123 **** public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { ! IDocument doc = viewer.getDocument(); ! Point selectedRange = viewer.getSelectedRange(); ! // there may not be a selected range ! java.lang.String completeDoc = doc.get(); ! codeCompletion.calcDocBoundary(completeDoc, documentOffset); ! String activationToken = codeCompletion.getActivationToken(completeDoc, documentOffset); ! java.lang.String qualifier = ""; ! //we complete on '.' and '('. ! //' ' gets globals ! //and any other char gets globals on token and templates. ! //we have to get the qualifier. e.g. bla.foo = foo is the qualifier. ! if (activationToken.indexOf('.') != -1) { ! while (endsWithSomeChar(new char[] { '.' }, activationToken) == false ! && activationToken.length() > 0) { ! qualifier = activationToken.charAt(activationToken.length() - 1) + qualifier; ! activationToken = activationToken.substring(0, activationToken.length() - 1); } - } else { //everything is a part of the qualifier. - qualifier = activationToken.trim(); - activationToken = ""; - } ! int qlen = qualifier.length(); ! try { ! PythonShell.getServerShell().sendGoToDirMsg(edit.getEditorFile()); ! } catch (Exception e) { ! //if we don't suceed, we don't have to fail... just go on and try ! // to complete... ! e.printStackTrace(); ! } ! List pythonProposals = getPythonProposals(documentOffset, doc, activationToken, qlen); ! List templateProposals = getTemplateProposals(viewer, documentOffset, activationToken, qualifier, ! pythonProposals); ! ArrayList pythonAndTemplateProposals = new ArrayList(); ! pythonAndTemplateProposals.addAll(pythonProposals); ! pythonAndTemplateProposals.addAll(templateProposals); ! ArrayList returnProposals = new ArrayList(); ! for (Iterator iter = pythonAndTemplateProposals.iterator(); iter.hasNext();) { ! ICompletionProposal proposal = (ICompletionProposal) iter.next(); ! if (proposal.getDisplayString().startsWith(qualifier)) { ! returnProposals.add(proposal); } - } - - ICompletionProposal[] proposals = new ICompletionProposal[returnProposals.size()]; ! // and fill with list elements ! returnProposals.toArray(proposals); ! Arrays.sort(proposals, proposalsComparator); ! // Return the proposals ! return proposals; } --- 58,130 ---- public ICompletionProposal[] computeCompletionProposals(ITextViewer viewer, int documentOffset) { ! try { ! IDocument doc = viewer.getDocument(); ! Point selectedRange = viewer.getSelectedRange(); ! // there may not be a selected range ! java.lang.String completeDoc = doc.get(); ! codeCompletion.calcDocBoundary(completeDoc, documentOffset); ! String activationToken = codeCompletion.getActivationToken(completeDoc, documentOffset); ! java.lang.String qualifier = ""; ! //we complete on '.' and '('. ! //' ' gets globals ! //and any other char gets globals on token and templates. ! //we have to get the qualifier. e.g. bla.foo = foo is the qualifier. ! if (activationToken.indexOf('.') != -1) { ! while (endsWithSomeChar(new char[] { '.' }, activationToken) == false ! && activationToken.length() > 0) { ! qualifier = activationToken.charAt(activationToken.length() - 1) + qualifier; ! activationToken = activationToken.substring(0, activationToken.length() - 1); ! } ! } else { //everything is a part of the qualifier. ! qualifier = activationToken.trim(); ! activationToken = ""; } ! int qlen = qualifier.length(); ! try { ! PythonShell.getServerShell().sendGoToDirMsg(edit.getEditorFile()); ! } catch (Exception e) { ! //if we don't suceed, we don't have to fail... just go on and try ! // to complete... ! e.printStackTrace(); ! } ! List pythonProposals = getPythonProposals(documentOffset, doc, activationToken, qlen); ! List templateProposals = getTemplateProposals(viewer, documentOffset, activationToken, qualifier, ! pythonProposals); ! ArrayList pythonAndTemplateProposals = new ArrayList(); ! pythonAndTemplateProposals.addAll(pythonProposals); ! pythonAndTemplateProposals.addAll(templateProposals); ! ArrayList returnProposals = new ArrayList(); ! for (Iterator iter = pythonAndTemplateProposals.iterator(); iter.hasNext();) { ! ICompletionProposal proposal = (ICompletionProposal) iter.next(); ! if (proposal.getDisplayString().startsWith(qualifier)) { ! returnProposals.add(proposal); ! } } ! ICompletionProposal[] proposals = new ICompletionProposal[returnProposals.size()]; ! // and fill with list elements ! returnProposals.toArray(proposals); + Arrays.sort(proposals, proposalsComparator); + // Return the proposals + return proposals; + } catch (CoreException e) { + + ErrorDialog.openError(null,"Error", "Error", e.getStatus()); + } + return new ICompletionProposal[0]; } *************** *** 129,134 **** * @param qlen * @return */ ! private List getPythonProposals(int documentOffset, IDocument doc, String activationToken, int qlen) { List allProposals = this.completionCache.getAllProposals(edit, doc, activationToken, documentOffset, qlen, codeCompletion); --- 136,142 ---- * @param qlen * @return + * @throws CoreException */ ! private List getPythonProposals(int documentOffset, IDocument doc, String activationToken, int qlen) throws CoreException { List allProposals = this.completionCache.getAllProposals(edit, doc, activationToken, documentOffset, qlen, codeCompletion); Index: CompletionCache.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/codecompletion/CompletionCache.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** CompletionCache.java 22 Sep 2004 16:32:41 -0000 1.5 --- CompletionCache.java 24 Sep 2004 16:41:21 -0000 1.6 *************** *** 12,15 **** --- 12,16 ---- import java.util.Map; + import org.eclipse.core.runtime.CoreException; import org.eclipse.jface.text.IDocument; import org.eclipse.jface.text.contentassist.CompletionProposal; *************** *** 36,43 **** * @param codeCompletion * @return */ public List getAllProposals(PyEdit edit, IDocument doc, String activationToken, int documentOffset, int qlen, ! PyCodeCompletion codeCompletion) { String importsTipperStr = codeCompletion.getImportsTipperStr(activationToken, edit, doc, documentOffset); --- 37,45 ---- * @param codeCompletion * @return + * @throws CoreException */ public List getAllProposals(PyEdit edit, IDocument doc, String activationToken, int documentOffset, int qlen, ! PyCodeCompletion codeCompletion) throws CoreException { String importsTipperStr = codeCompletion.getImportsTipperStr(activationToken, edit, doc, documentOffset); |
From: Fabio Z. <fa...@us...> - 2004-09-24 16:41:31
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15928/src/org/python/pydev/editor/actions Modified Files: PyBackspace.java Log Message: Decoration support / Making correction assistant on Ctrl+1 Index: PyBackspace.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyBackspace.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PyBackspace.java 16 Jul 2004 15:33:54 -0000 1.1 --- PyBackspace.java 24 Sep 2004 16:41:21 -0000 1.2 *************** *** 14,138 **** /** * @author Fabio Zadrozny ! * ! * Makes a backspace happen... ! * ! * We can: ! * - go to the indentation from some uncommented previous line (if we only ! * have whitespaces in the current line). ! * ! * - erase all whitespace characters until we find some character. ! * ! * - erase a single character. */ ! public class PyBackspace extends PyAction{ ! /** ! * Makes a backspace happen... ! * ! * We can: ! * - go to the indentation from some uncommented previous line (if we only ! * have whitespaces in the current line). ! * ! * - erase all whitespace characters until we find some character. ! * ! * - erase a single character. ! */ ! public void run(IAction action) { ! // Select from text editor ! PySelection ps = new PySelection ( getTextEditor ( ), false ); ! // Perform the action ! try ! { ! ITextSelection textSelection = ps.getITextSelection(); ! if( textSelection.getLength() != 0){ ! eraseSelection(ps); ! return ; ! } ! ! int lastCharPosition = getLastCharPosition(ps.doc, ps.getCursorOffset()); ! ! int cursorOffset = textSelection.getOffset(); ! ! IRegion lastCharRegion = ps.doc.getLineInformationOfOffset(lastCharPosition+1); ! //System.out.println("cursorOffset: "+ cursorOffset); ! //System.out.println("lastCharPosition: "+lastCharPosition); ! //System.out.println("lastCharRegion.getOffset(): " +lastCharRegion.getOffset()); ! // IRegion cursorRegion = ps.doc.getLineInformationOfOffset(cursorOffset); ! ! if( cursorOffset == lastCharRegion.getOffset()){ ! //System.out.println("We are in the beggining of the line."); ! //in this situation, we are in the first character of the line... ! //so, we have to get the end of the other line and delete it. ! if (cursorOffset != 0) //we only want to erase if we are not in the first line. ! eraseLineDelimiter(ps); ! } ! else if(cursorOffset <= lastCharPosition){ ! //System.out.println("cursorOffset <= lastCharPosition"); ! //this situation is: ! // |a (delete to previous indentation - considers cursor position) ! //or ! // as | as (delete single char) ! //or ! // | a (delete to previous indentation - considers cursor position) ! //so, we have to treat it carefully ! eraseToPreviousIndentation(ps,false); ! } ! else if(lastCharRegion.getOffset() == lastCharPosition+1){ ! //System.out.println("Only whitespaces in the line."); ! //in this situation, this line only has whitespaces, ! //so, we have to erase depending on the previous indentation. ! eraseToPreviousIndentation(ps,true); ! }else{ ! ! if (cursorOffset - lastCharPosition == 1){ ! //System.out.println("Erase single char."); ! //last char and cursor are in the same line. ! //this situation is: ! // a| ! eraseSingleChar(ps); ! ! }else if (cursorOffset - lastCharPosition > 1){ ! //this situation is: ! // a | ! //System.out.println("Erase until last char is found."); ! eraseUntilLastChar(ps,lastCharPosition); ! } ! } ! } ! catch ( Exception e ) ! { ! beep ( e ); ! } ! ! } ! /** * @param ps ! * @param hasOnlyWhitespaces ! * @throws BadLocationException */ ! private void eraseToPreviousIndentation(PySelection ps, boolean hasOnlyWhitespaces) throws BadLocationException { ITextSelection textSelection = ps.getITextSelection(); ! int indentation = getPreviousIndentation(ps,textSelection); ! if(indentation == -1){ //System.out.println("erasing single char"); eraseSingleChar(ps); ! }else{ ! if(hasOnlyWhitespaces){ //System.out.println("only whitespaces"); eraseToIndentation(ps, indentation); ! }else{ //System.out.println("not only whitespaces"); ! //this situation is: ! // |a (delete to previous indentation - considers cursor position) ! //or ! // as | as (delete single char) ! //or ! // | a (delete to previous indentation - considers cursor position) ! //so, we have to treat it carefully ! //TODO: use the conditions above and not just erase a single char. eraseSingleChar(ps); --- 14,136 ---- /** * @author Fabio Zadrozny ! * ! * Makes a backspace happen... ! * ! * We can: - go to the indentation from some uncommented previous line (if we ! * only have whitespaces in the current line). ! * - erase all whitespace characters until we find some character. ! * - erase a single character. */ ! public class PyBackspace extends PyAction { ! /** ! * Makes a backspace happen... ! * ! * We can: - go to the indentation from some uncommented previous line (if ! * we only have whitespaces in the current line). ! * - erase all whitespace characters until we find some character. ! * - erase a single character. ! */ ! public void run(IAction action) { ! // Select from text editor ! PySelection ps = new PySelection(getTextEditor(), false); ! // Perform the action ! try { ! ITextSelection textSelection = ps.getITextSelection(); ! if (textSelection.getLength() != 0) { ! eraseSelection(ps); ! return; ! } + int lastCharPosition = getLastCharPosition(ps.doc, ps.getCursorOffset()); ! int cursorOffset = textSelection.getOffset(); ! ! IRegion lastCharRegion = ps.doc.getLineInformationOfOffset(lastCharPosition + 1); ! //System.out.println("cursorOffset: "+ cursorOffset); ! //System.out.println("lastCharPosition: "+lastCharPosition); ! //System.out.println("lastCharRegion.getOffset(): " ! // +lastCharRegion.getOffset()); ! // IRegion cursorRegion = ! // ps.doc.getLineInformationOfOffset(cursorOffset); ! ! if (cursorOffset == lastCharRegion.getOffset()) { ! //System.out.println("We are in the beggining of the line."); ! //in this situation, we are in the first character of the ! // line... ! //so, we have to get the end of the other line and delete it. ! if (cursorOffset != 0) //we only want to erase if we are not in ! // the first line. ! eraseLineDelimiter(ps); ! } else if (cursorOffset <= lastCharPosition) { ! //System.out.println("cursorOffset <= lastCharPosition"); ! //this situation is: ! // |a (delete to previous indentation - considers cursor ! // position) ! //or ! // as | as (delete single char) ! //or ! // | a (delete to previous indentation - considers cursor ! // position) ! //so, we have to treat it carefully ! eraseToPreviousIndentation(ps, false); ! } else if (lastCharRegion.getOffset() == lastCharPosition + 1) { ! //System.out.println("Only whitespaces in the line."); ! //in this situation, this line only has whitespaces, ! //so, we have to erase depending on the previous indentation. ! eraseToPreviousIndentation(ps, true); ! } else { ! ! if (cursorOffset - lastCharPosition == 1) { ! //System.out.println("Erase single char."); ! //last char and cursor are in the same line. ! //this situation is: ! // a| ! eraseSingleChar(ps); ! ! } else if (cursorOffset - lastCharPosition > 1) { ! //this situation is: ! // a | ! //System.out.println("Erase until last char is found."); ! eraseUntilLastChar(ps, lastCharPosition); ! } ! } ! } catch (Exception e) { ! beep(e); ! } ! ! } ! ! /** * @param ps ! * @param hasOnlyWhitespaces ! * @throws BadLocationException */ ! private void eraseToPreviousIndentation(PySelection ps, boolean hasOnlyWhitespaces) ! throws BadLocationException { ITextSelection textSelection = ps.getITextSelection(); ! int indentation = getPreviousIndentation(ps, textSelection.getStartLine()); ! if (indentation == -1) { //System.out.println("erasing single char"); eraseSingleChar(ps); ! } else { ! if (hasOnlyWhitespaces) { //System.out.println("only whitespaces"); eraseToIndentation(ps, indentation); ! } else { //System.out.println("not only whitespaces"); ! //this situation is: ! // |a (delete to previous indentation - considers cursor ! // position) ! //or ! // as | as (delete single char) ! //or ! // | a (delete to previous indentation - considers cursor ! // position) ! //so, we have to treat it carefully ! //TODO: use the conditions above and not just erase a single ! // char. eraseSingleChar(ps); *************** *** 145,161 **** * @param ps * @param textSelection ! * @return offset of the indentation on the previous non-commented line or -1 ! * if we are not able to get it (if this happens, we delete 1 char). * @throws BadLocationException */ ! private int getPreviousIndentation(PySelection ps, ITextSelection textSelection) throws BadLocationException { ! int currentLine = textSelection.getStartLine(); ! if(currentLine == 0){ ! //we are in the first line, so, we have no basis to get indentation. return -1; ! }else{ ! for (int i = currentLine-1; i >=0 ; i++) { int currentLineOffset = ps.doc.getLineOffset(i); ! if(ps.doc.getChar(currentLineOffset+1) != '#'){ int currentLineFirstCharPos = getFirstCharRelativePosition(ps.doc, currentLineOffset); return currentLineFirstCharPos; --- 143,160 ---- * @param ps * @param textSelection ! * @return offset of the indentation on the previous non-commented line or ! * -1 if we are not able to get it (if this happens, we delete 1 ! * char). * @throws BadLocationException */ ! private static int getPreviousIndentation(PySelection ps, int currentLine) throws BadLocationException { ! if (currentLine == 0) { ! //we are in the first line, so, we have no basis to get ! // indentation. return -1; ! } else { ! for (int i = currentLine - 1; i >= 0; i++) { int currentLineOffset = ps.doc.getLineOffset(i); ! if (ps.doc.getChar(currentLineOffset + 1) != '#') { int currentLineFirstCharPos = getFirstCharRelativePosition(ps.doc, currentLineOffset); return currentLineFirstCharPos; *************** *** 166,170 **** } - /** * --- 165,168 ---- *************** *** 172,181 **** * @throws BadLocationException */ ! private void eraseSingleChar(PySelection ps) throws BadLocationException{ ! ITextSelection textSelection = ps.getITextSelection(); ! ! ps.doc.replace ( textSelection.getOffset() -1, 1, "" ); ! } ! /** * --- 170,179 ---- * @throws BadLocationException */ ! private void eraseSingleChar(PySelection ps) throws BadLocationException { ! ITextSelection textSelection = ps.getITextSelection(); ! ! ps.doc.replace(textSelection.getOffset() - 1, 1, ""); ! } ! /** * *************** *** 183,282 **** * @throws BadLocationException */ ! private void eraseLineDelimiter(PySelection ps) throws BadLocationException{ ! ITextSelection textSelection = ps.getITextSelection(); ! ! int length = getDelimiter(ps.doc, 1).length(); ! int offset = textSelection.getOffset() - length; ! //System.out.println("Replacing offset: "+(offset) +" lenght: "+ (length)); ! ps.doc.replace ( offset, length, "" ); ! } ! ! /** ! * ! * @param ps ! * @throws BadLocationException ! */ ! private void eraseSelection(PySelection ps) throws BadLocationException{ ! ITextSelection textSelection = ps.getITextSelection(); ! ! ps.doc.replace ( textSelection.getOffset() , textSelection.getLength(), "" ); ! } ! /** * @param ps ! * @param lastCharPosition ! * @throws BadLocationException */ ! private void eraseUntilLastChar(PySelection ps, int lastCharPosition) throws BadLocationException { ! ITextSelection textSelection = ps.getITextSelection(); ! int cursorOffset = textSelection.getOffset(); ! ! int offset = lastCharPosition+1; ! int length = cursorOffset - lastCharPosition-1; ! //System.out.println("Replacing offset: "+(offset) +" lenght: "+ (length)); ! ps.doc.replace ( offset , length, "" ); } /** ! * TODO: Make use of the indentation gotten previously. This implementation just ! * uses the indentation string and erases the number of chars from it. * * @param ps ! * @param indentation - this is in number of characters. * @throws BadLocationException */ private void eraseToIndentation(PySelection ps, int indentation) throws BadLocationException { ! ITextSelection textSelection = ps.getITextSelection(); ! int cursorOffset = textSelection.getOffset(); ! ! String indentationString = getIndentationString(); ! int length = indentationString.length(); ! int offset = cursorOffset - length; ! ! IRegion region = ps.doc.getLineInformationOfOffset(cursorOffset); ! int dif = region.getOffset() - offset; ! //System.out.println("dif = "+dif); ! if (dif > 0){ ! offset += dif; ! length -= dif; ! } ! //we have to be careful not to erase more than the current line. ! //System.out.println("Replacing offset: "+(offset) +" lenght: "+ (length)); ! ps.doc.replace ( offset , length, "" ); ! } //CODE BELOW GOTTEN FROM PyAutoIndentStrategy.java. //TODO: Software enginner this (Ctrl-C / Ctrl-V is not a good strategy) ! String identString = null; ! // should tab be converted to spaces? ! boolean useSpaces = PydevPrefs.getPreferences().getBoolean(PydevPrefs.SUBSTITUTE_TABS); ! int tabWidth = PydevPrefs.getPreferences().getInt(PydevPrefs.TAB_WIDTH); ! boolean forceTabs = false; ! private String createSpaceString(int width) { ! StringBuffer b = new StringBuffer(width); ! while (tabWidth-- > 0) ! b.append(" "); ! return b.toString(); ! } ! private String getIndentationString() { ! if (identString == null || ! tabWidth != PydevPrefs.getPreferences().getInt(PydevPrefs.TAB_WIDTH) || ! useSpaces != PydevPrefs.getPreferences().getBoolean(PydevPrefs.SUBSTITUTE_TABS)) ! { ! tabWidth = PydevPrefs.getPreferences().getInt(PydevPrefs.TAB_WIDTH); ! useSpaces = PydevPrefs.getPreferences().getBoolean(PydevPrefs.SUBSTITUTE_TABS); ! if (useSpaces && !forceTabs) ! identString = createSpaceString(tabWidth); ! else ! identString = "\t"; ! } ! return identString; ! } ! //END TODO. ! } --- 181,312 ---- * @throws BadLocationException */ ! private void eraseLineDelimiter(PySelection ps) throws BadLocationException { ! ITextSelection textSelection = ps.getITextSelection(); ! int length = getDelimiter(ps.doc, 1).length(); ! int offset = textSelection.getOffset() - length; ! //System.out.println("Replacing offset: "+(offset) +" lenght: "+ ! // (length)); ! ps.doc.replace(offset, length, ""); ! } ! ! /** ! * * @param ps ! * @throws BadLocationException */ ! private void eraseSelection(PySelection ps) throws BadLocationException { ! ITextSelection textSelection = ps.getITextSelection(); ! ! ps.doc.replace(textSelection.getOffset(), textSelection.getLength(), ""); } + /** + * @param ps + * @param lastCharPosition + * @throws BadLocationException + */ + private void eraseUntilLastChar(PySelection ps, int lastCharPosition) throws BadLocationException { + ITextSelection textSelection = ps.getITextSelection(); + int cursorOffset = textSelection.getOffset(); + + int offset = lastCharPosition + 1; + int length = cursorOffset - lastCharPosition - 1; + //System.out.println("Replacing offset: "+(offset) +" lenght: "+ + // (length)); + ps.doc.replace(offset, length, ""); + } /** ! * TODO: Make use of the indentation gotten previously. This implementation ! * just uses the indentation string and erases the number of chars from it. * * @param ps ! * @param indentation - ! * this is in number of characters. * @throws BadLocationException */ private void eraseToIndentation(PySelection ps, int indentation) throws BadLocationException { ! ITextSelection textSelection = ps.getITextSelection(); ! int cursorOffset = textSelection.getOffset(); + String indentationString = getIndentationString(); + int length = indentationString.length(); + int offset = cursorOffset - length; + + IRegion region = ps.doc.getLineInformationOfOffset(cursorOffset); + int dif = region.getOffset() - offset; + //System.out.println("dif = "+dif); + if (dif > 0) { + offset += dif; + length -= dif; + } + //we have to be careful not to erase more than the current line. + //System.out.println("Replacing offset: "+(offset) +" lenght: "+ + // (length)); + ps.doc.replace(offset, length, ""); + } //CODE BELOW GOTTEN FROM PyAutoIndentStrategy.java. //TODO: Software enginner this (Ctrl-C / Ctrl-V is not a good strategy) ! String identString = null; ! // should tab be converted to spaces? ! boolean useSpaces = PydevPrefs.getPreferences().getBoolean(PydevPrefs.SUBSTITUTE_TABS); ! int tabWidth = PydevPrefs.getPreferences().getInt(PydevPrefs.TAB_WIDTH); ! ! boolean forceTabs = false; ! ! private String createSpaceString(int width) { ! StringBuffer b = new StringBuffer(width); ! while (tabWidth-- > 0) ! b.append(" "); ! return b.toString(); ! } ! ! /** ! * ! * @return indentation string (from cache) ! */ ! private String getIndentationString() { ! if (identString == null || tabWidth != PydevPrefs.getPreferences().getInt(PydevPrefs.TAB_WIDTH) ! || useSpaces != PydevPrefs.getPreferences().getBoolean(PydevPrefs.SUBSTITUTE_TABS)) { ! tabWidth = PydevPrefs.getPreferences().getInt(PydevPrefs.TAB_WIDTH); ! useSpaces = PydevPrefs.getPreferences().getBoolean(PydevPrefs.SUBSTITUTE_TABS); ! if (useSpaces && !forceTabs) ! identString = createSpaceString(tabWidth); ! else ! identString = "\t"; ! } ! return identString; ! } ! //END TODO. ! ! ! private static String createStaticSpaceString(int width, int tabWidth) { ! StringBuffer b = new StringBuffer(width); ! while (tabWidth-- > 0) ! b.append(" "); ! return b.toString(); ! } ! ! /** ! * ! * @return indentation string (always recreated) ! */ ! public static String getStaticIndentationString() { ! int tabWidth = PydevPrefs.getPreferences().getInt(PydevPrefs.TAB_WIDTH); ! boolean useSpaces = PydevPrefs.getPreferences().getBoolean(PydevPrefs.SUBSTITUTE_TABS); ! boolean forceTabs = false; ! String identString; ! ! if (useSpaces && !forceTabs) ! identString = createStaticSpaceString(tabWidth, tabWidth); ! else ! identString = "\t"; ! return identString; ! } ! } \ No newline at end of file |
From: Fabio Z. <fa...@us...> - 2004-09-24 16:41:30
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15928/src/org/python/pydev/editor/correctionassist Modified Files: PythonCorrectionProcessor.java Log Message: Decoration support / Making correction assistant on Ctrl+1 Index: PythonCorrectionProcessor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/correctionassist/PythonCorrectionProcessor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PythonCorrectionProcessor.java 23 Sep 2004 18:06:31 -0000 1.2 --- PythonCorrectionProcessor.java 24 Sep 2004 16:41:12 -0000 1.3 *************** *** 18,22 **** --- 18,27 ---- import org.python.pydev.editor.PyEdit; import org.python.pydev.editor.actions.PyAction; + import org.python.pydev.editor.actions.PyBackspace; import org.python.pydev.editor.actions.PySelection; + import org.python.pydev.editor.model.AbstractNode; + import org.python.pydev.editor.model.ClassNode; + import org.python.pydev.editor.model.FunctionNode; + import org.python.pydev.editor.model.ModelUtils; /** *************** *** 65,70 **** PySelection ps = new PySelection(edit, false); ! List results = getAssignToResults(ps); ! results.addAll(getCreations(ps)); return (ICompletionProposal[]) results.toArray(new ICompletionProposal[0]); --- 70,83 ---- PySelection ps = new PySelection(edit, false); ! List results = new ArrayList(); ! try { ! results.addAll(getAssignToResults(ps)); ! } catch (BadLocationException e) { ! } ! ! try { ! results.addAll(getCreations(ps)); ! } catch (BadLocationException e1) { ! } return (ICompletionProposal[]) results.toArray(new ICompletionProposal[0]); *************** *** 74,79 **** * @param ps * @return */ ! private List getCreations(PySelection ps) { List l = new ArrayList(); --- 87,93 ---- * @param ps * @return + * @throws BadLocationException */ ! private List getCreations(PySelection ps) throws BadLocationException { List l = new ArrayList(); *************** *** 83,96 **** //here, any callable can be used to create a new method or class. ! //we have to parse it, because we have to discover the parameters for the new class. return l; } /** * @param ps */ ! private List getAssignToResults(PySelection ps) { List l = new ArrayList(); --- 97,198 ---- //here, any callable can be used to create a new method or class. ! //we have to parse it, because we have to discover the parameters for the new class or method. + String callName = getBeforeParentesisTok(ps); + + if(callName.length() == 0){ + return l; + } + + String params = "("+getInsideParentesisTok(ps)+")"; + int firstCharPosition = PyAction.getFirstCharRelativePosition(ps.doc, ps.absoluteCursorOffset); + String indentation = PyBackspace.getStaticIndentationString(); + + + String delim = PyAction.getDelimiter(ps.doc, 0); + String cls = "class "+callName+":"+delim+delim; + cls += indentation+"def __init__"+params+":"+delim; + cls += indentation+indentation+"pass"+delim; + + String method = "def "+callName+params+":"+delim+indentation+"pass"+delim; + + if (firstCharPosition == 0){ //we are in the global context + + int newPos = 0; + int lineOfOffset = ps.doc.getLineOfOffset(ps.absoluteCursorOffset); + + if(lineOfOffset > 0){ + newPos = ps.doc.getLineInformation(lineOfOffset - 1).getOffset(); + } + + l.add(new CompletionProposal(cls, newPos, 0, cls.length()+1, null, + "Create new class (global context)", null, null)); + + l.add(new CompletionProposal(method, newPos, 0, method.length()+1, null, + "Create new method (global context)", null, null)); + + }else{ //we are in a method or class context + + AbstractNode root = edit.getPythonModel(); + if (root == null){ + return l; + } + + //now, discover in which node we are right now... + AbstractNode current = ModelUtils.getLessOrEqualNode(root, ps.absoluteCursorOffset, ps.doc); + while (current != null) { + if (current instanceof FunctionNode + || current instanceof ClassNode) { + break; + } + current = ModelUtils.getPreviousNode(current); + } + + + if(ps.selection.indexOf("self.") != -1){ //we are going for a class method. + + if (current instanceof FunctionNode) { //if we are in a class, here we are within a method. + FunctionNode node = (FunctionNode) current; + + int newPos = 0; + int lineOfOffset = node.getStart().line; + + if(lineOfOffset > 0){ + newPos = ps.doc.getLineInformation(lineOfOffset).getOffset(); + } + + int col = node.getStart().column; + String newIndent = indentation; + + while(newIndent.length() < col){ + newIndent += indentation; + } + String atStart = newIndent.replaceFirst(indentation, ""); + method = method.replaceAll(indentation, newIndent); + method = atStart+method+delim; + + l.add(new CompletionProposal(method, newPos, 0, method.length()-4, null, + "Create new method (in class)", null, null)); + } + + }else{ //we are going for a class or a global method. + //TODO: End this. + // l.add(new CompletionProposal(callName, 0, 0, 0, null, + // "Create new class", null, null)); + // + // l.add(new CompletionProposal(callName, 0, 0, 0, null, + // "Create new method", null, null)); + } + } return l; } + /** * @param ps + * @throws BadLocationException */ ! private List getAssignToResults(PySelection ps) throws BadLocationException { List l = new ArrayList(); *************** *** 122,159 **** // self.|result| = 1+1 ! String string = ps.selection.replaceAll("\\(*\\)", "()"); ! try { ! int firstCharPosition = PyAction.getFirstCharPosition(ps.doc, ps.absoluteCursorOffset); ! int i; ! String callName = "result"; ! if ((i = string.indexOf("()")) != -1) { ! callName = ""; ! for (int j = i-1; j >= 0 && stillInTok(string, j); j--) { ! callName = string.charAt(j) + callName; ! } ! ! if(callName.length()>0){ ! //all that just to change first char to lower case. ! char[] ds = callName.toCharArray(); ! ds[0] = (""+ds[0]).toLowerCase().charAt(0); ! callName = new String(ds); ! } ! } ! callName += " = "; ! l.add(new CompletionProposal(callName, firstCharPosition, 0, 0, null, ! "Assign to new local variable", null, null)); ! ! l.add(new CompletionProposal("self." + callName, firstCharPosition, 0, 0, null, ! "Assign to new field", null, null)); ! ! } catch (BadLocationException e) { ! e.printStackTrace(); } } ! return l; } --- 224,278 ---- // self.|result| = 1+1 ! String callName = getBeforeParentesisTok(ps); ! if(callName.length() > 0){ ! //all that just to change first char to lower case. ! char[] ds = callName.toCharArray(); ! ds[0] = (""+ds[0]).toLowerCase().charAt(0); ! callName = new String(ds); ! }else{ ! callName = "result"; ! } ! int firstCharPosition = PyAction.getFirstCharPosition(ps.doc, ps.absoluteCursorOffset); ! callName += " = "; ! l.add(new CompletionProposal(callName, firstCharPosition, 0, 0, null, ! "Assign to new local variable", null, null)); ! ! l.add(new CompletionProposal("self." + callName, firstCharPosition, 0, 5, null, ! "Assign to new field", null, null)); ! } ! return l; ! } ! /** ! * @param ps ! * @return ! */ ! private String getInsideParentesisTok(PySelection ps) { ! int beg = ps.selection.indexOf('(')+1; ! int end = ps.selection.indexOf(')'); ! return ps.selection.substring(beg, end); ! } ! /** ! * @param ps ! * @return string with the token or empty token if not found. ! */ ! private String getBeforeParentesisTok(PySelection ps) { ! String string = ps.selection.replaceAll("\\(.*\\)", "()"); ! ! int i; ! ! String callName = ""; ! if ((i = string.indexOf("()")) != -1) { ! callName = ""; ! ! for (int j = i-1; j >= 0 && stillInTok(string, j); j--) { ! callName = string.charAt(j) + callName; } + } ! return callName; } *************** *** 166,170 **** char c = string.charAt(j); ! return c != '\n' && c != '\r' && c != ' ' && c != '.' && c != '(' && c != ')'; } --- 285,289 ---- char c = string.charAt(j); ! return c != '\n' && c != '\r' && c != ' ' && c != '.' && c != '(' && c != ')' && c != ',' && c != ']' && c != '['; } |
From: Aleksandar T. <at...@us...> - 2004-09-24 00:39:31
|
Update of /cvsroot/pydev/org.python.pydev.debug In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27792 Modified Files: plugin.xml Log Message: version 0.6 Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/plugin.xml,v retrieving revision 1.16 retrieving revision 1.17 diff -C2 -d -r1.16 -r1.17 *** plugin.xml 20 Sep 2004 13:20:39 -0000 1.16 --- plugin.xml 24 Sep 2004 00:39:21 -0000 1.17 *************** *** 4,8 **** id="org.python.pydev.debug" name="Pydev debug" ! version="0.5.3.1" provider-name="Aleks Totic" class="org.python.pydev.debug.core.PydevDebugPlugin"> --- 4,8 ---- id="org.python.pydev.debug" name="Pydev debug" ! version="0.6" provider-name="Aleks Totic" class="org.python.pydev.debug.core.PydevDebugPlugin"> |
From: Aleksandar T. <at...@us...> - 2004-09-24 00:39:14
|
Update of /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27733/src/org/python/pydev/debug/model Modified Files: PyDebugTarget.java Log Message: Bug fix: fire an event upon termination to make executed line marker disappear. Index: PyDebugTarget.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.debug/src/org/python/pydev/debug/model/PyDebugTarget.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PyDebugTarget.java 21 Jul 2004 18:04:43 -0000 1.8 --- PyDebugTarget.java 24 Sep 2004 00:39:05 -0000 1.9 *************** *** 164,167 **** --- 164,168 ---- threads = new IThread[0]; process.terminate(); + fireEvent(new DebugEvent(this, DebugEvent.TERMINATE)); } |
From: Aleksandar T. <at...@us...> - 2004-09-24 00:37:57
|
Update of /cvsroot/pydev/org.python.pydev In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27377 Modified Files: plugin.xml Log Message: version 0.6 Index: plugin.xml =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/plugin.xml,v retrieving revision 1.43 retrieving revision 1.44 diff -C2 -d -r1.43 -r1.44 *** plugin.xml 23 Sep 2004 18:06:31 -0000 1.43 --- plugin.xml 24 Sep 2004 00:37:48 -0000 1.44 *************** *** 4,8 **** id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.5.9.8" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> --- 4,8 ---- id="org.python.pydev" name="Pydev - Python Development Environment" ! version="0.6" provider-name="AleksTotic" class="org.python.pydev.plugin.PydevPlugin"> |
From: Aleksandar T. <at...@us...> - 2004-09-24 00:29:51
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25389/src/org/python/pydev/outline Modified Files: ParsedModel.java Log Message: Removed a TODO Index: ParsedModel.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/outline/ParsedModel.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** ParsedModel.java 27 Apr 2004 01:06:57 -0000 1.5 --- ParsedModel.java 24 Sep 2004 00:29:31 -0000 1.6 *************** *** 111,115 **** public void setError(Throwable error) { ! // TODO put some error note on the items? } --- 111,115 ---- public void setError(Throwable error) { ! // put some error note on the items? } |
From: Aleksandar T. <at...@us...> - 2004-09-24 00:29:19
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25357/src/org/python/pydev/ui Modified Files: ProjectProperties.java Log Message: Changed "Dana" to "any volunteer" Index: ProjectProperties.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/ProjectProperties.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** ProjectProperties.java 15 Apr 2004 23:19:22 -0000 1.2 --- ProjectProperties.java 24 Sep 2004 00:29:10 -0000 1.3 *************** *** 22,26 **** /** ! * TODO just a stub for now. Dana will implement real include preferenecs */ public class ProjectProperties extends PropertyPage { --- 22,26 ---- /** ! * TODO just a stub for now. Volunteers needed to implement real include preferenecs */ public class ProjectProperties extends PropertyPage { |
From: Aleksandar T. <at...@us...> - 2004-09-24 00:28:57
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25266/src/org/python/pydev/ui Modified Files: InterpreterEditor.java Log Message: Removed a TODO Index: InterpreterEditor.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/ui/InterpreterEditor.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** InterpreterEditor.java 22 Apr 2004 10:35:23 -0000 1.2 --- InterpreterEditor.java 24 Sep 2004 00:28:48 -0000 1.3 *************** *** 69,73 **** dialog.setFilterExtensions(new String[] {"*.exe", "*.*"}); else ! ; // TODO right file dialog executable filters for unix/mac? if (lastPath != null) { if (new File(lastPath).exists()) --- 69,73 ---- dialog.setFilterExtensions(new String[] {"*.exe", "*.*"}); else ! ; // right file dialog executable filters for unix/mac? if (lastPath != null) { if (new File(lastPath).exists()) |
From: Aleksandar T. <at...@us...> - 2004-09-24 00:28:15
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/codefolding In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv25127/src/org/python/pydev/editor/actions/codefolding Modified Files: PyCollapse.java Log Message: Added logging of error (instead of e.printStackTrace) Index: PyCollapse.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/codefolding/PyCollapse.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyCollapse.java 16 Aug 2004 13:30:59 -0000 1.2 --- PyCollapse.java 24 Sep 2004 00:28:05 -0000 1.3 *************** *** 9,12 **** --- 9,13 ---- import java.util.Iterator; + import org.eclipse.core.runtime.IStatus; import org.eclipse.jface.action.IAction; import org.eclipse.jface.text.BadLocationException; *************** *** 16,19 **** --- 17,21 ---- import org.python.pydev.editor.actions.PySelection; import org.python.pydev.editor.codefolding.PyProjectionAnnotation; + import org.python.pydev.plugin.PydevPlugin; /** *************** *** 57,63 **** } } catch (BadLocationException e) { ! // TODO Auto-generated catch block ! e.printStackTrace(); ! } } } \ No newline at end of file --- 59,64 ---- } } catch (BadLocationException e) { ! PydevPlugin.log(IStatus.ERROR, "Unexpected error collapsing", e); ! } } } \ No newline at end of file |
From: Aleksandar T. <at...@us...> - 2004-09-24 00:27:10
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24821/src/org/python/pydev/editor/actions Modified Files: PyOpenAction.java Log Message: Fixed the "cant open correct line when clicking console" bug Index: PyOpenAction.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/actions/PyOpenAction.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** PyOpenAction.java 20 Sep 2004 19:08:42 -0000 1.6 --- PyOpenAction.java 24 Sep 2004 00:27:00 -0000 1.7 *************** *** 63,67 **** editor = PydevPlugin.doOpenEditor(path, true); } ! if (editor instanceof ITextEditor && p.start.line >= 0 && p.end.line >= 0) { showInEditor((ITextEditor)editor, p.start, p.end); } --- 63,67 ---- editor = PydevPlugin.doOpenEditor(path, true); } ! if (editor instanceof ITextEditor && p.start.line >= 0) { showInEditor((ITextEditor)editor, p.start, p.end); } |
From: Aleksandar T. <at...@us...> - 2004-09-24 00:25:20
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24472/src/org/python/pydev/editor Modified Files: Hyperlink.java Log Message: Fixed the "no underline" bug Index: Hyperlink.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/Hyperlink.java,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** Hyperlink.java 2 Jul 2004 02:50:38 -0000 1.7 --- Hyperlink.java 24 Sep 2004 00:25:09 -0000 1.8 *************** *** 637,641 **** ITextViewerExtension5 extension= (ITextViewerExtension5) viewer; ! IRegion widgetRange= extension.modelRange2WidgetRange(new Region(offset, length)); if (widgetRange == null) return; --- 637,641 ---- ITextViewerExtension5 extension= (ITextViewerExtension5) viewer; ! IRegion widgetRange= extension.modelRange2WidgetRange(fActiveRegion); if (widgetRange == null) return; |