[Pydev-cvs] org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter WriteState.java, 1.2
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-09-27 19:59:46
|
Update of /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv20472/src/org/python/pydev/parser/prettyprinter Modified Files: WriteState.java AuxSpecials.java IWriterEraser.java PrettyPrinter.java PrettyPrinterUtils.java WriterEraser.java Log Message: Synching to latest changes: Pydev <ul> <li><strong>Editor</strong>: Cursor settings no longer overridden</li> <li><strong>Code-completion</strong>: If __all__ is defined with runtime elements (and not only in a single assign statement), it's ignored for code-completion purposes</li> <li><strong>Debugger</strong>: Pythonpath the same in debug and regular modes (sys.path[0] is the same directory as the file run)</li> <li><strong>Debugger</strong>: Persist choices done in the debugger when files from the debugger are not found</li> <li><strong>Interpreter config</strong>: "email" automatically added to the "forced builtins"</li> <li><strong>Parser</strong>: Correctly recognizing absolute import with 3 or more levels</li> <li><strong>Syntax check</strong>: Option to do only on active editor</li> </ul> Also: tabs changed for spaces Index: PrettyPrinterUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/PrettyPrinterUtils.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** PrettyPrinterUtils.java 11 Jun 2007 00:07:53 -0000 1.1 --- PrettyPrinterUtils.java 27 Sep 2008 19:58:43 -0000 1.2 *************** *** 277,292 **** } ! protected void genericAfter(SimpleNode node, boolean needIndent, boolean isNewScope) throws IOException { ! state.popInStmt(); afterNode(node, isNewScope); ! } ! protected void genericBefore(SimpleNode node, boolean requiresNewLine) throws IOException { ! if(requiresNewLine){ fixNewStatementCondition(); } beforeNode(node); state.pushInStmt(node); ! } public Object superGlobal(Global node) throws Exception { --- 277,292 ---- } ! protected void genericAfter(SimpleNode node, boolean needIndent, boolean isNewScope) throws IOException { ! state.popInStmt(); afterNode(node, isNewScope); ! } ! protected void genericBefore(SimpleNode node, boolean requiresNewLine) throws IOException { ! if(requiresNewLine){ fixNewStatementCondition(); } beforeNode(node); state.pushInStmt(node); ! } public Object superGlobal(Global node) throws Exception { *************** *** 331,335 **** public Object superReturn(Return node) throws Exception { ! return super.visitReturn(node); } --- 331,335 ---- public Object superReturn(Return node) throws Exception { ! return super.visitReturn(node); } *************** *** 343,351 **** public Object superDelete(Delete node) throws Exception { ! return super.visitDelete(node); } public Object superListComp(ListComp node) throws Exception { ! return super.visitListComp(node); } --- 343,351 ---- public Object superDelete(Delete node) throws Exception { ! return super.visitDelete(node); } public Object superListComp(ListComp node) throws Exception { ! return super.visitListComp(node); } Index: WriteState.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/WriteState.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** WriteState.java 13 Jun 2007 00:20:54 -0000 1.2 --- WriteState.java 27 Sep 2008 19:58:43 -0000 1.3 *************** *** 76,96 **** } ! public void pushInStmt(SimpleNode node) { ! stmtStack.push(node); ! } ! public SimpleNode popInStmt() { ! return stmtStack.pop(); ! } ! public boolean inStmt() { ! return stmtStack.size() > 0; ! } ! public void eraseIndent() { ! if(indentation.toString().length() > 0){ ! writer.erase(prefs.getIndent()); ! } ! } public void write(String o) { --- 76,96 ---- } ! public void pushInStmt(SimpleNode node) { ! stmtStack.push(node); ! } ! public SimpleNode popInStmt() { ! return stmtStack.pop(); ! } ! public boolean inStmt() { ! return stmtStack.size() > 0; ! } ! public void eraseIndent() { ! if(indentation.toString().length() > 0){ ! writer.erase(prefs.getIndent()); ! } ! } public void write(String o) { Index: PrettyPrinter.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/PrettyPrinter.java,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** PrettyPrinter.java 5 Jul 2008 21:53:00 -0000 1.3 --- PrettyPrinter.java 27 Sep 2008 19:58:43 -0000 1.4 *************** *** 173,177 **** @Override public Object visitAssign(Assign node) throws Exception { ! state.pushInStmt(node); auxComment.writeSpecialsBefore(node); for (int i = 0; i < node.targets.length; i++) { --- 173,177 ---- @Override public Object visitAssign(Assign node) throws Exception { ! state.pushInStmt(node); auxComment.writeSpecialsBefore(node); for (int i = 0; i < node.targets.length; i++) { *************** *** 322,326 **** @Override public Object visitDelete(Delete node) throws Exception { ! return visitGeneric(node, "visitDelete", false); } --- 322,326 ---- @Override public Object visitDelete(Delete node) throws Exception { ! return visitGeneric(node, "visitDelete", false); } *************** *** 333,337 **** } afterNode(node); ! return null; } --- 333,337 ---- } afterNode(node); ! return null; } *************** *** 519,523 **** @Override public Object visitReturn(Return node) throws Exception { ! return visitGeneric(node, "visitReturn", true); } --- 519,523 ---- @Override public Object visitReturn(Return node) throws Exception { ! return visitGeneric(node, "visitReturn", true); } *************** *** 575,580 **** state.writeIndentString(); } ! ! //write the body and dedent for (SimpleNode n : node.body){ n.accept(this); --- 575,580 ---- state.writeIndentString(); } ! ! //write the body and dedent for (SimpleNode n : node.body){ n.accept(this); *************** *** 584,588 **** if(node.orelse != null && node.orelse.length > 0){ ! boolean inElse = false; auxComment.writeSpecialsAfter(node); --- 584,588 ---- if(node.orelse != null && node.orelse.length > 0){ ! boolean inElse = false; auxComment.writeSpecialsAfter(node); *************** *** 590,595 **** //but if it is an 'else:' we will have to make the indent again if(node.specialsAfter != null && node.specialsAfter.contains(new SpecialStr("else:",0,0))){ //the SpecialStr only compares with its String ! inElse = true; ! state.indent(); if(!fixNewStatementCondition()){ state.writeIndentString(); --- 590,595 ---- //but if it is an 'else:' we will have to make the indent again if(node.specialsAfter != null && node.specialsAfter.contains(new SpecialStr("else:",0,0))){ //the SpecialStr only compares with its String ! inElse = true; ! state.indent(); if(!fixNewStatementCondition()){ state.writeIndentString(); *************** *** 600,604 **** } if(inElse){ ! dedent(); } } --- 600,604 ---- } if(inElse){ ! dedent(); } } *************** *** 618,631 **** } ! @Override public Object visitStr(Str node) throws Exception { ! auxComment.writeSpecialsBefore(node); ! state.write(NodeUtils.getStringToPrint(node)); ! if(!state.inStmt()){ fixNewStatementCondition(); ! } ! auxComment.writeSpecialsAfter(node); ! return null; } --- 618,631 ---- } ! @Override public Object visitStr(Str node) throws Exception { ! auxComment.writeSpecialsBefore(node); ! state.write(NodeUtils.getStringToPrint(node)); ! if(!state.inStmt()){ fixNewStatementCondition(); ! } ! auxComment.writeSpecialsAfter(node); ! return null; } *************** *** 646,650 **** state.indent(); { ! auxComment.writeSpecialsAfter(name); if(node.bases.length > 0){ --- 646,650 ---- state.indent(); { ! auxComment.writeSpecialsAfter(name); if(node.bases.length > 0){ *************** *** 721,727 **** { ! //arguments ! makeArgs(node.args.args, node.args); ! //end arguments if(!fixNewStatementCondition()){ if(lastWrite == state.getLastWrite()){ --- 721,727 ---- { ! //arguments ! makeArgs(node.args.args, node.args); ! //end arguments if(!fixNewStatementCondition()){ if(lastWrite == state.getLastWrite()){ *************** *** 769,776 **** if(completeArgs.vararg != null){ ! completeArgs.vararg.accept(this); } if(completeArgs.kwarg != null){ ! completeArgs.kwarg.accept(this); } --- 769,776 ---- if(completeArgs.vararg != null){ ! completeArgs.vararg.accept(this); } if(completeArgs.kwarg != null){ ! completeArgs.kwarg.accept(this); } Index: IWriterEraser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/IWriterEraser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** IWriterEraser.java 11 Jun 2007 00:07:53 -0000 1.1 --- IWriterEraser.java 27 Sep 2008 19:58:43 -0000 1.2 *************** *** 3,9 **** public interface IWriterEraser { ! public void write(String o); ! ! public void erase(String o); public void pushTempBuffer(); --- 3,9 ---- public interface IWriterEraser { ! public void write(String o); ! ! public void erase(String o); public void pushTempBuffer(); Index: WriterEraser.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/WriterEraser.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** WriterEraser.java 11 Jun 2007 00:07:53 -0000 1.1 --- WriterEraser.java 27 Sep 2008 19:58:43 -0000 1.2 *************** *** 5,31 **** public class WriterEraser implements IWriterEraser{ ! FastStack<StringBuffer> buf = new FastStack<StringBuffer>(); ! public WriterEraser(){ pushTempBuffer(); //this is the initial buffer (should never be removed) } ! public void write(String o) { ! buf.peek().append(o); ! } ! public void erase(String o) { StringBuffer buffer = buf.peek(); if(buffer.toString().endsWith(o)){ //only delete if it ends with what was passed ! int len = o.length(); ! int bufLen = buffer.length(); buffer.delete(bufLen-len, bufLen); } ! } ! public StringBuffer getBuffer() { ! return buf.peek(); ! } public void pushTempBuffer() { --- 5,31 ---- public class WriterEraser implements IWriterEraser{ ! FastStack<StringBuffer> buf = new FastStack<StringBuffer>(); ! public WriterEraser(){ pushTempBuffer(); //this is the initial buffer (should never be removed) } ! public void write(String o) { ! buf.peek().append(o); ! } ! public void erase(String o) { StringBuffer buffer = buf.peek(); if(buffer.toString().endsWith(o)){ //only delete if it ends with what was passed ! int len = o.length(); ! int bufLen = buffer.length(); buffer.delete(bufLen-len, bufLen); } ! } ! public StringBuffer getBuffer() { ! return buf.peek(); ! } public void pushTempBuffer() { Index: AuxSpecials.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/prettyprinter/AuxSpecials.java,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** AuxSpecials.java 13 Jun 2007 00:20:54 -0000 1.2 --- AuxSpecials.java 27 Sep 2008 19:58:43 -0000 1.3 *************** *** 45,52 **** } }else if(c instanceof SpecialStr){ ! SpecialStr s = (SpecialStr) c; ! String str = s.str; ! if(canWrite(str, ignore, write)){ ! state.write(prefs.getReplacement(str)); } }else{ --- 45,52 ---- } }else if(c instanceof SpecialStr){ ! SpecialStr s = (SpecialStr) c; ! String str = s.str; ! if(canWrite(str, ignore, write)){ ! state.write(prefs.getReplacement(str)); } }else{ *************** *** 81,92 **** public void writeSpecialsAfter(SimpleNode node) throws IOException { ! writeSpecialsAfter(node, true); } public void writeSpecialsAfter(SimpleNode node, boolean isNewScope) throws IOException { ! int line = node.beginLine; ! if(node.specialsAfter == null){ ! return; } --- 81,92 ---- public void writeSpecialsAfter(SimpleNode node) throws IOException { ! writeSpecialsAfter(node, true); } public void writeSpecialsAfter(SimpleNode node, boolean isNewScope) throws IOException { ! int line = node.beginLine; ! if(node.specialsAfter == null){ ! return; } *************** *** 95,109 **** commentType c = (commentType)o; if(c.beginLine > line){ ! if(state.writeNewLine(false)){ ! if(isNewScope){ ! state.writeIndent(1); ! }else{ ! state.writeIndent(); ! } } }else{ state.writeSpacesBeforeComment(); } ! state.write(c.id); state.writeNewLine(); line = c.beginLine + 1; --- 95,109 ---- commentType c = (commentType)o; if(c.beginLine > line){ ! if(state.writeNewLine(false)){ ! if(isNewScope){ ! state.writeIndent(1); ! }else{ ! state.writeIndent(); ! } } }else{ state.writeSpacesBeforeComment(); } ! state.write(c.id); state.writeNewLine(); line = c.beginLine + 1; *************** *** 112,119 **** }else if(o instanceof SpecialStr){ ! SpecialStr s = (SpecialStr) o; ! state.write(prefs.getReplacement(s.str)); ! line = s.beginLine; ! }else if(o instanceof String){ state.write(prefs.getReplacement((String)o)); --- 112,119 ---- }else if(o instanceof SpecialStr){ ! SpecialStr s = (SpecialStr) o; ! state.write(prefs.getReplacement(s.str)); ! line = s.beginLine; ! }else if(o instanceof String){ state.write(prefs.getReplacement((String)o)); *************** *** 132,136 **** state.write(prefs.getReplacement((String)o)); }else if(o instanceof SpecialStr){ ! state.write(prefs.getReplacement(o.toString())); } } --- 132,136 ---- state.write(prefs.getReplacement((String)o)); }else if(o instanceof SpecialStr){ ! state.write(prefs.getReplacement(o.toString())); } } |