Thread: [Pydev-cvs] org.python.pydev.core/src/org/python/pydev/core/docutils ParsingUtils.java, 1.22, 1.23
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2008-07-06 17:10:31
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29951/src/org/python/pydev/core/docutils Modified Files: ParsingUtils.java Log Message: Minor changes in parsing utilities (removed unused methods / minor refactorings) Index: ParsingUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/ParsingUtils.java,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** ParsingUtils.java 5 Jul 2008 21:53:05 -0000 1.22 --- ParsingUtils.java 6 Jul 2008 17:10:39 -0000 1.23 *************** *** 14,36 **** ! public class ParsingUtils implements IPythonPartitions{ - /** - * @param cs the char array we are parsing - * @param buf used to add the comments contents (out) - * @param i the position - * @return the : position - */ - public static int eatToColon(char[] cs, FastStringBuffer buf, int i) { - while(i < cs.length && cs[i] != ':'){ - buf.append(cs[i]); - i++; - } - if(i < cs.length) - buf.append(cs[i]); - - return i; - } /** --- 14,24 ---- ! /** ! * Helper class for parsing python code. ! * ! * @author Fabio ! */ public class ParsingUtils implements IPythonPartitions{ /** *************** *** 42,53 **** */ public static int eatComments(Object cs, FastStringBuffer buf, int i) { ! while(i < len(cs) && charAt(cs,i) != '\n' && charAt(cs,i) != '\r'){ if(buf != null){ ! buf.append(charAt(cs,i)); } i++; } ! if(i < len(cs)){ if(buf != null){ buf.append(charAt(cs,i)); --- 30,44 ---- */ public static int eatComments(Object cs, FastStringBuffer buf, int i) { ! int len = len(cs); ! char c; ! ! while(i < len && (c = charAt(cs,i)) != '\n' && c != '\r'){ if(buf != null){ ! buf.append(c); } i++; } ! if(i < len){ if(buf != null){ buf.append(charAt(cs,i)); *************** *** 58,91 **** } - /** - * @param cs the char array we are parsing - * @param buf used to add the comments contents (out) - * @param i the # position - * @return the end of the comments position (end of document or new line char) - */ - public static int eatComments(char[] cs, int i) { - while(i < cs.length && cs[i] != '\n' && cs[i] != '\r'){ - i++; - } - - return i; - } - - /** - * @param cs the char array we are parsing - * @param buf used to add the token contents (out) - * @param i the start of the token - * @return the end of the token position (end of document or new line char or whitespace) - */ - public static int eatToken(char[] cs, FastStringBuffer buf, int i) { - while(i < cs.length && !Character.isWhitespace(cs[i])){ - buf.append(cs[i]); - i++; - } - if(i < cs.length) - buf.append(cs[i]); - - return i; - } /** --- 49,52 ---- *************** *** 107,111 **** if(buf != null){ ! for (int k = i; k < len(cs) && k <= j; k++) { buf.append(charAt(cs, k)); } --- 68,73 ---- if(buf != null){ ! int len = len(cs); ! for (int k = i; k < len && k <= j; k++) { buf.append(charAt(cs, k)); } *************** *** 152,156 **** int j = i+1; ! while(j < len(cs) && (c = charAt(cs,j)) != closingPar){ j++; --- 114,119 ---- int j = i+1; ! int len = len(cs); ! while(j < len && (c = charAt(cs,j)) != closingPar){ j++; *************** *** 180,184 **** public static int findNextSingle(Object cs, int i, char curr) { boolean ignoreNext = false; ! while(i < len(cs)){ char c = charAt(cs,i); --- 143,148 ---- public static int findNextSingle(Object cs, int i, char curr) { boolean ignoreNext = false; ! int len = len(cs); ! while(i < len){ char c = charAt(cs,i); *************** *** 205,209 **** */ public static int findNextMulti(Object cs, int i, char curr) { ! while(i+2 < len(cs)){ char c = charAt(cs,i); if (c == curr && charAt(cs,i+1) == curr && charAt(cs,i+2) == curr){ --- 169,174 ---- */ public static int findNextMulti(Object cs, int i, char curr) { ! int len = len(cs); ! while(i+2 < len){ char c = charAt(cs,i); if (c == curr && charAt(cs,i+1) == curr && charAt(cs,i+2) == curr){ *************** *** 215,220 **** } } ! if(len(cs) < i+2){ ! return len(cs); } return i+2; --- 180,185 ---- } } ! if(len < i+2){ ! return len; } return i+2; *************** *** 271,275 **** */ public static boolean isMultiLiteral(Object cs, int i, char curr){ ! if(len(cs) <= i + 2){ return false; } --- 236,241 ---- */ public static boolean isMultiLiteral(Object cs, int i, char curr){ ! int len = len(cs); ! if(len <= i + 2){ return false; } *************** *** 280,296 **** } - public static int eatWhitespaces(char cs[], int i) { - while(i < cs.length && Character.isWhitespace(cs[i])){ - i++; - } - return i; - } - - public static int eatWhitespaces(FastStringBuffer buf, int i) { - while(i < buf.length() && Character.isWhitespace(buf.charAt(i))){ - i++; - } - return i; - } public static void removeCommentsWhitespacesAndLiterals(FastStringBuffer buf) { --- 246,249 ---- *************** *** 390,407 **** } - public static void removeToClosingPar(FastStringBuffer buf) { - int length = buf.length(); - for (int i = length -1; i >= 0; i--) { - char ch = buf.charAt(i); - if(ch != ')'){ - buf.deleteCharAt(i); - }else{ - buf.deleteCharAt(i); - return; - - } - } - } - /** --- 343,346 ---- *************** *** 539,557 **** } - public static String getLastLine(String code) { - int i = code.lastIndexOf('\r'); - int j = code.lastIndexOf('\n'); - if(i == -1 && j == -1){ - return code; - } - - char toSplit = '\n'; - if(i > j){ - toSplit = '\r'; - } - - String[] strings = StringUtils.split(code, toSplit); - return strings[strings.length-1]; - } public static String removeComments(String line) { --- 478,481 ---- |