Thread: [Pydev-cvs] org.python.pydev.parser/src/org/python/pydev/parser/visitors NodeUtils.java,1.10,1.11
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2005-07-29 18:00:09
|
Update of /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21513/src/org/python/pydev/parser/visitors Modified Files: NodeUtils.java Log Message: Index: NodeUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.parser/src/org/python/pydev/parser/visitors/NodeUtils.java,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** NodeUtils.java 29 Jul 2005 01:06:39 -0000 1.10 --- NodeUtils.java 29 Jul 2005 18:00:00 -0000 1.11 *************** *** 171,182 **** } public static int[] getColLineEnd(SimpleNode v) { int lineEnd = getLineEnd(v); int col = 0; ! if(lineEnd == v.beginLine){ if(v instanceof Str){ String s = ((Str)v).s; ! col = v.beginColumn + s.length(); }else{ col = getFromRepresentation(v); --- 171,216 ---- } + + + /** + * @param ast2 the node to work with + * @return the line definition of a node + */ + public static int getLineDefinition(SimpleNode ast2) { + if(ast2 instanceof Attribute){ + if(!(((Attribute)ast2).value instanceof Call)){ + return getLineDefinition(((Attribute)ast2).value); + } + } + return ast2.beginLine; + } + + + /** + * @param ast2 the node to work with + * @return the column definition of a node + */ + public static int getColDefinition(SimpleNode ast2) { + if(ast2 instanceof Attribute){ + if(!(((Attribute)ast2).value instanceof Call)){ + return getColDefinition(((Attribute)ast2).value); + } + } + return ast2.beginColumn; + } + + + /** + * @param v the token to work with + * @return a tuple with [line, col] of the definition of a token + */ public static int[] getColLineEnd(SimpleNode v) { int lineEnd = getLineEnd(v); int col = 0; ! if(lineEnd == getLineDefinition(v)){ if(v instanceof Str){ String s = ((Str)v).s; ! col = getColDefinition(v) + s.length(); }else{ col = getFromRepresentation(v); *************** *** 210,214 **** } try { ! col = v.beginColumn + representationString.length(); } catch (Exception e) { col = -1; --- 244,248 ---- } try { ! col = getColDefinition(v) + representationString.length(); } catch (Exception e) { col = -1; *************** *** 228,237 **** } } ! // StringTokenizer tokenizer = new StringTokenizer(s, "\n"); ! // int countTokens = tokenizer.countTokens(); ! // System.out.println("For-->"+s+"<-- ="+countTokens); ! return v.beginLine + found; } ! return v.beginLine; } --- 262,268 ---- } } ! return getLineDefinition(v) + found; } ! return getLineDefinition(v); } *************** *** 275,278 **** --- 306,310 ---- return null; } + } |