[Pydev-cvs] org.python.pydev.core/src/org/python/pydev/core/docutils PySelection.java,1.8,1.9 Parsin
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2006-04-06 23:42:09
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9054/src/org/python/pydev/core/docutils Modified Files: PySelection.java ParsingUtils.java Log Message: Index: PySelection.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/PySelection.java,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** PySelection.java 6 Apr 2006 16:05:57 -0000 1.8 --- PySelection.java 6 Apr 2006 23:41:58 -0000 1.9 *************** *** 250,263 **** } ! public static String getLineWithoutComments(String l) { ! int i; ! if((i = l.indexOf('#') ) != -1){ ! l = l.substring(0, i); ! } ! return l; } ! public String getLineWithoutComments() { ! return getLineWithoutComments(getLine()); } --- 250,261 ---- } ! public static String getLineWithoutCommentsOrLiterals(String l) { ! StringBuffer buf = new StringBuffer(l); ! ParsingUtils.removeCommentsWhitespacesAndLiterals(buf, false); ! return buf.toString(); } ! public String getLineWithoutCommentsOrLiterals() { ! return getLineWithoutCommentsOrLiterals(getLine()); } Index: ParsingUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/ParsingUtils.java,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** ParsingUtils.java 22 Mar 2006 16:45:22 -0000 1.4 --- ParsingUtils.java 6 Apr 2006 23:41:58 -0000 1.5 *************** *** 263,266 **** --- 263,269 ---- } + public static void removeCommentsWhitespacesAndLiterals(StringBuffer buf) { + removeCommentsWhitespacesAndLiterals(buf, true); + } /** * Removes all the comments, whitespaces and literals from a stringbuffer (might be useful when *************** *** 268,273 **** * * @param buf the buffer from where things should be removed. */ ! public static void removeCommentsWhitespacesAndLiterals(StringBuffer buf) { for (int i = 0; i < buf.length(); i++) { char ch = buf.charAt(i); --- 271,277 ---- * * @param buf the buffer from where things should be removed. + * @param whitespacesToo: are you sure about the whitespaces? */ ! public static void removeCommentsWhitespacesAndLiterals(StringBuffer buf, boolean whitespacesToo) { for (int i = 0; i < buf.length(); i++) { char ch = buf.charAt(i); *************** *** 288,296 **** } ! int length = buf.length(); ! for (int i = length -1; i >= 0; i--) { ! char ch = buf.charAt(i); ! if(Character.isWhitespace(ch)){ ! buf.deleteCharAt(i); } } --- 292,302 ---- } ! if(whitespacesToo){ ! int length = buf.length(); ! for (int i = length -1; i >= 0; i--) { ! char ch = buf.charAt(i); ! if(Character.isWhitespace(ch)){ ! buf.deleteCharAt(i); ! } } } |