[Pydev-cvs] org.python.pydev/src/org/python/pydev/editor/model LengthEstimator.java, 1.6, 1.7 ItemP
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-09-28 12:48:25
|
Update of /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv4313/src/org/python/pydev/editor/model Modified Files: LengthEstimator.java ItemPointer.java IModelListener.java Location.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: LengthEstimator.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/LengthEstimator.java,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** LengthEstimator.java 20 Mar 2006 19:37:56 -0000 1.6 --- LengthEstimator.java 28 Sep 2008 12:45:47 -0000 1.7 *************** *** 66,359 **** public class LengthEstimator extends VisitorBase { ! int length = 0; ! int getLength() { ! return length; ! } ! protected Object unhandled_node(SimpleNode node) throws Exception { ! return null; ! } ! public void traverse(SimpleNode node) throws Exception { ! node.traverse(this); ! } ! ! public Object visitName(Name node) throws Exception { ! length += node.id.length(); ! return null; ! } ! public Object visitAttribute(Attribute node) throws Exception { ! length += ((NameTok)node.attr).id.length() + 1; // +1 for '.' ! node.traverse(this); ! return null; ! } ! public Object visitCall(Call node) throws Exception { ! LengthEstimator e2 = new LengthEstimator(); ! node.traverse(e2); ! length += e2.getLength(); ! return null; ! } ! public Object visitAssert(Assert node) throws Exception { ! // System.out.println("lenVisitAssert:" + node.toString("")); ! return null; ! } ! public Object visitAssign(Assign node) throws Exception { ! // System.out.println("lenVisitAssign:" + node.toString("")); ! return null; ! } ! public Object visitAugAssign(AugAssign node) throws Exception { ! // System.out.println("lenVisitAugAssign:" + node.toString("")); ! return null; ! } ! public Object visitBinOp(BinOp node) throws Exception { ! // System.out.println("lenVisitBinOp:" + node.toString("")); ! return null; ! } ! public Object visitBoolOp(BoolOp node) throws Exception { ! // System.out.println("lenVisitBoolOp:" + node.toString("")); ! return null; ! } ! public Object visitBreak(Break node) throws Exception { ! // System.out.println("lenVisitBreak:" + node.toString("")); ! return null; ! } ! public Object visitClassDef(ClassDef node) throws Exception { ! // System.out.println("lenVisitClassDef:" + node.name); ! return null; ! } ! public Object visitCompare(Compare node) throws Exception { ! // System.out.println("lenVisitCompare:" + node.toString("")); ! return null; ! } ! public Object visitContinue(Continue node) throws Exception { ! // System.out.println("lenVisitContinue:" + node.toString("")); ! return null; ! } ! public Object visitDelete(Delete node) throws Exception { ! // System.out.println("lenVisitDelete:" + node.toString("")); ! return null; ! } ! public Object visitDict(Dict node) throws Exception { ! // System.out.println("lenVisitDict:" + node.toString("")); ! return null; ! } ! public Object visitEllipsis(Ellipsis node) throws Exception { ! // System.out.println("lenVisitEllipsis:" + node.toString("")); ! return null; ! } ! public Object visitExec(Exec node) throws Exception { ! // System.out.println("lenVisitExec:" + node.toString("")); ! return null; ! } ! public Object visitExpr(Expr node) throws Exception { ! // System.out.println("lenVisitExpr:" + node.toString("")); ! return null; ! } ! public Object visitExpression(Expression node) throws Exception { ! // System.out.println("lenVisitExpression:" + node.toString("")); ! return null; ! } ! public Object visitExtSlice(ExtSlice node) throws Exception { ! // System.out.println("lenVisitExtSlice:" + node.toString("")); ! return null; ! } ! public Object visitFor(For node) throws Exception { ! // System.out.println("lenVisitFor:" + node.toString("")); ! return null; ! } ! public Object visitFunctionDef(FunctionDef node) throws Exception { ! // System.out.println("lenVisitFunctionDef:" + node.toString("")); ! return null; ! } ! public Object visitGlobal(Global node) throws Exception { ! // System.out.println("lenVisitGlobal:" + node.toString("")); ! return null; ! } ! public Object visitIf(If node) throws Exception { ! // System.out.println("lenVisitIf:" + node.toString("")); ! return null; ! } ! public Object visitImport(Import node) throws Exception { ! // System.out.println("lenVisitImport:" + node.toString("")); ! return null; ! } ! public Object visitImportFrom(ImportFrom node) throws Exception { ! // System.out.println("lenVisitImportFrom:" + node.toString("")); ! return null; ! } ! public Object visitIndex(Index node) throws Exception { ! // System.out.println("lenVisitIndex:" + node.toString("")); ! return null; ! } ! public Object visitInteractive(Interactive node) throws Exception { ! // System.out.println("lenVisitInteractive:" + node.toString("")); ! return null; ! } ! public Object visitLambda(Lambda node) throws Exception { ! // System.out.println("lenVisitLambda:" + node.toString("")); ! return null; ! } ! public Object visitList(List node) throws Exception { ! // System.out.println("lenVisitList:" + node.toString("")); ! return null; ! } ! public Object visitListComp(ListComp node) throws Exception { ! // System.out.println("lenVisitListComp:" + node.toString("")); ! return null; ! } ! public Object visitModule(Module node) throws Exception { ! // System.out.println("lenVisitModule:" + node.toString("")); ! return null; ! } ! public Object visitNum(Num node) throws Exception { ! // System.out.println("lenVisitNum:" + node.toString("")); ! return null; ! } ! public Object visitPass(Pass node) throws Exception { ! // System.out.println("lenVisitPass:" + node.toString("")); ! return null; ! } ! public Object visitPrint(Print node) throws Exception { ! // System.out.println("lenVisitPrint:" + node.toString("")); ! return null; ! } ! public Object visitRaise(Raise node) throws Exception { ! // System.out.println("lenVisitRaise:" + node.toString("")); ! return null; ! } ! public Object visitRepr(Repr node) throws Exception { ! // System.out.println("lenVisitRepr:" + node.toString("")); ! return null; ! } ! public Object visitReturn(Return node) throws Exception { ! // System.out.println("lenVisitReturn:" + node.toString("")); ! return null; ! } ! public Object visitSlice(Slice node) throws Exception { ! // System.out.println("lenVisitSlice:" + node.toString("")); ! return null; ! } ! public Object visitStr(Str node) throws Exception { ! // System.out.println("lenVisitStr:" + node.toString("")); ! return null; ! } ! public Object visitSubscript(Subscript node) throws Exception { ! // System.out.println("lenVisitSubscript:" + node.toString("")); ! return null; ! } ! public Object visitSuite(Suite node) throws Exception { ! // System.out.println("lenVisitSuite:" + node.toString("")); ! return null; ! } ! public Object visitTryExcept(TryExcept node) throws Exception { ! // System.out.println("lenVisitTryExcept:" + node.toString("")); ! return null; ! } ! public Object visitTryFinally(TryFinally node) throws Exception { ! // System.out.println("lenVisitTryFinally:" + node.toString("")); ! return null; ! } ! public Object visitTuple(Tuple node) throws Exception { ! // System.out.println("lenVisitTuple:" + node.toString("")); ! return null; ! } ! public Object visitUnaryOp(UnaryOp node) throws Exception { ! // System.out.println("lenVisitUnaryOp:" + node.toString("")); ! return null; ! } ! public Object visitWhile(While node) throws Exception { ! // System.out.println("lenVisitWhile:" + node.toString("")); ! return null; ! } ! public Object visitYield(Yield node) throws Exception { ! // System.out.println("lenVisitYield:" + node.toString("")); ! return null; ! } } --- 66,359 ---- public class LengthEstimator extends VisitorBase { ! int length = 0; ! int getLength() { ! return length; ! } ! protected Object unhandled_node(SimpleNode node) throws Exception { ! return null; ! } ! public void traverse(SimpleNode node) throws Exception { ! node.traverse(this); ! } ! ! public Object visitName(Name node) throws Exception { ! length += node.id.length(); ! return null; ! } ! public Object visitAttribute(Attribute node) throws Exception { ! length += ((NameTok)node.attr).id.length() + 1; // +1 for '.' ! node.traverse(this); ! return null; ! } ! public Object visitCall(Call node) throws Exception { ! LengthEstimator e2 = new LengthEstimator(); ! node.traverse(e2); ! length += e2.getLength(); ! return null; ! } ! public Object visitAssert(Assert node) throws Exception { ! // System.out.println("lenVisitAssert:" + node.toString("")); ! return null; ! } ! public Object visitAssign(Assign node) throws Exception { ! // System.out.println("lenVisitAssign:" + node.toString("")); ! return null; ! } ! public Object visitAugAssign(AugAssign node) throws Exception { ! // System.out.println("lenVisitAugAssign:" + node.toString("")); ! return null; ! } ! public Object visitBinOp(BinOp node) throws Exception { ! // System.out.println("lenVisitBinOp:" + node.toString("")); ! return null; ! } ! public Object visitBoolOp(BoolOp node) throws Exception { ! // System.out.println("lenVisitBoolOp:" + node.toString("")); ! return null; ! } ! public Object visitBreak(Break node) throws Exception { ! // System.out.println("lenVisitBreak:" + node.toString("")); ! return null; ! } ! public Object visitClassDef(ClassDef node) throws Exception { ! // System.out.println("lenVisitClassDef:" + node.name); ! return null; ! } ! public Object visitCompare(Compare node) throws Exception { ! // System.out.println("lenVisitCompare:" + node.toString("")); ! return null; ! } ! public Object visitContinue(Continue node) throws Exception { ! // System.out.println("lenVisitContinue:" + node.toString("")); ! return null; ! } ! public Object visitDelete(Delete node) throws Exception { ! // System.out.println("lenVisitDelete:" + node.toString("")); ! return null; ! } ! public Object visitDict(Dict node) throws Exception { ! // System.out.println("lenVisitDict:" + node.toString("")); ! return null; ! } ! public Object visitEllipsis(Ellipsis node) throws Exception { ! // System.out.println("lenVisitEllipsis:" + node.toString("")); ! return null; ! } ! public Object visitExec(Exec node) throws Exception { ! // System.out.println("lenVisitExec:" + node.toString("")); ! return null; ! } ! public Object visitExpr(Expr node) throws Exception { ! // System.out.println("lenVisitExpr:" + node.toString("")); ! return null; ! } ! public Object visitExpression(Expression node) throws Exception { ! // System.out.println("lenVisitExpression:" + node.toString("")); ! return null; ! } ! public Object visitExtSlice(ExtSlice node) throws Exception { ! // System.out.println("lenVisitExtSlice:" + node.toString("")); ! return null; ! } ! public Object visitFor(For node) throws Exception { ! // System.out.println("lenVisitFor:" + node.toString("")); ! return null; ! } ! public Object visitFunctionDef(FunctionDef node) throws Exception { ! // System.out.println("lenVisitFunctionDef:" + node.toString("")); ! return null; ! } ! public Object visitGlobal(Global node) throws Exception { ! // System.out.println("lenVisitGlobal:" + node.toString("")); ! return null; ! } ! public Object visitIf(If node) throws Exception { ! // System.out.println("lenVisitIf:" + node.toString("")); ! return null; ! } ! public Object visitImport(Import node) throws Exception { ! // System.out.println("lenVisitImport:" + node.toString("")); ! return null; ! } ! public Object visitImportFrom(ImportFrom node) throws Exception { ! // System.out.println("lenVisitImportFrom:" + node.toString("")); ! return null; ! } ! public Object visitIndex(Index node) throws Exception { ! // System.out.println("lenVisitIndex:" + node.toString("")); ! return null; ! } ! public Object visitInteractive(Interactive node) throws Exception { ! // System.out.println("lenVisitInteractive:" + node.toString("")); ! return null; ! } ! public Object visitLambda(Lambda node) throws Exception { ! // System.out.println("lenVisitLambda:" + node.toString("")); ! return null; ! } ! public Object visitList(List node) throws Exception { ! // System.out.println("lenVisitList:" + node.toString("")); ! return null; ! } ! public Object visitListComp(ListComp node) throws Exception { ! // System.out.println("lenVisitListComp:" + node.toString("")); ! return null; ! } ! public Object visitModule(Module node) throws Exception { ! // System.out.println("lenVisitModule:" + node.toString("")); ! return null; ! } ! public Object visitNum(Num node) throws Exception { ! // System.out.println("lenVisitNum:" + node.toString("")); ! return null; ! } ! public Object visitPass(Pass node) throws Exception { ! // System.out.println("lenVisitPass:" + node.toString("")); ! return null; ! } ! public Object visitPrint(Print node) throws Exception { ! // System.out.println("lenVisitPrint:" + node.toString("")); ! return null; ! } ! public Object visitRaise(Raise node) throws Exception { ! // System.out.println("lenVisitRaise:" + node.toString("")); ! return null; ! } ! public Object visitRepr(Repr node) throws Exception { ! // System.out.println("lenVisitRepr:" + node.toString("")); ! return null; ! } ! public Object visitReturn(Return node) throws Exception { ! // System.out.println("lenVisitReturn:" + node.toString("")); ! return null; ! } ! public Object visitSlice(Slice node) throws Exception { ! // System.out.println("lenVisitSlice:" + node.toString("")); ! return null; ! } ! public Object visitStr(Str node) throws Exception { ! // System.out.println("lenVisitStr:" + node.toString("")); ! return null; ! } ! public Object visitSubscript(Subscript node) throws Exception { ! // System.out.println("lenVisitSubscript:" + node.toString("")); ! return null; ! } ! public Object visitSuite(Suite node) throws Exception { ! // System.out.println("lenVisitSuite:" + node.toString("")); ! return null; ! } ! public Object visitTryExcept(TryExcept node) throws Exception { ! // System.out.println("lenVisitTryExcept:" + node.toString("")); ! return null; ! } ! public Object visitTryFinally(TryFinally node) throws Exception { ! // System.out.println("lenVisitTryFinally:" + node.toString("")); ! return null; ! } ! public Object visitTuple(Tuple node) throws Exception { ! // System.out.println("lenVisitTuple:" + node.toString("")); ! return null; ! } ! public Object visitUnaryOp(UnaryOp node) throws Exception { ! // System.out.println("lenVisitUnaryOp:" + node.toString("")); ! return null; ! } ! public Object visitWhile(While node) throws Exception { ! // System.out.println("lenVisitWhile:" + node.toString("")); ! return null; ! } ! public Object visitYield(Yield node) throws Exception { ! // System.out.println("lenVisitYield:" + node.toString("")); ! return null; ! } } Index: ItemPointer.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/ItemPointer.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** ItemPointer.java 17 Aug 2008 00:26:46 -0000 1.8 --- ItemPointer.java 28 Sep 2008 12:45:47 -0000 1.9 *************** *** 17,38 **** public class ItemPointer { ! /** ! * IFile or File object (may be null) ! */ ! public final Object file; ! ! /** ! * Position of the 1st character ! */ ! public final Location start; ! ! /** ! * Position of the last character ! */ ! public final Location end; ! ! /** ! * The definition that originated this ItemPointer (good chance of being null). ! */ public final Definition definition; --- 17,38 ---- public class ItemPointer { ! /** ! * IFile or File object (may be null) ! */ ! public final Object file; ! ! /** ! * Position of the 1st character ! */ ! public final Location start; ! ! /** ! * Position of the last character ! */ ! public final Location end; ! ! /** ! * The definition that originated this ItemPointer (good chance of being null). ! */ public final Definition definition; *************** *** 41,51 **** */ public final String zipFilePath; - ! public ItemPointer(Object file) { ! this(file, new Location(), new Location()); ! } ! public ItemPointer(Object file, SimpleNode n) { int line = n.beginLine; int col = n.beginColumn; --- 41,51 ---- */ public final String zipFilePath; ! ! public ItemPointer(Object file) { ! this(file, new Location(), new Location()); ! } ! public ItemPointer(Object file, SimpleNode n) { int line = n.beginLine; int col = n.beginColumn; *************** *** 58,69 **** } ! public ItemPointer(Object file, Location start, Location end) { ! this(file, start, end, null, null); ! } public ItemPointer(Object file, Location start, Location end, Definition definition, String zipFilePath) { ! this.file = file; ! this.start = start; ! this.end = end; this.definition = definition; this.zipFilePath = zipFilePath; --- 58,69 ---- } ! public ItemPointer(Object file, Location start, Location end) { ! this(file, start, end, null, null); ! } public ItemPointer(Object file, Location start, Location end, Definition definition, String zipFilePath) { ! this.file = file; ! this.start = start; ! this.end = end; this.definition = definition; this.zipFilePath = zipFilePath; *************** *** 104,108 **** @Override public int hashCode() { ! int colLineBasedHash = (this.end.column + this.start.line + 7) * 3; if(this.file != null){ return this.file.hashCode() + colLineBasedHash; --- 104,108 ---- @Override public int hashCode() { ! int colLineBasedHash = (this.end.column + this.start.line + 7) * 3; if(this.file != null){ return this.file.hashCode() + colLineBasedHash; Index: Location.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/Location.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** Location.java 26 Jan 2007 16:01:52 -0000 1.4 --- Location.java 28 Sep 2008 12:45:47 -0000 1.5 *************** *** 16,72 **** public class Location { ! /** ! * Location: line and col start at 0 ! */ ! public int line; ! public int column; ! static Location MIN_LOCATION = new Location(0,0); ! static Location MAX_LOCATION = new Location(Integer.MAX_VALUE, Integer.MAX_VALUE); ! ! public Location() { ! line = column = 0; ! } ! public Location(int line, int column) { ! this.line = line; ! this.column = column; ! } ! ! /** ! * Conversion to document coordinates. ! */ ! public int toOffset(IDocument document) throws BadLocationException { ! return document.getLineOffset(line) + column; ! } ! /** ! * @return true if location is completely enclosed between start & end. ! */ ! public boolean contained(Location start, Location end) { ! boolean startOk = (line > start.line || line == start.line && column >= start.column); ! boolean endOk = startOk ? (line < end.line || line == end.line && column <= end.column): false; ! return startOk && endOk; ! } ! ! public String toString() { ! return "L:" + Integer.toString(line) + " C:" + Integer.toString(column); ! } ! ! /** ! * standard compare ! * @return 1 means I win, -1 means argument wins, 0 means equal ! */ ! public int compareTo(Location l) { ! if (line > l.line) ! return 1; ! if (line < l.line) ! return -1; ! if (column > l.column) ! return 1; ! if (column < l.column) ! return -1; ! return 0; ! } @Override --- 16,72 ---- public class Location { ! /** ! * Location: line and col start at 0 ! */ ! public int line; ! public int column; ! static Location MIN_LOCATION = new Location(0,0); ! static Location MAX_LOCATION = new Location(Integer.MAX_VALUE, Integer.MAX_VALUE); ! ! public Location() { ! line = column = 0; ! } ! public Location(int line, int column) { ! this.line = line; ! this.column = column; ! } ! ! /** ! * Conversion to document coordinates. ! */ ! public int toOffset(IDocument document) throws BadLocationException { ! return document.getLineOffset(line) + column; ! } ! /** ! * @return true if location is completely enclosed between start & end. ! */ ! public boolean contained(Location start, Location end) { ! boolean startOk = (line > start.line || line == start.line && column >= start.column); ! boolean endOk = startOk ? (line < end.line || line == end.line && column <= end.column): false; ! return startOk && endOk; ! } ! ! public String toString() { ! return "L:" + Integer.toString(line) + " C:" + Integer.toString(column); ! } ! ! /** ! * standard compare ! * @return 1 means I win, -1 means argument wins, 0 means equal ! */ ! public int compareTo(Location l) { ! if (line > l.line) ! return 1; ! if (line < l.line) ! return -1; ! if (column > l.column) ! return 1; ! if (column < l.column) ! return -1; ! return 0; ! } @Override *************** *** 83,99 **** return (line * 99) + (column * 5); } ! ! /** ! * Utility: Converts document's offset to Location ! * @return Location ! */ ! static public Location offsetToLocation(IDocument document, int offset) { ! try { ! int line = document.getLineOfOffset(offset); ! int line_start = document.getLineOffset(line); ! return new Location(line, offset - line_start); ! } catch (BadLocationException e) { ! return new Location(); ! } ! } } --- 83,99 ---- return (line * 99) + (column * 5); } ! ! /** ! * Utility: Converts document's offset to Location ! * @return Location ! */ ! static public Location offsetToLocation(IDocument document, int offset) { ! try { ! int line = document.getLineOfOffset(offset); ! int line_start = document.getLineOffset(line); ! return new Location(line, offset - line_start); ! } catch (BadLocationException e) { ! return new Location(); ! } ! } } Index: IModelListener.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev/src/org/python/pydev/editor/model/IModelListener.java,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** IModelListener.java 1 May 2007 13:57:28 -0000 1.5 --- IModelListener.java 28 Sep 2008 12:45:47 -0000 1.6 *************** *** 6,10 **** package org.python.pydev.editor.model; ! import org.python.pydev.editor.ErrorDescription; import org.python.pydev.parser.jython.SimpleNode; --- 6,10 ---- package org.python.pydev.editor.model; ! import org.python.pydev.parser.ErrorDescription; import org.python.pydev.parser.jython.SimpleNode; *************** *** 15,28 **** */ public interface IModelListener { ! /** ! * every time document gets parsed, it generates a new parse tree ! * @param root - the root of the new model ! */ ! void modelChanged(SimpleNode root); /** * Every time the document changes its error state, it generates this notification */ ! void errorChanged(ErrorDescription errorDesc); } --- 15,28 ---- */ public interface IModelListener { ! /** ! * every time document gets parsed, it generates a new parse tree ! * @param root - the root of the new model ! */ ! void modelChanged(SimpleNode root); /** * Every time the document changes its error state, it generates this notification */ ! void errorChanged(ErrorDescription errorDesc); } |