Thread: [Pydev-cvs] org.python.pydev/src/org/python/pydev/editor/refactoring PyRefactoring.java,1.2,1.3
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2004-09-16 15:33:45
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/refactoring In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26116/src/org/python/pydev/editor/refactoring Modified Files: PyRefactoring.java Log Message: Making refactoring. Index: PyRefactoring.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/refactoring/PyRefactoring.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** PyRefactoring.java 15 Sep 2004 17:36:08 -0000 1.2 --- PyRefactoring.java 16 Sep 2004 15:33:33 -0000 1.3 *************** *** 10,13 **** --- 10,14 ---- import org.eclipse.core.runtime.CoreException; + import org.python.pydev.editor.actions.refactoring.PyRefactorAction.Operation; import org.python.pydev.editor.codecompletion.PythonShell; *************** *** 36,44 **** ! private PyRefactoring(){ ! ! } ! ! public static PyRefactoring getPyRefactoring(){ if (pyRefactoring == null){ pyRefactoring = new PyRefactoring(); --- 37,41 ---- ! public synchronized static PyRefactoring getPyRefactoring(){ if (pyRefactoring == null){ pyRefactoring = new PyRefactoring(); *************** *** 47,50 **** --- 44,55 ---- } + private PyRefactoring(){ + try { + getServerShell(); //when we initialize, initialize the server. + } catch (Exception e) { + e.printStackTrace(); + } + } + /** * @return *************** *** 53,57 **** * */ ! private PythonShell getServerShell() throws IOException, CoreException { if(pytonShell == null){ pytonShell = new PythonShell(); --- 58,62 ---- * */ ! private synchronized PythonShell getServerShell() throws IOException, CoreException { if(pytonShell == null){ pytonShell = new PythonShell(); *************** *** 65,71 **** * * @param str * @return */ ! private String makeAction(String str){ PythonShell pytonShell; try { --- 70,77 ---- * * @param str + * @param operation * @return */ ! private String makeAction(String str, Operation operation){ PythonShell pytonShell; try { *************** *** 74,78 **** pytonShell.write(str); ! return pytonShell.read(); } catch (Exception e) { e.printStackTrace(); --- 80,84 ---- pytonShell.write(str); ! return pytonShell.read(operation); } catch (Exception e) { e.printStackTrace(); *************** *** 94,99 **** * @param endCol * @param name */ ! public void extract(File editorFile, int beginLine, int beginCol, int endLine, int endCol, String name) { String s = "@@REFACTOR"; s+= "extractMethod"; --- 100,106 ---- * @param endCol * @param name + * @param operation */ ! public String extract(File editorFile, int beginLine, int beginCol, int endLine, int endCol, String name, Operation operation) { String s = "@@REFACTOR"; s+= "extractMethod"; *************** *** 106,112 **** s+= "END@@"; System.out.println("Extract: "+s); ! String string = makeAction(s); System.out.println("REFACTOR RESULT:"+string); ! } --- 113,119 ---- s+= "END@@"; System.out.println("Extract: "+s); ! String string = makeAction(s, operation); System.out.println("REFACTOR RESULT:"+string); ! return string; } *************** *** 116,121 **** * @param beginCol * @param name */ ! public void rename(File editorFile, int beginLine, int beginCol, String name) { String s = "@@REFACTOR"; s+= "renameByCoordinates"; --- 123,129 ---- * @param beginCol * @param name + * @param operation */ ! public String rename(File editorFile, int beginLine, int beginCol, String name, Operation operation) { String s = "@@REFACTOR"; s+= "renameByCoordinates"; *************** *** 126,133 **** s+= "END@@"; System.out.println("Extract: "+s); ! String string = makeAction(s); System.out.println("REFACTOR RESULT:"+string); } } --- 134,155 ---- s+= "END@@"; System.out.println("Extract: "+s); ! String string = makeAction(s, operation); System.out.println("REFACTOR RESULT:"+string); + return string; } + /** + * + */ + public void restartShell() { + try { + getServerShell().restartShell(); + } catch (IOException e) { + e.printStackTrace(); + } catch (CoreException e) { + e.printStackTrace(); + } + } + } |