[Pydev-cvs] org.python.pydev.core/src/org/python/pydev/core/docutils ParsingUtils.java,1.1,1.2
Brought to you by:
fabioz
From: Fabio Z. <fa...@us...> - 2006-03-15 00:16:17
|
Update of /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24628/src/org/python/pydev/core/docutils Modified Files: ParsingUtils.java Log Message: Index: ParsingUtils.java =================================================================== RCS file: /cvsroot/pydev/org.python.pydev.core/src/org/python/pydev/core/docutils/ParsingUtils.java,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** ParsingUtils.java 25 Feb 2006 00:13:09 -0000 1.1 --- ParsingUtils.java 15 Mar 2006 00:16:13 -0000 1.2 *************** *** 322,324 **** --- 322,365 ---- } + public final static String PY_COMMENT = "__python_comment"; + public final static String PY_SINGLELINE_STRING = "__python_singleline_string"; + public final static String PY_MULTILINE_STRING = "__python_multiline_string"; + public final static String PY_BACKQUOTES = "__python_backquotes"; + public final static String PY_DEFAULT = "__dftl_partition_content_type"; + + /** + * @param initial + * @param currPos + * @return the content type of the + */ + public static String getContentType(String initial, int currPos) { + StringBuffer buf = new StringBuffer(initial); + String curr = PY_DEFAULT; + + for (int i = 0; i < buf.length() && i < currPos; i++) { + char ch = buf.charAt(i); + curr = PY_DEFAULT; + + if(ch == '#'){ + curr = PY_COMMENT; + + int j = i; + while(j < buf.length()-1 && ch != '\n' && ch != '\r'){ + j++; + ch = buf.charAt(j); + } + i = j; + } + if(i >= currPos){ + return curr; + } + + if(ch == '\'' || ch == '"'){ + curr = PY_SINGLELINE_STRING; + i = getLiteralEnd(buf, i, ch); + } + } + return curr; + } + } |